From b550757d400659ca4d4dfc30b7499d0b7b72e686 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 15 Jul 2024 15:05:27 +0100 Subject: [PATCH] Display correct orgs data protection confirmation --- app/controllers/organisations_controller.rb | 2 +- .../requests/organisations_controller_spec.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 138baa78c..dfe50fa22 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -238,7 +238,7 @@ class OrganisationsController < ApplicationController end def data_sharing_agreement - @data_protection_confirmation = current_user.organisation.data_protection_confirmation + @data_protection_confirmation = @organisation.data_protection_confirmation end def confirm_data_sharing_agreement diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index e6fb20ac7..702f69a63 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -2099,6 +2099,26 @@ RSpec.describe OrganisationsController, type: :request do expect(response).to have_http_status(:ok) end end + + context "when signed in as support" do + let(:support_user) { create(:user, :support, with_dsa: false) } + + before do + organisation.data_protection_confirmation.update!(signed_at: Time.zone.local(2001, 3, 2), organisation_name: "Org name") + allow(support_user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in support_user + end + + context "and viewing other org dsa" do + it "shows correct org data and dates" do + get "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers + expect(response).to have_http_status(:ok) + expect(page).to have_content("This agreement is made the 2nd day of March 2001") + # binding.pry + expect(page).to have_content("1) Org name") + end + end + end end describe "POST #data_sharing_agreement" do