From 6205a2e006470042a412d092bc9b30ba0b9fcf7a Mon Sep 17 00:00:00 2001 From: Aaron Spencer Date: Mon, 25 Sep 2023 17:52:12 +0100 Subject: [PATCH] CLDC-2672: WIP --- app/views/form/page.html.erb | 17 +++++++++++------ spec/features/lettings_log_spec.rb | 4 ++-- spec/features/sales_log_spec.rb | 6 +++--- spec/models/form/page_spec.rb | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index b5ce2ead7..b28d240a3 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -64,13 +64,18 @@
<% if !@page.interruption_screen? && if request.query_parameters["referrer"] != "check_answers" %> - <%= f.govuk_submit "Save and continue" %> - <%= govuk_link_to( - (@page.skip_text || "Skip for now"), - (@page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user), @log)), - ) %> + <% if request.query_parameters["referrer"] == "duplicate_logs" %> + <%= f.govuk_submit "Save changes" %> + <%= govuk_link_to("Cancel", lettings_log_duplicate_logs_path(request.query_parameters["original_log_id"], original_log_id: request.query_parameters["original_log_id"]))%> <% else %> - <%= f.govuk_submit "Save changes" %> + <%= f.govuk_submit "Save and continue" %> + <%= govuk_link_to( + (@page.skip_text || "Skip for now"), + (@page.skip_href(@log) || send(@log.form.next_page_redirect_path(@page, @log, current_user), @log)), + ) %> + <% end %> + <% else %> + <%= f.govuk_submit "Save changes" %> <%= govuk_link_to "Cancel", send(@log.form.cancel_path(@page, @log), @log) %> <% end %> <% end %> diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index 9f8cfbb77..123156d74 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -510,7 +510,7 @@ RSpec.describe "Lettings Log Features" do expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}") click_link("Change", href: "/lettings-logs/#{duplicate_log.id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs") fill_in("lettings-log-tenancycode-field", with: "something else") - click_button("Save and continue") + click_button("Save changes") expect(page).to have_current_path("/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}") expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") @@ -521,7 +521,7 @@ RSpec.describe "Lettings Log Features" do it "allows deduplicating logs by changing the answers on the original log" do click_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?first_remaining_duplicate_id=#{duplicate_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs") fill_in("lettings-log-tenancycode-field", with: "something else") - click_button("Save and continue") + click_button("Save changes") expect(page).to have_current_path("/lettings-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}") expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb index f03287723..e5597077d 100644 --- a/spec/features/sales_log_spec.rb +++ b/spec/features/sales_log_spec.rb @@ -34,7 +34,7 @@ RSpec.describe "Sales Log Features" do it "includes the purchaser code and sale completion date questions" do click_button "Create a new sales log" click_link "Set up this sales log" - fill_in("sales_log[saledate(1i)]", with: Time.zone.today.year) + fill_in("sales_log[saledate(i)]", with: Time.zone.today.year) fill_in("sales_log[saledate(2i)]", with: Time.zone.today.month) fill_in("sales_log[saledate(3i)]", with: Time.zone.today.day) click_button "Save and continue" @@ -249,7 +249,7 @@ RSpec.describe "Sales Log Features" do expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") click_link("Change", href: "/sales-logs/#{duplicate_log.id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs") fill_in("sales-log-purchid-field", with: "something else") - click_button("Save and continue") + click_button("Save changes") expect(page).to have_current_path("/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") @@ -260,7 +260,7 @@ RSpec.describe "Sales Log Features" do it "allows deduplicating logs by changing the answers on the original log" do click_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs") fill_in("sales-log-purchid-field", with: "something else") - click_button("Save and continue") + click_button("Save changes") expect(page).to have_current_path("/sales-logs/#{duplicate_log.id}/duplicate-logs?original_log_id=#{sales_log.id}") expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") diff --git a/spec/models/form/page_spec.rb b/spec/models/form/page_spec.rb index 17bd7dcc9..579afd0da 100644 --- a/spec/models/form/page_spec.rb +++ b/spec/models/form/page_spec.rb @@ -1,3 +1,4 @@ + require "rails_helper" RSpec.describe Form::Page, type: :model do