Browse Source

Clear all previous location fields (#2658)

pull/2659/head^2
kosiakkatrina 3 months ago committed by GitHub
parent
commit
7c8f62a164
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      app/controllers/form_controller.rb
  2. 27
      spec/requests/check_errors_controller_spec.rb

1
app/controllers/form_controller.rb

@ -409,6 +409,7 @@ private
next if question.subsection.id == "setup"
question.page.questions.map(&:id).each { |id| @log[id] = nil }
@log.previous_la_known = nil if question.id == "ppostcode_full"
end
@log.save!
@questions = params[@log.model_name.param_key].keys.reject { |id| %w[clear_question_ids page].include?(id) }.map { |id| @log.form.get_question(id, @log) }

27
spec/requests/check_errors_controller_spec.rb

@ -300,6 +300,33 @@ RSpec.describe CheckErrorsController, type: :request do
end
end
context "and clearing ppostcode_full when previous_la_known is yes" do
let(:params) do
{
id: lettings_log.id,
lettings_log: {
layear: "1",
clear_question_ids: "ppostcode_full",
page: "time_lived_in_local_authority",
},
check_errors: "",
}
end
before do
lettings_log.update!(previous_la_known: 1, ppcodenk: 0, ppostcode_full: "AA11AA")
sign_in user
post "/lettings-logs/#{lettings_log.id}/time-lived-in-local-authority", params:
end
it "clears related previous location fields" do
expect(lettings_log.reload.prevloc).to eq(nil)
expect(lettings_log.reload.previous_la_known).to eq(nil)
expect(lettings_log.reload.ppostcode_full).to eq(nil)
expect(lettings_log.reload.ppcodenk).to eq(nil)
end
end
context "and clearing specific sales question" do
let(:params) do
{

Loading…
Cancel
Save