- [Data provider organisation] and Department for Levelling Up, Housing and Communities
+ <%= org_name_for_data_sharing_agreement(@data_sharing_agreement, current_user) %> and Department for Levelling Up, Housing and Communities
<% if @data_sharing_agreement %>
@@ -15,7 +15,11 @@
<% end %>
between
-
1) [core data provider organisation] of [full address] (“CORE Data Provider”)
+ <% if @data_sharing_agreement %>
+
1) <%= @data_sharing_agreement.organisation_name %> of <%= @data_sharing_agreement.organisation_address %> (“CORE Data Provider”)
+ <% else %>
+
1) [Data provider organisation] of [full address] (“CORE Data Provider”)
+ <% end %>
and
2) The Department for Levelling Up, Housing and Communities of 2 Marsham Street, London, SW1P 4DF (“DLUHC”)
1. Background
@@ -101,8 +105,11 @@
11.2. CORE data providers and DLUHC acknowledge that any loss or unauthorised release of the Data can be treated as valid grounds for immediately terminating this agreement by DLUHC.
12. Authorised representatives
12.1. CORE data providers and DLUHC will each appoint an Authorised Representative to be the primary point of contact in all day-to-day matters relating to this Agreement:
-
12.2. For [the Data Provider]: Name:
- Postal Address: E-mail address: Telephone number:
+ <% if @data_sharing_agreement %>
+
12.2. For <%= @data_sharing_agreement.organisation_name %>: Name: <%= @data_sharing_agreement.dpo_name %>, Postal Address: <%= @data_sharing_agreement.organisation_address %>, E-mail address: <%= @data_sharing_agreement.dpo_email %>, Telephone number: <%= @data_sharing_agreement.organisation_phone_number %>
+ <% else %>
+
12.2. For [Organisation name]: Name: [DPO name], Postal Address: [Organisation address], E-mail address: [DPO email], Telephone number: [Organisation telephone number]
+ <% end %>
12.3. For DLUHC: Name: Rachel Worledge
Postal Address: South-west section, 4th Floor, Fry Building, 2 Marsham Street, London, SW1P 4DF
E-mail address: Rachel.Worledge@levellingup.gov.uk
@@ -118,7 +125,7 @@
16. Statutory compliance
16.1. The Parties shall comply with all relevant legislation, regulations, orders, statutory instruments and any amendments or re-enactments thereof from the commencement of this agreement.
As witness of which the parties have set their hands on the day and year first above written
- signed for and on behalf of [job title of an officer with appropriate delegated authority] for [core data provider name], by:
+ signed for and on behalf of [job title of an officer with appropriate delegated authority] for <%= org_name_for_data_sharing_agreement(@data_sharing_agreement, current_user) %>, by:
- Name: <%= name_for_data_sharing_agreement(@data_sharing_agreement, current_user) %>
- Title: Data Protection Officer
diff --git a/db/migrate/20230530094653_add_data_sharing_agreement.rb b/db/migrate/20230530094653_add_data_sharing_agreement.rb
index b3f79c04d..a148b32cc 100644
--- a/db/migrate/20230530094653_add_data_sharing_agreement.rb
+++ b/db/migrate/20230530094653_add_data_sharing_agreement.rb
@@ -5,6 +5,11 @@ class AddDataSharingAgreement < ActiveRecord::Migration[7.0]
t.belongs_to :data_protection_officer, class_name: "User"
t.datetime :signed_at, null: false
+ t.string :organisation_name, null: false
+ t.string :organisation_address, null: false
+ t.string :organisation_phone_number
+ t.string :dpo_email, null: false
+ t.string :dpo_name, null: false
t.timestamps
end
diff --git a/db/schema.rb b/db/schema.rb
index 9a63c06d3..d01fa5935 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -60,6 +60,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_30_094653) do
t.bigint "organisation_id"
t.bigint "data_protection_officer_id"
t.datetime "signed_at", null: false
+ t.string "organisation_name", null: false
+ t.string "organisation_address", null: false
+ t.string "organisation_phone_number"
+ t.string "dpo_email", null: false
+ t.string "dpo_name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["data_protection_officer_id"], name: "index_data_sharing_agreements_on_data_protection_officer_id"
diff --git a/spec/factories/data_sharing_agreement.rb b/spec/factories/data_sharing_agreement.rb
new file mode 100644
index 000000000..11e9eef02
--- /dev/null
+++ b/spec/factories/data_sharing_agreement.rb
@@ -0,0 +1,15 @@
+FactoryBot.define do
+ factory :data_sharing_agreement do
+ organisation
+ data_protection_officer { create(:user, is_dpo: true) }
+ signed_at { Time.zone.now }
+ created_at { Time.zone.now }
+ updated_at { Time.zone.now }
+
+ dpo_name { data_protection_officer.name }
+ dpo_email { data_protection_officer.email }
+ organisation_address { organisation.address_string }
+ organisation_phone_number { organisation.phone }
+ organisation_name { organisation.name }
+ end
+end
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 374503106..7281bcbd1 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -1518,13 +1518,24 @@ RSpec.describe OrganisationsController, type: :request do
expect(flash[:notification_banner_body]).to eq("Your organisation can now submit logs.")
end
+ it "creates a data sharing agreement" do
+ expect(organisation.reload.data_sharing_agreement).to be_nil
+
+ post("/organisations/#{organisation.id}/data-sharing-agreement", headers:)
+
+ data_sharing_agreement = organisation.reload.data_sharing_agreement
+
+ expect(data_sharing_agreement.organisation_address).to eq(organisation.address_string)
+ expect(data_sharing_agreement.organisation_name).to eq(organisation.name)
+ expect(data_sharing_agreement.organisation_phone_number).to eq(organisation.phone)
+ expect(data_sharing_agreement.data_protection_officer).to eq(user)
+ expect(data_sharing_agreement.dpo_name).to eq(user.name)
+ expect(data_sharing_agreement.dpo_email).to eq(user.email)
+ end
+
context "when the user has already accepted the agreement" do
before do
- DataSharingAgreement.create!(
- organisation: user.organisation,
- signed_at: Time.zone.now - 1.day,
- data_protection_officer: user,
- )
+ create(:data_sharing_agreement, data_protection_officer: user, organisation: user.organisation)
end
it "returns not found" do
diff --git a/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb b/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb
index 779a51325..67f094c26 100644
--- a/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb
+++ b/spec/views/organisations/data_sharing_agreement.html.erb_spec.rb
@@ -1,6 +1,6 @@
require "rails_helper"
-RSpec.describe "organisations/data_sharing_agreement.html.erb" do
+RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failures do
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
allow(view).to receive(:current_user).and_return(user)
@@ -19,46 +19,50 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb" do
context "when dpo" do
let(:user) { create(:user, is_dpo: true) }
- it "shows current date" do
+ it "renders dynamic content" do
render
+ # current date
expect(fragment).to have_content("10th day of January 2023")
- end
-
- it "shows dpo name" do
- render
+ # dpo name
expect(fragment).to have_content("Name: #{user.name}")
- end
-
- it "shows action buttons" do
- render
+ # org details
+ expect(fragment).to have_content("[Data provider organisation] of [full address] (“CORE Data Provider”)")
+ # header
+ expect(fragment).to have_css("h2", text: "#{user.organisation.name} and Department for Levelling Up, Housing and Communities")
+ # action buttons
expect(fragment).to have_button(text: "Accept this agreement")
expect(fragment).to have_link(text: "Cancel", href: "/organisations/#{organisation.id}/details")
+
+ # Shows placeholder details in 12.2
+ expect(fragment).to have_content("12.2. For [Organisation name]: Name: [DPO name], Postal Address: [Organisation address], E-mail address: [DPO email], Telephone number: [Organisation telephone number]")
end
context "when accepted" do
let(:data_sharing_agreement) do
- DataSharingAgreement.create!(
+ create(
+ :data_sharing_agreement,
organisation:,
signed_at: Time.zone.now - 1.day,
- data_protection_officer: user,
)
end
- it "does not show action buttons" do
+ it "renders dynamic content" do
render
+ # dpo name
+ expect(fragment).to have_content("Name: #{data_sharing_agreement.dpo_name}")
+
+ # org details
+ expect(fragment).to have_content("#{data_sharing_agreement.organisation_name} of #{data_sharing_agreement.organisation_address} (“CORE Data Provider”)")
+ # header
+ expect(fragment).to have_css("h2", text: "#{data_sharing_agreement.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")
- end
-
- it "sees signed_at date" do
- render
+ # sees signed_at date
expect(fragment).to have_content("9th day of January 2023")
- end
-
- it "shows dpo name" do
- render
- expect(fragment).to have_content("Name: #{user.name}")
+ # Shows filled in details in 12.2
+ expect(fragment).to have_content("12.2. For #{data_sharing_agreement.organisation_name}: Name: #{data_sharing_agreement.dpo_name}, Postal Address: #{data_sharing_agreement.organisation_address}, E-mail address: #{data_sharing_agreement.dpo_email}, Telephone number: #{data_sharing_agreement.organisation_phone_number}")
end
end
end
@@ -66,45 +70,47 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb" do
context "when not dpo" do
let(:user) { create(:user) }
- it "shows DPO placeholder" do
- render
- expect(fragment).to have_content("Name: [DPO name]")
- end
-
- it "shows placeholder date" do
+ it "renders dynamic content" do
render
+ # placeholder date
expect(fragment).to have_content("This agreement is made the [XX] day of [XX] 20[XX]")
- end
-
- it "does not show action buttons" do
- render
+ # dpo name placedholder
+ expect(fragment).to have_content("Name: [DPO name]")
+ # org details
+ expect(fragment).to have_content("[Data provider organisation] of [full address] (“CORE Data Provider”)")
+ # header
+ expect(fragment).to have_css("h2", text: "[Data provider organisation] 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")
+ # Shows placeholder details in 12.2
+ expect(fragment).to have_content("12.2. For [Organisation name]: Name: [DPO name], Postal Address: [Organisation address], E-mail address: [DPO email], Telephone number: [Organisation telephone number]")
end
context "when accepted" do
let(:data_sharing_agreement) do
- DataSharingAgreement.create!(
+ create(
+ :data_sharing_agreement,
organisation:,
signed_at: Time.zone.now - 1.day,
- data_protection_officer: user,
)
end
- it "does not show action buttons" do
+ it "renders dynamic content" do
render
+ # sees signed_at date
+ expect(fragment).to have_content("9th day of January 2023")
+ # dpo name placedholder
+ expect(fragment).to have_content("Name: #{data_sharing_agreement.dpo_name}")
+ # org details
+ expect(fragment).to have_content("#{data_sharing_agreement.organisation_name} of #{data_sharing_agreement.organisation_address} (“CORE Data Provider”)")
+ # header
+ expect(fragment).to have_css("h2", text: "#{data_sharing_agreement.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")
- end
-
- it "sees signed_at date" do
- render
- expect(fragment).to have_content("9th day of January 2023")
- end
-
- it "shows dpo name" do
- render
- expect(fragment).to have_content("Name: #{user.name}")
+ # Shows filled in details in 12.2
+ expect(fragment).to have_content("12.2. For #{data_sharing_agreement.organisation_name}: Name: #{data_sharing_agreement.dpo_name}, Postal Address: #{data_sharing_agreement.organisation_address}, E-mail address: #{data_sharing_agreement.dpo_email}, Telephone number: #{data_sharing_agreement.organisation_phone_number}")
end
end
end
diff --git a/spec/views/organisations/show.html.erb_spec.rb b/spec/views/organisations/show.html.erb_spec.rb
index 762b7786a..ea392d76d 100644
--- a/spec/views/organisations/show.html.erb_spec.rb
+++ b/spec/views/organisations/show.html.erb_spec.rb
@@ -52,13 +52,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when accepted" do
- let(:data_sharing_agreement) do
- DataSharingAgreement.create!(
- organisation:,
- signed_at: Time.zone.now - 1.day,
- data_protection_officer: user,
- )
- end
+ let(:data_sharing_agreement) { create(:data_sharing_agreement, organisation:, signed_at: Time.zone.now - 1.day) }
it "includes data sharing agreement row" do
render
@@ -108,14 +102,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when accepted" do
- let(:dpo) { create(:user, is_dpo: true) }
- let(:data_sharing_agreement) do
- DataSharingAgreement.create!(
- organisation:,
- signed_at: Time.zone.now - 1.day,
- data_protection_officer: dpo,
- )
- end
+ let(:data_sharing_agreement) { create(:data_sharing_agreement, organisation:, signed_at: Time.zone.now - 1.day) }
it "includes data sharing agreement row" do
render
@@ -132,7 +119,7 @@ RSpec.describe "organisations/show.html.erb" do
it "shows show name of who signed the agreement" do
render
- expect(fragment).to have_content(dpo.name)
+ expect(fragment).to have_content(data_sharing_agreement.dpo_name)
end
it "shows link to view data sharing agreement" do
@@ -169,11 +156,7 @@ RSpec.describe "organisations/show.html.erb" do
context "when accepted" do
let(:data_sharing_agreement) do
- DataSharingAgreement.create!(
- organisation:,
- signed_at: Time.zone.now - 1.day,
- data_protection_officer: user,
- )
+ create(:data_sharing_agreement, organisation:, signed_at: Time.zone.now - 1.day)
end
it "includes data sharing agreement row" do