Browse Source

Add success banner

pull/2480/head
Kat 2 years ago
parent
commit
f4e29db746
  1. 2
      app/controllers/form_controller.rb
  2. 4
      spec/requests/check_errors_controller_spec.rb

2
app/controllers/form_controller.rb

@ -229,11 +229,13 @@ private
if params[@log.model_name.param_key]["check_errors"] if params[@log.model_name.param_key]["check_errors"]
@page = form.get_page(params[@log.model_name.param_key]["page"]) @page = form.get_page(params[@log.model_name.param_key]["page"])
flash[:notice] = "You have successfully updated #{@page.questions.map(&:check_answer_label).to_sentence}"
return send("#{@log.class.name.underscore}_#{params[@log.model_name.param_key]['original_page_id']}_path", @log, { check_errors: true, related_question_ids: params[@log.model_name.param_key]["related_question_ids"].split(" ") }.compact) return send("#{@log.class.name.underscore}_#{params[@log.model_name.param_key]['original_page_id']}_path", @log, { check_errors: true, related_question_ids: params[@log.model_name.param_key]["related_question_ids"].split(" ") }.compact)
end end
if params["referrer"] == "check_errors" if params["referrer"] == "check_errors"
@page = form.get_page(params[@log.model_name.param_key]["page"]) @page = form.get_page(params[@log.model_name.param_key]["page"])
flash[:notice] = "You have successfully updated #{@page.questions.map(&:check_answer_label).to_sentence}"
return send("#{@log.class.name.underscore}_#{params['original_page_id']}_path", @log, { check_errors: true, related_question_ids: params["related_question_ids"] }.compact) return send("#{@log.class.name.underscore}_#{params['original_page_id']}_path", @log, { check_errors: true, related_question_ids: params["related_question_ids"] }.compact)
end end

4
spec/requests/check_errors_controller_spec.rb

@ -274,7 +274,7 @@ RSpec.describe CheckErrorsController, type: :request do
context "and answering specific lettings question" do context "and answering specific lettings question" do
let(:params) do let(:params) do
{ {
original_page_id: "income_amount", original_page_id: "household_members",
referrer: "check_errors", referrer: "check_errors",
related_question_ids: %w[hhmemb ecstat1 earnings], related_question_ids: %w[hhmemb ecstat1 earnings],
lettings_log: { lettings_log: {
@ -293,6 +293,7 @@ RSpec.describe CheckErrorsController, type: :request do
follow_redirect! follow_redirect!
expect(request.query_parameters["check_errors"]).to eq("true") expect(request.query_parameters["check_errors"]).to eq("true")
expect(request.query_parameters["related_question_ids"]).to eq(%w[hhmemb ecstat1 earnings]) expect(request.query_parameters["related_question_ids"]).to eq(%w[hhmemb ecstat1 earnings])
expect(page).to have_content("You have successfully updated Number of household members")
end end
end end
@ -319,6 +320,7 @@ RSpec.describe CheckErrorsController, type: :request do
follow_redirect! follow_redirect!
expect(request.query_parameters["check_errors"]).to eq("true") expect(request.query_parameters["check_errors"]).to eq("true")
expect(request.query_parameters["related_question_ids"]).to eq(%w[income1 la ownershipsch]) expect(request.query_parameters["related_question_ids"]).to eq(%w[income1 la ownershipsch])
expect(page).to have_content("You have successfully updated Buyer 1’s gross annual income known? and Buyer 1’s gross annual income")
end end
end end
end end

Loading…
Cancel
Save