From e2b47d4b24df8b0d7ac09fe2e6fd6c9e7bd600be Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 29 Nov 2022 14:03:47 +0000 Subject: [PATCH] do not allow the aswers from previous collection windows to be changed --- ...heck_answers_summary_list_card_component.html.erb | 12 +++++++----- app/views/form/_check_answers_summary_list.html.erb | 12 +++++++----- spec/requests/lettings_logs_controller_spec.rb | 11 +++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index f299674b2..cc13532b8 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -25,11 +25,13 @@ <%= inferred_answer %> <% end %> <% end %> - <% row.action( - text: question.action_text(log), - href: question.action_href(log, question.page.id), - visually_hidden_text: question.check_answer_label.to_s.downcase, - ) %> + <% if @log.form.end_date > Time.zone.today %> + <% row.action( + text: question.action_text(log), + href: question.action_href(log, question.page.id), + visually_hidden_text: question.check_answer_label.to_s.downcase, + ) %> + <% end %> <% end %> <% end %> <% end %> diff --git a/app/views/form/_check_answers_summary_list.html.erb b/app/views/form/_check_answers_summary_list.html.erb index 68a9cf00a..a03569084 100644 --- a/app/views/form/_check_answers_summary_list.html.erb +++ b/app/views/form/_check_answers_summary_list.html.erb @@ -13,11 +13,13 @@ <%= inferred_answer %> <% end %> <% end %> - <% row.action( - text: question.action_text(@log), - href: question.action_href(@log, question.page.id), - visually_hidden_text: question.check_answer_label.to_s.downcase, - ) %> + <% if @log.form.end_date > Time.zone.today %> + <% row.action( + text: question.action_text(@log), + href: question.action_href(@log, question.page.id), + visually_hidden_text: question.check_answer_label.to_s.downcase, + ) %> + <% end %> <% end %> <% end %> <% end %> diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 6be967721..2a79254fc 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -738,6 +738,7 @@ RSpec.describe LettingsLogsController, type: :request do postcode_known: "No") end let(:id) { postcode_lettings_log.id } + let(:completed_lettings_log) { FactoryBot.create(:lettings_log, :completed, owning_organisation: user.organisation, managing_organisation: user.organisation, created_by: user, startdate: Time.zone.local(2021, 4, 1)) } before do stub_request(:get, /api.postcodes.io/) @@ -771,6 +772,16 @@ RSpec.describe LettingsLogsController, type: :request do get "/lettings-logs/#{id}/income-and-benefits/check-answers" expect(CGI.unescape_html(response.body)).to include("You didn’t answer this question") end + + it "does not allow you to change the answers for previous collection year logs" do + get "/lettings-logs/#{completed_lettings_log.id}/setup/check-answers", headers: { "Accept" => "text/html" }, params: {} + expect(page).not_to have_link("Change") + expect(page).not_to have_link("Answer") + + get "/lettings-logs/#{completed_lettings_log.id}/income-and-benefits/check-answers", headers: { "Accept" => "text/html" }, params: {} + expect(page).not_to have_link("Change") + expect(page).not_to have_link("Answer") + end end context "when requesting CSV download" do