|
|
@ -230,9 +230,10 @@ RSpec.describe FormController, type: :request do |
|
|
|
Form::Question.new("tenant_code", { "type" => "text" }, nil), |
|
|
|
Form::Question.new("tenant_code", { "type" => "text" }, nil), |
|
|
|
] |
|
|
|
] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
let(:page) { case_log.form.get_page("accessibility_requirements") } |
|
|
|
|
|
|
|
|
|
|
|
it "updates both question fields" do |
|
|
|
it "updates both question fields" do |
|
|
|
allow_any_instance_of(Form::Page).to receive(:expected_responses).and_return(questions_for_page) |
|
|
|
allow(page).to receive(:expected_responses).and_return(questions_for_page) |
|
|
|
post "/logs/#{case_log.id}/form", params: case_log_form_params |
|
|
|
post "/logs/#{case_log.id}/form", params: case_log_form_params |
|
|
|
case_log.reload |
|
|
|
case_log.reload |
|
|
|
|
|
|
|
|
|
|
@ -244,10 +245,7 @@ RSpec.describe FormController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with conditional routing" do |
|
|
|
context "with conditional routing" do |
|
|
|
before do |
|
|
|
let(:validator) { case_log._validators[nil].first } |
|
|
|
allow_any_instance_of(CaseLogValidator).to receive(:validate_pregnancy).and_return(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:case_log_form_conditional_question_yes_params) do |
|
|
|
let(:case_log_form_conditional_question_yes_params) do |
|
|
|
{ |
|
|
|
{ |
|
|
|
id: case_log.id, |
|
|
|
id: case_log.id, |
|
|
@ -257,7 +255,6 @@ RSpec.describe FormController, type: :request do |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
let(:case_log_form_conditional_question_no_params) do |
|
|
|
let(:case_log_form_conditional_question_no_params) do |
|
|
|
{ |
|
|
|
{ |
|
|
|
id: case_log.id, |
|
|
|
id: case_log.id, |
|
|
@ -267,7 +264,6 @@ RSpec.describe FormController, type: :request do |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
let(:case_log_form_conditional_question_wchair_yes_params) do |
|
|
|
let(:case_log_form_conditional_question_wchair_yes_params) do |
|
|
|
{ |
|
|
|
{ |
|
|
|
id: case_log.id, |
|
|
|
id: case_log.id, |
|
|
@ -278,6 +274,10 @@ RSpec.describe FormController, type: :request do |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
allow(validator).to receive(:validate_pregnancy).and_return(true) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "routes to the appropriate conditional page based on the question answer of the current page" do |
|
|
|
it "routes to the appropriate conditional page based on the question answer of the current page" do |
|
|
|
post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_yes_params |
|
|
|
post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_yes_params |
|
|
|
expect(response).to redirect_to("/logs/#{case_log.id}/conditional-question-yes-page") |
|
|
|
expect(response).to redirect_to("/logs/#{case_log.id}/conditional-question-yes-page") |
|
|
|