Browse Source

Fix page invalidation when no form set

pull/302/head
baarkerlounger 3 years ago
parent
commit
6b98cf354f
  1. 2
      app/models/case_log.rb
  2. 12
      spec/models/case_log_spec.rb

2
app/models/case_log.rb

@ -226,6 +226,8 @@ private
end
def reset_invalidated_dependent_fields!
return unless form
form.invalidated_page_questions(self).each do |question|
public_send("#{question.id}=", nil) if respond_to?(question.id.to_s)
end

12
spec/models/case_log_spec.rb

@ -656,6 +656,10 @@ RSpec.describe CaseLog do
case_log.update(age1: 25)
end
it "validates start date" do
expect(validator).to receive(:validate_startdate)
end
it "validates ages" do
expect(validator).to receive(:validate_person_1_age)
expect(validator).to receive(:validate_household_number_of_other_members)
@ -1039,6 +1043,14 @@ RSpec.describe CaseLog do
expect(case_log.cbl).to eq("Yes")
end
end
context "when the case log does not have a valid form set yet" do
let(:case_log) { FactoryBot.create(:case_log) }
it "does not throw an error" do
expect { case_log.update(startdate: Time.zone.local(2015, 1, 1)) }.not_to raise_error
end
end
end
describe "paper trail" do

Loading…
Cancel
Save