diff --git a/spec/factories/models/forms.rb b/spec/factories/models/forms.rb index 6c82f79ba..f26e95fb2 100644 --- a/spec/factories/models/forms.rb +++ b/spec/factories/models/forms.rb @@ -104,7 +104,7 @@ end pages do - Array.new(pages_count) { association(:page, :with_selections_settings) } + Array.new(pages_count) { association(:page, :with_selection_settings) } end end diff --git a/spec/factories/models/pages.rb b/spec/factories/models/pages.rb index d890605db..639f8a0f6 100644 --- a/spec/factories/models/pages.rb +++ b/spec/factories/models/pages.rb @@ -37,7 +37,7 @@ def as_json(*args) answer_type { Page::ANSWER_TYPES_WITHOUT_SETTINGS.sample } end - trait :with_selections_settings do + trait :with_selection_settings do transient do only_one_option { "true" } selection_options { [{ name: "Option 1" }, { name: "Option 2" }] } diff --git a/spec/features/form/add_or_edit_questions/edit_answer_settings_for_existing_questions_spec.rb b/spec/features/form/add_or_edit_questions/edit_answer_settings_for_existing_questions_spec.rb index a6c2ec186..449148938 100644 --- a/spec/features/form/add_or_edit_questions/edit_answer_settings_for_existing_questions_spec.rb +++ b/spec/features/form/add_or_edit_questions/edit_answer_settings_for_existing_questions_spec.rb @@ -24,7 +24,7 @@ let(:address_question) { build(:page, :with_address_settings, form_id: 1) } let(:date_question) { build(:page, :with_date_settings, form_id: 1, input_type: "date_of_birth") } let(:name_question) { build(:page, :with_name_settings, form_id: 1, input_type: "first_middle_and_last_name", title_needed: "true") } - let(:selection_question) { build(:page, :with_selections_settings, form_id: 1, is_optional: true) } + let(:selection_question) { build(:page, :with_selection_settings, form_id: 1, is_optional: true) } let(:text_question) { build(:page, :with_text_settings, form_id: 1, input_type: "long_text") } let(:pages) { [address_question, date_question, name_question, selection_question, text_question] } diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 09e5eed19..446deeefd 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -145,12 +145,12 @@ end let(:selection_pages_with_routes) do (4..5).map do |index| - build :page, :with_selections_settings, id: index, position: index, routing_conditions: [(build :condition, id: index, check_page_id: index, goto_page_id: index + 2)] + build :page, :with_selection_settings, id: index, position: index, routing_conditions: [(build :condition, id: index, check_page_id: index, goto_page_id: index + 2)] end end let(:selection_pages_without_routes) do (6..9).map do |index| - build :page, :with_selections_settings, id: index, position: index, routing_conditions: [] + build :page, :with_selection_settings, id: index, position: index, routing_conditions: [] end end let(:form) { build :form, name: "Form 1", organisation:, submission_email: "", pages: non_select_from_list_pages + selection_pages_with_routes + selection_pages_without_routes } @@ -164,12 +164,12 @@ describe "#has_no_remaining_routes_available?" do let(:selection_pages_with_routes) do (1..3).map do |index| - build :page, :with_selections_settings, id: index, position: index, routing_conditions: [(build :condition, id: index, check_page_id: index, goto_page_id: index + 2)] + build :page, :with_selection_settings, id: index, position: index, routing_conditions: [(build :condition, id: index, check_page_id: index, goto_page_id: index + 2)] end end let(:selection_pages_without_routes) do (4..5).map do |index| - build :page, :with_selections_settings, id: index, position: index, routing_conditions: [] + build :page, :with_selection_settings, id: index, position: index, routing_conditions: [] end end diff --git a/spec/policies/form_policy_spec.rb b/spec/policies/form_policy_spec.rb index 41a55f6d5..cf7a0ab48 100644 --- a/spec/policies/form_policy_spec.rb +++ b/spec/policies/form_policy_spec.rb @@ -124,7 +124,7 @@ context "and the form only has a selection question with an existing route" do let(:routing_conditions) { [(build :condition, id: 1, check_page_id: 1, answer_value: "Wales", goto_pageid: 2)] } - let(:pages) { [(build :page, :with_selections_settings, position: 1, id: 1, routing_conditions:), (build :page, position: 2, id: 2)] } + let(:pages) { [(build :page, :with_selection_settings, position: 1, id: 1, routing_conditions:), (build :page, position: 2, id: 2)] } it { is_expected.to forbid_actions(%i[can_add_page_routing_conditions]) } end @@ -132,14 +132,14 @@ context "and the form has a selection question without an existing route" do context "and the available selection question is the last page in the form" do let(:routing_conditions) { [(build :condition, id: 1, check_page_id: 1, answer_value: "Wales", goto_pageid: 2)] } - let(:pages) { [(build :page, :with_selections_settings, position: 1, id: 1, routing_conditions:), (build :page, position: 2, id: 2), (build :page, :with_selections_settings, position: 3, id: 3)] } + let(:pages) { [(build :page, :with_selection_settings, position: 1, id: 1, routing_conditions:), (build :page, position: 2, id: 2), (build :page, :with_selection_settings, position: 3, id: 3)] } it { is_expected.to forbid_actions(%i[can_add_page_routing_conditions]) } end context "and the available selection question is not the last page in the form" do let(:routing_conditions) { [(build :condition, id: 1, check_page_id: 1, answer_value: "Wales", goto_pageid: 2)] } - let(:pages) { [(build :page, :with_selections_settings, position: 1, id: 1, routing_conditions:), (build :page, :with_selections_settings, position: 2, id: 2), (build :page, position: 3, id: 3)] } + let(:pages) { [(build :page, :with_selection_settings, position: 1, id: 1, routing_conditions:), (build :page, :with_selection_settings, position: 2, id: 2), (build :page, position: 3, id: 3)] } it { is_expected.to permit_actions(%i[can_add_page_routing_conditions]) } end diff --git a/spec/requests/pages/secondary_skip_controller_spec.rb b/spec/requests/pages/secondary_skip_controller_spec.rb index cb9f22ff6..4f7d269a0 100644 --- a/spec/requests/pages/secondary_skip_controller_spec.rb +++ b/spec/requests/pages/secondary_skip_controller_spec.rb @@ -253,7 +253,7 @@ def build_pages def build_pages_with_skip_condition build_pages.tap do |pages| - pages[0] = build :page, :with_selections_settings, id: 1, routing_conditions: [ + pages[0] = build :page, :with_selection_settings, id: 1, routing_conditions: [ build(:condition, id: 1, routing_page_id: pages.first.id, check_page_id: pages.first.id, answer_value: "Option 1", goto_page_id: pages[2].id, skip_to_end: false), ] end diff --git a/spec/requests/pages/selection/bulk_options_controller_spec.rb b/spec/requests/pages/selection/bulk_options_controller_spec.rb index e70b89e29..cc63fecc8 100644 --- a/spec/requests/pages/selection/bulk_options_controller_spec.rb +++ b/spec/requests/pages/selection/bulk_options_controller_spec.rb @@ -113,7 +113,7 @@ end describe "#edit" do - let(:page) { build :page, :with_selections_settings, id: 2, form_id: form.id, answer_settings: } + let(:page) { build :page, :with_selection_settings, id: 2, form_id: form.id, answer_settings: } let(:answer_settings) { { selection_options: } } let(:selection_options) { [{ name: "Option 1" }, { name: "Option 2" }] } let(:page_id) { page.id } @@ -155,7 +155,7 @@ end describe "#update" do - let(:page) { build :page, :with_selections_settings, id: 2, form_id: form.id, answer_settings: } + let(:page) { build :page, :with_selection_settings, id: 2, form_id: form.id, answer_settings: } let(:answer_settings) { { only_one_option: "true", selection_options: } } let(:selection_options) { [{ name: "Option 1" }, { name: "Option 2" }] } diff --git a/spec/requests/pages/selection/options_controller_spec.rb b/spec/requests/pages/selection/options_controller_spec.rb index d1db126f8..ec7d7a1a3 100644 --- a/spec/requests/pages/selection/options_controller_spec.rb +++ b/spec/requests/pages/selection/options_controller_spec.rb @@ -131,7 +131,7 @@ end describe "#edit" do - let(:page) { build :page, :with_selections_settings, id: 2, form_id: form.id } + let(:page) { build :page, :with_selection_settings, id: 2, form_id: form.id } let(:page_id) { page.id } before do diff --git a/spec/requests/pages/selection/type_controller_spec.rb b/spec/requests/pages/selection/type_controller_spec.rb index 85a71ba0b..5ec41db97 100644 --- a/spec/requests/pages/selection/type_controller_spec.rb +++ b/spec/requests/pages/selection/type_controller_spec.rb @@ -105,7 +105,7 @@ end describe "#edit" do - let(:page) { build :page, :with_selections_settings, id: 2, form_id: form.id } + let(:page) { build :page, :with_selection_settings, id: 2, form_id: form.id } let(:page_id) { page.id } before do diff --git a/spec/services/page_summary_card_data_service_spec.rb b/spec/services/page_summary_card_data_service_spec.rb index 55ea341e8..e0f3d9510 100644 --- a/spec/services/page_summary_card_data_service_spec.rb +++ b/spec/services/page_summary_card_data_service_spec.rb @@ -23,7 +23,7 @@ end context "when the page is a selection question" do - let(:page) { build :page, :with_selections_settings, is_optional: } + let(:page) { build :page, :with_selection_settings, is_optional: } it "includes a title without (optional) added to it" do expect(service.build_data[:card][:title]).to eq page.question_text.to_s @@ -38,7 +38,7 @@ end context "when the page is a selection question" do - let(:page) { build :page, :with_selections_settings, is_optional: } + let(:page) { build :page, :with_selection_settings, is_optional: } it "includes a title without (optional) added to it" do expect(service.build_data[:card][:title]).to eq page.question_text.to_s @@ -54,7 +54,7 @@ end context "when the page is a selection question" do - let(:page) { build :page, :with_selections_settings, is_optional: } + let(:page) { build :page, :with_selection_settings, is_optional: } it "includes a title without (optional) added to it" do expect(service.build_data[:card][:title]).to eq page.question_text.to_s diff --git a/spec/views/pages/_forms.html.erb_spec.rb b/spec/views/pages/_forms.html.erb_spec.rb index 618541c16..2ee9bb38a 100644 --- a/spec/views/pages/_forms.html.erb_spec.rb +++ b/spec/views/pages/_forms.html.erb_spec.rb @@ -52,7 +52,7 @@ end context "when the question is an only one option selection" do - let(:page) { build :page, :with_selections_settings, id: 2, form_id: form.id } + let(:page) { build :page, :with_selection_settings, id: 2, form_id: form.id } it "does not have the radio input for repeatable" do expect(rendered).not_to have_field("pages_question_input[is_repeatable]", type: :radio) @@ -60,7 +60,7 @@ end context "when the question is an only more than one option selection" do - let(:page) { build :page, :with_selections_settings, only_one_option: false, id: 2, form_id: form.id } + let(:page) { build :page, :with_selection_settings, only_one_option: false, id: 2, form_id: form.id } it "does not have the radio input for repeatable" do expect(rendered).not_to have_field("pages_question_input[is_repeatable]", type: :radio) diff --git a/spec/views/pages/conditions/routing_page.html.erb_spec.rb b/spec/views/pages/conditions/routing_page.html.erb_spec.rb index f398e8233..5e1a49df6 100644 --- a/spec/views/pages/conditions/routing_page.html.erb_spec.rb +++ b/spec/views/pages/conditions/routing_page.html.erb_spec.rb @@ -2,7 +2,7 @@ describe "pages/conditions/routing_page.html.erb" do let(:form) { build :form, id: 1 } - let(:pages) { build_list :page, 3, :with_selections_settings, form_id: 1 } + let(:pages) { build_list :page, 3, :with_selection_settings, form_id: 1 } let(:routing_page_input) { Pages::RoutingPageInput.new } let(:allowed_to_create_routes) { true } let(:all_routes_created) { false } @@ -53,7 +53,7 @@ end context "with 10 options" do - let(:pages) { build_list :page, 10, :with_selections_settings, form_id: 1 } + let(:pages) { build_list :page, 10, :with_selection_settings, form_id: 1 } it "contains a fieldset legend asking a user to select a question page" do expect(rendered).to have_css(".govuk-fieldset__legend", text: t("routing_page.legend_text")) @@ -68,7 +68,7 @@ end context "with more than 10 options" do - let(:pages) { build_list :page, 11, :with_selections_settings, form_id: 1 } + let(:pages) { build_list :page, 11, :with_selection_settings, form_id: 1 } it "contains a fieldset legend asking a user to select a question page" do expect(rendered).to have_css(".govuk-label", text: t("routing_page.legend_text")) diff --git a/spec/views/pages/secondary_skip/new.html.erb_spec.rb b/spec/views/pages/secondary_skip/new.html.erb_spec.rb index cbbffea8a..5fab99ca1 100644 --- a/spec/views/pages/secondary_skip/new.html.erb_spec.rb +++ b/spec/views/pages/secondary_skip/new.html.erb_spec.rb @@ -4,7 +4,7 @@ let(:form) { build :form, id: 1, pages: [page] } let(:page) do build(:page, - :with_selections_settings, + :with_selection_settings, id: 1, position: 1, answer_settings: DataStruct.new(