Skip to content

Commit 4aa1b04

Browse files
committed
Update default route text for next page
1 parent 9f35489 commit 4aa1b04

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

app/services/routes/build_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def options_for_goto_page(page, selected = nil)
4545
if drop
4646
if value == next_page_id
4747
drop = false
48-
["Go to question #{page.position.next}", Forms::RouteInput::DEFAULT_VALUE]
48+
["#{page.position.next}. #{next_page.question_text}", Forms::RouteInput::DEFAULT_VALUE]
4949
elsif selected && value == selected
5050
option
5151
end

spec/services/routes/build_service_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@
242242
options = service.options_for_goto_page(pages.first)
243243
default_option = options.find { |opt| opt[1] == Forms::RouteInput::DEFAULT_VALUE }
244244

245-
expect(default_option).to eq(["Go to question 2", Forms::RouteInput::DEFAULT_VALUE])
245+
expect(default_option).to eq(["2. #{pages.second.question_text}", Forms::RouteInput::DEFAULT_VALUE])
246246
end
247247

248248
it "does not include the current page in the options" do
@@ -256,7 +256,7 @@
256256
options = service.options_for_goto_page(pages.second)
257257

258258
expect(options).to eq [
259-
["Go to question 3", Forms::RouteInput::DEFAULT_VALUE],
259+
["3. #{pages.third.question_text}", Forms::RouteInput::DEFAULT_VALUE],
260260
["End of the form", "end_of_form"],
261261
]
262262
end
@@ -267,7 +267,7 @@
267267

268268
expect(options).to eq [
269269
["1. #{pages.first.question_text}", pages.first.id],
270-
["Go to question 3", Forms::RouteInput::DEFAULT_VALUE],
270+
["3. #{pages.third.question_text}", Forms::RouteInput::DEFAULT_VALUE],
271271
["End of the form", "end_of_form"],
272272
]
273273
end

spec/views/routes/show.html.erb_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ def select_options(select_field)
8181

8282
expect(rendered).to have_selector('.govuk-select[name="forms_routes_input[routes_attributes][0][goto]"]') do |field|
8383
expect(select_options(field)).to eq [
84-
["default", "Go to question 2"],
84+
["default", "2. #{pages.second.question_text}"],
8585
["103", "3. #{pages.third.question_text}"],
8686
["end_of_form", "End of the form"],
8787
]
8888
end
8989

9090
expect(rendered).to have_selector('.govuk-select[name="forms_routes_input[routes_attributes][1][goto]"]') do |field|
9191
expect(select_options(field)).to eq [
92-
["default", "Go to question 3"],
92+
["default", "3. #{pages.third.question_text}"],
9393
["end_of_form", "End of the form"],
9494
]
9595
end

0 commit comments

Comments
 (0)