From c1889342b0f5ab24b3a00b52131fc6230c2a3efc Mon Sep 17 00:00:00 2001 From: Anton Katunin Date: Thu, 25 Jul 2024 17:16:33 +1000 Subject: [PATCH] Fix specs --- spec/lib/model_fields_spec.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/lib/model_fields_spec.rb b/spec/lib/model_fields_spec.rb index 6029fd3..29f453d 100644 --- a/spec/lib/model_fields_spec.rb +++ b/spec/lib/model_fields_spec.rb @@ -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