Skip to content

Commit

Permalink
Merge pull request #28 from annkissam/fix-end-date-propagator-messages
Browse files Browse the repository at this point in the history
Apply messages directly, not via keyword.
  • Loading branch information
izzergh authored Feb 2, 2021
2 parents b5310c2 + 799dd01 commit 64dbb8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions lib/acts_as_span/end_date_propagator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def call
result = propagate
# only add new errors to the object
result.errors.each do |error, message|
unless object.errors[error].include? message
object.errors.add(error, message: message)
end
object.errors.add(error) if object.errors[error].exclude? message
end
object
end
Expand All @@ -114,7 +112,7 @@ def propagate
errors_cache.each do |message|
skip if object.errors.added?(:base, message)

object.errors.add(:base, message: message)
object.errors.add(:base, message)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_span/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ActsAsSpan
module VERSION
MAJOR = 1
MINOR = 2
TINY = 0
TINY = 1
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/end_date_propagator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
end
it "the parent shows that grandchild's errors" do
expect(
end_date_propagator.call.errors.values.join
end_date_propagator.call.errors.full_messages.join
).to include(
I18n.t(
'not_within_parent_date_span',
Expand All @@ -114,7 +114,7 @@
end
it "the parent gains all children's errors" do
expect(
end_date_propagator.call.errors.values.join
end_date_propagator.call.errors.full_messages.join
).to include(
I18n.t(
'not_within_parent_date_span',
Expand All @@ -135,7 +135,7 @@
let(:include_errors) { false }

it 'does not push any child errors' do
expect(end_date_propagator.call.errors.values).to be_empty
expect(end_date_propagator.call.errors.full_messages).to be_empty
end
end
end
Expand Down

0 comments on commit 64dbb8e

Please sign in to comment.