Skip to content

Commit

Permalink
Merge branch 'hotfix/0.8.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
thornomad committed Dec 15, 2020
2 parents b98bfcd + fb7efc6 commit 1b8d4e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
enumbler (0.8.1)
enumbler (0.8.2)
activerecord (>= 5.2.3, < 6.1)
activesupport (>= 5.2.3, < 6.1)

Expand Down
2 changes: 2 additions & 0 deletions lib/enumbler/enabler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def find_enumbles(*args, case_sensitive: false, raise_error: false)
enumble =
if arg.is_a?(Symbol)
@enumbled_model.enumbles.find { |e| e.enum == arg }
elsif arg.is_a?(Enumbler::Enumble)
@enumbled_model.enumbles.find { |e| e.enum == arg.enum }
elsif arg.is_a?(String)
@enumbled_model.enumbles.find do |e|
if case_sensitive
Expand Down
2 changes: 1 addition & 1 deletion lib/enumbler/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Enumbler
VERSION = '0.8.1'
VERSION = '0.8.2'
end
3 changes: 3 additions & 0 deletions spec/enumbler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,14 @@ class Sky < ApplicationRecord
it 'returns the correct enumbles' do
expect(Color.find_enumbles(1, 2)).to contain_exactly(Color.enumbles.first, Color.enumbles.second)
expect(Color.find_enumble(1)).to eq Color.enumbles.first
expect(Color.find_enumble(Color.enumbles.first)).to eq Color.enumbles.first
end

it 'can return an enumble based on a ActiveModel record' do
color = Color.find(1)
expect(Color.find_enumbles!(color)).to contain_exactly(color.enumble)
end

it 'raises an error when something that is not an integer is passed' do
expect { Color.find_enumbles('bob') }.not_to raise_error
expect { Color.find_enumbles!('bob') }.to raise_error(Enumbler::Error, /bob/)
Expand Down

0 comments on commit 1b8d4e2

Please sign in to comment.