Skip to content

Commit

Permalink
Remove unnecessary plural in 'with_selections_settings` trait
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBiddle committed Nov 27, 2024
1 parent 9c5f7c1 commit 2fdd7f8
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion spec/factories/models/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/models/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" }] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] }

Expand Down
8 changes: 4 additions & 4 deletions spec/models/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/policies/form_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@

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

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
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/pages/secondary_skip_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/pages/selection/bulk_options_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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" }] }

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/pages/selection/options_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/pages/selection/type_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/services/page_summary_card_data_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/views/pages/_forms.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
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)
end
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)
Expand Down
6 changes: 3 additions & 3 deletions spec/views/pages/conditions/routing_page.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion spec/views/pages/secondary_skip/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2fdd7f8

Please sign in to comment.