From ae0b375580628cb569f3fbee56e813c94cc56e1c Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 5 Dec 2022 18:35:11 +0000 Subject: [PATCH] Only hide created_by question for non support users (#1045) --- .../form/lettings/questions/created_by_id.rb | 4 ++-- spec/features/lettings_log_spec.rb | 2 +- .../lettings/questions/created_by_id_spec.rb | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/models/form/lettings/questions/created_by_id.rb b/app/models/form/lettings/questions/created_by_id.rb index d5921e935..a120e72a8 100644 --- a/app/models/form/lettings/questions/created_by_id.rb +++ b/app/models/form/lettings/questions/created_by_id.rb @@ -35,8 +35,8 @@ class Form::Lettings::Questions::CreatedById < ::Form::Question answer_options[value] end - def hidden_in_check_answers?(_log, _current_user) - true + def hidden_in_check_answers?(_log, current_user) + !current_user.support? end def derived? diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index 6d09b205a..066126ac7 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -89,7 +89,7 @@ RSpec.describe "Lettings Log Features" do log_id = page.current_path.scan(/\d/).join visit("lettings-logs/#{log_id}/setup/check-answers") expect(page).to have_content("Housing provider #{support_user.organisation.name}") - expect(page).to have_content("You have answered 2 of 8 questions") + expect(page).to have_content("You have answered 3 of 9 questions") end end end diff --git a/spec/models/form/lettings/questions/created_by_id_spec.rb b/spec/models/form/lettings/questions/created_by_id_spec.rb index a5e60ad2b..84ee4156a 100644 --- a/spec/models/form/lettings/questions/created_by_id_spec.rb +++ b/spec/models/form/lettings/questions/created_by_id_spec.rb @@ -51,8 +51,20 @@ RSpec.describe Form::Lettings::Questions::CreatedById, type: :model do expect(question.derived?).to be true end - it "is not shown in check answers" do - expect(question.hidden_in_check_answers?(nil, user_1)).to be true + context "when the current user is support" do + let(:support_user) { FactoryBot.build(:user, :support) } + + it "is shown in check answers" do + expect(question.hidden_in_check_answers?(nil, support_user)).to be false + end + end + + context "when the current user is not support" do + let(:user) { FactoryBot.build(:user) } + + it "is not shown in check answers" do + expect(question.hidden_in_check_answers?(nil, user)).to be true + end end context "when the owning organisation is already set" do