Browse Source

Do not show invalid emails

pull/1766/head
Jack S 3 years ago
parent
commit
38edde5f84
  1. 4
      app/helpers/data_sharing_agreement_helper.rb
  2. 44
      spec/views/organisations/data_sharing_agreement.html.erb_spec.rb

4
app/helpers/data_sharing_agreement_helper.rb

@ -61,8 +61,12 @@ module DataSharingAgreementHelper
end end
end end
if data_protection_confirmation&.confirmed? && @dpo_email.exclude?("@") # Do not show invalid email addresses
"12.2. For #{@org_name}: Name: #{@dpo_name}, Postal Address: #{@org_address}, Telephone number: #{@org_phone}"
else
"12.2. For #{@org_name}: Name: #{@dpo_name}, Postal Address: #{@org_address}, E-mail address: #{@dpo_email}, Telephone number: #{@org_phone}" "12.2. For #{@org_name}: Name: #{@dpo_name}, Postal Address: #{@org_address}, E-mail address: #{@dpo_email}, Telephone number: #{@org_phone}"
end end
end
# rubocop:enable Rails/HelperInstanceVariable # rubocop:enable Rails/HelperInstanceVariable
private private

44
spec/views/organisations/data_sharing_agreement.html.erb_spec.rb

@ -65,6 +65,50 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failu
# Shows DPO and org details in 12.2 # Shows DPO and org details in 12.2
expect(fragment).to have_content("12.2. For #{organisation.name}: Name: #{dpo.name}, Postal Address: #{organisation.address_row}, E-mail address: #{dpo.email}, Telephone number: #{organisation.phone}") expect(fragment).to have_content("12.2. For #{organisation.name}: Name: #{dpo.name}, Postal Address: #{organisation.address_row}, E-mail address: #{dpo.email}, Telephone number: #{organisation.phone}")
end end
context "when user email not valid" do
let(:dpo) do
u = User.new(
name: "test",
organisation:,
is_dpo: true,
encrypted_password: SecureRandom.hex(10),
email: SecureRandom.uuid,
confirmed_at: Time.zone.now,
active: false,
)
u.save!(validate: false)
u
end
let(:data_protection_confirmation) do
create(
:data_protection_confirmation,
organisation:,
created_at: Time.zone.now - 1.day,
data_protection_officer: dpo,
)
end
it "renders dynamic content" do
render
# dpo name
expect(fragment).to have_content("Name: #{dpo.name}")
# org details
expect(fragment).to have_content("#{organisation.name} of #{organisation.address_row} (“CORE Data Provider”)")
# header
expect(fragment).to have_css("h2", text: "#{organisation.name} and Department for Levelling Up, Housing and Communities")
# does not show action buttons
expect(fragment).not_to have_button(text: "Accept this agreement")
expect(fragment).not_to have_link(text: "Cancel", href: "/organisations/#{organisation.id}/details")
# sees signed_at date
expect(fragment).to have_content("9th day of January 2023")
# Shows DPO and org details in 12.2
expect(fragment).to have_content("12.2. For #{organisation.name}: Name: #{dpo.name}, Postal Address: #{organisation.address_row}, Telephone number: #{organisation.phone}")
end
end
end end
end end

Loading…
Cancel
Save