Browse Source

Merge a4a6f5cd72 into 21b1691831

pull/3143/merge
Samuel Young 5 days ago committed by GitHub
parent
commit
2baf5ab37b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 38
      app/components/data_protection_confirmation_banner_component.rb
  2. 29
      spec/components/data_protection_confirmation_banner_component_spec.rb

38
app/components/data_protection_confirmation_banner_component.rb

@ -12,16 +12,16 @@ class DataProtectionConfirmationBannerComponent < ViewComponent::Base
def display_banner? def display_banner?
return false if user.support? && organisation.blank? return false if user.support? && organisation.blank?
return true if org_without_dpo? return true if show_no_dpo_message?
return false if !org_or_user_org.holds_own_stock? && org_or_user_org.stock_owners.empty? && org_or_user_org.absorbed_organisations.empty? return false if !org_or_user_org.holds_own_stock? && org_or_user_org.stock_owners.empty? && org_or_user_org.absorbed_organisations.empty?
!org_or_user_org.data_protection_confirmed? || !org_or_user_org.organisation_or_stock_owner_signed_dsa_and_holds_own_stock? !dsa_signed? || !org_or_user_org.organisation_or_stock_owner_signed_dsa_and_holds_own_stock?
end end
def header_text def header_text
if org_without_dpo? if show_no_dpo_message?
"To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement." "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement."
elsif !org_or_user_org.holds_own_stock? && org_or_user_org.data_protection_confirmed? elsif show_no_stock_owner_message?
"Your organisation does not own stock. To create logs your stock owner(s) must accept the Data Sharing Agreement on CORE." "Your organisation does not own stock. To create logs your stock owner(s) must accept the Data Sharing Agreement on CORE."
elsif user.is_dpo? elsif user.is_dpo?
"Your organisation must accept the Data Sharing Agreement before you can create any logs." "Your organisation must accept the Data Sharing Agreement before you can create any logs."
@ -31,7 +31,7 @@ class DataProtectionConfirmationBannerComponent < ViewComponent::Base
end end
def banner_text def banner_text
if org_without_dpo? || user.is_dpo? || !org_or_user_org.holds_own_stock? if show_no_dpo_message? || user.is_dpo? || !org_or_user_org.holds_own_stock?
govuk_link_to( govuk_link_to(
link_text, link_text,
link_href, link_href,
@ -51,9 +51,9 @@ private
end end
def link_text def link_text
if dpo_required? if show_no_dpo_message?
"Contact helpdesk to assign a data protection officer" "Contact helpdesk to assign a data protection officer"
elsif !org_or_user_org.holds_own_stock? && org_or_user_org.data_protection_confirmed? elsif show_no_stock_owner_message?
"View or add stock owners" "View or add stock owners"
else else
"Read the Data Sharing Agreement" "Read the Data Sharing Agreement"
@ -61,24 +61,32 @@ private
end end
def link_href def link_href
if dpo_required? if show_no_dpo_message?
GlobalConstants::HELPDESK_URL GlobalConstants::HELPDESK_URL
elsif !org_or_user_org.holds_own_stock? && org_or_user_org.data_protection_confirmed? elsif show_no_stock_owner_message?
stock_owners_organisation_path(org_or_user_org) stock_owners_organisation_path(org_or_user_org)
else else
data_sharing_agreement_organisation_path(org_or_user_org) data_sharing_agreement_organisation_path(org_or_user_org)
end end
end end
def dpo_required? def show_no_dpo_message?
org_or_user_org.data_protection_officers.empty? # it is fine if an org has a DSA and the DPO has moved on
# CORE staff do this sometimes as a single DPO covers multiple 'orgs' that exist as branches of the same real world org
# so, they move the DPO to all the mini orgs and have the sign each DSA
# so the DSA being signed can silence this warning
org_or_user_org.data_protection_officers.empty? && !dsa_signed?
end end
def org_or_user_org def dsa_signed?
organisation.presence || user.organisation org_or_user_org.data_protection_confirmed?
end
def show_no_stock_owner_message?
!org_or_user_org.holds_own_stock? && dsa_signed?
end end
def org_without_dpo? def org_or_user_org
org_or_user_org.data_protection_officers.empty? organisation.presence || user.organisation
end end
end end

29
spec/components/data_protection_confirmation_banner_component_spec.rb

@ -23,13 +23,18 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
organisation.users.where(is_dpo: true).destroy_all organisation.users.where(is_dpo: true).destroy_all
end end
it "displays the banner" do context "when org does not have a signed data sharing agreement" do
expect(component.display_banner?).to eq(true) let(:organisation) { create(:organisation, :without_dpc) }
expect(render).to have_link( let(:user) { create(:user, organisation:, with_dsa: false) }
"Contact helpdesk to assign a data protection officer",
href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11", it "displays the banner" do
) expect(component.display_banner?).to eq(true)
expect(render).to have_selector("p", text: "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement.") expect(render).to have_link(
"Contact helpdesk to assign a data protection officer",
href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11",
)
expect(render).to have_selector("p", text: "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement.")
end
end end
end end
@ -127,13 +132,9 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
organisation.users.where(is_dpo: true).destroy_all organisation.users.where(is_dpo: true).destroy_all
end end
it "displays the banner" do it "doesn't display the banner" do
expect(component.display_banner?).to eq(true) expect(component.display_banner?).to eq(false)
expect(render).to have_link( expect(render.content).to be_empty
"Contact helpdesk to assign a data protection officer",
href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11",
)
expect(render).to have_selector("p", text: "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement.")
end end
end end

Loading…
Cancel
Save