Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
antulik committed Jul 25, 2024
1 parent 9ac6a50 commit c188934
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions spec/lib/model_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,28 @@ def execute

describe '#any_changed?' do
it 'is false if value has not changed' do
model = double('Model', date_field: Date.today)
model = double('Model', date_field: Date.today, new_record?: false)
form = test_form_class.new(model: model, date_field: Date.today)

expect(form.any_changed?(:date_field)).to be false
end

it 'is true if new record' do
model = double('Model', date_field: Date.today, new_record?: true)
form = test_form_class.new(model: model, date_field: Date.today)

expect(form.any_changed?(:date_field)).to be true
end

it 'is true when value changed' do
model = double('Model', date_field: Date.today)
model = double('Model', date_field: Date.today, new_record?: false)
form = test_form_class.new(model: model, date_field: Date.tomorrow)

expect(form.any_changed?(:date_field)).to be true
end

it 'is true when value is cleared' do
model = double('Model', date_field: Date.today)
model = double('Model', date_field: Date.today, new_record?: false)
form = test_form_class.new(model: model, date_field: nil)

expect(form.any_changed?(:date_field)).to be true
Expand Down

0 comments on commit c188934

Please sign in to comment.