Skip to content

Commit

Permalink
fix #417 by allowing explicitly made detailed errors on :base mergeable
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronLasseigne committed Jun 9, 2017
1 parent 4ae9a05 commit 017276a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_interaction/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def merge_details!(other)
end

def merge_detail!(other, attribute, detail, error)
if attribute?(attribute)
if attribute?(attribute) || attribute == :base
add(attribute, error, detail) unless added?(attribute, error, detail)
else
translated_error = translate(other, attribute, error)
Expand Down
11 changes: 11 additions & 0 deletions spec/active_interaction/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def self.name
end
end

context 'that is a symbol on base' do
before do
other.add(:base)
end

it 'adds the error' do
errors.merge!(other)
expect(errors.details[:base]).to eql [{ error: :invalid }]
end
end

context 'that is a string' do
let(:message) { SecureRandom.hex }

Expand Down

0 comments on commit 017276a

Please sign in to comment.