diff --git a/app/components/create_log_actions_component.rb b/app/components/create_log_actions_component.rb
index 55795c94a..c61a85b80 100644
--- a/app/components/create_log_actions_component.rb
+++ b/app/components/create_log_actions_component.rb
@@ -13,7 +13,6 @@ class CreateLogActionsComponent < ViewComponent::Base
def display_actions?
return false if bulk_upload.present?
- return true unless FeatureToggle.new_data_protection_confirmation?
return true if user.support?
user.organisation.data_protection_confirmed?
diff --git a/app/components/data_protection_confirmation_banner_component.rb b/app/components/data_protection_confirmation_banner_component.rb
index ed5fd1310..5757ad87f 100644
--- a/app/components/data_protection_confirmation_banner_component.rb
+++ b/app/components/data_protection_confirmation_banner_component.rb
@@ -13,7 +13,6 @@ class DataProtectionConfirmationBannerComponent < ViewComponent::Base
end
def display_banner?
- return false unless FeatureToggle.new_data_protection_confirmation?
return false if user.support? && organisation.blank?
return true if org_without_dpo?
diff --git a/app/controllers/bulk_upload_lettings_logs_controller.rb b/app/controllers/bulk_upload_lettings_logs_controller.rb
index 035621e41..c9cdb0eaa 100644
--- a/app/controllers/bulk_upload_lettings_logs_controller.rb
+++ b/app/controllers/bulk_upload_lettings_logs_controller.rb
@@ -25,7 +25,6 @@ class BulkUploadLettingsLogsController < ApplicationController
private
def validate_data_protection_agrement_signed!
- return unless FeatureToggle.new_data_protection_confirmation?
return if @current_user.organisation.data_protection_confirmed?
redirect_to lettings_logs_path
diff --git a/app/controllers/bulk_upload_sales_logs_controller.rb b/app/controllers/bulk_upload_sales_logs_controller.rb
index 7a7a20297..de70ffc5d 100644
--- a/app/controllers/bulk_upload_sales_logs_controller.rb
+++ b/app/controllers/bulk_upload_sales_logs_controller.rb
@@ -25,7 +25,6 @@ class BulkUploadSalesLogsController < ApplicationController
private
def validate_data_protection_agrement_signed!
- return unless FeatureToggle.new_data_protection_confirmation?
return if @current_user.organisation.data_protection_confirmed?
redirect_to sales_logs_path
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 98082bea9..83ca8405e 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -159,13 +159,10 @@ class OrganisationsController < ApplicationController
end
def data_sharing_agreement
- return render_not_found unless FeatureToggle.new_data_protection_confirmation?
-
@data_protection_confirmation = current_user.organisation.data_protection_confirmation
end
def confirm_data_sharing_agreement
- return render_not_found unless FeatureToggle.new_data_protection_confirmation?
return render_not_found unless current_user.is_dpo?
return render_not_found if @organisation.data_protection_confirmed?
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 69aa59c97..ad74ac3e6 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -103,7 +103,7 @@ class Organisation < ApplicationRecord
end
def display_organisation_attributes
- attrs = [
+ [
{ name: "Name", value: name, editable: true },
{ name: "Organisation ID", value: "ORG#{id}", editable: false },
{ name: "Address", value: address_string, editable: true },
@@ -112,13 +112,7 @@ class Organisation < ApplicationRecord
{ name: "Registration number", value: housing_registration_no || "", editable: false },
{ name: "Rent periods", value: rent_period_labels, editable: false, format: :bullet },
{ name: "Owns housing stock", value: holds_own_stock ? "Yes" : "No", editable: false },
- ].compact
-
- unless FeatureToggle.new_data_protection_confirmation?
- attrs << { name: "Data protection agreement", value: data_protection_agreement_string, editable: false }
- end
-
- attrs
+ ]
end
def has_managing_agents?
diff --git a/app/models/user.rb b/app/models/user.rb
index c9ef7cd02..2cf45de45 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -186,7 +186,6 @@ protected
private
def send_data_protection_confirmation_reminder
- return unless FeatureToggle.new_data_protection_confirmation?
return unless persisted?
return unless is_dpo?
diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb
index bb76a7668..04fb2a2d7 100644
--- a/app/models/validations/setup_validations.rb
+++ b/app/models/validations/setup_validations.rb
@@ -49,8 +49,6 @@ module Validations::SetupValidations
end
def validate_managing_organisation_data_sharing_agremeent_signed(record)
- return unless FeatureToggle.new_data_protection_confirmation?
-
if record.managing_organisation_id_changed? && record.managing_organisation.present? && !record.managing_organisation.data_protection_confirmed?
record.errors.add :managing_organisation_id, I18n.t("validations.setup.managing_organisation.data_sharing_agreement_not_signed")
end
diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb
index 3b361e9d6..f9cd25e46 100644
--- a/app/models/validations/shared_validations.rb
+++ b/app/models/validations/shared_validations.rb
@@ -118,8 +118,6 @@ module Validations::SharedValidations
end
def validate_owning_organisation_data_sharing_agremeent_signed(record)
- return unless FeatureToggle.new_data_protection_confirmation?
-
if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed?
record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.data_sharing_agreement_not_signed")
end
diff --git a/app/services/feature_toggle.rb b/app/services/feature_toggle.rb
index 153b7352a..c12af1719 100644
--- a/app/services/feature_toggle.rb
+++ b/app/services/feature_toggle.rb
@@ -30,10 +30,6 @@ class FeatureToggle
!Rails.env.production?
end
- def self.new_data_protection_confirmation?
- true
- end
-
def self.deduplication_flow_enabled?
!Rails.env.production?
end
diff --git a/app/views/logs/_create_for_org_actions.html.erb b/app/views/logs/_create_for_org_actions.html.erb
index dc0469c44..f6ed9ad82 100644
--- a/app/views/logs/_create_for_org_actions.html.erb
+++ b/app/views/logs/_create_for_org_actions.html.erb
@@ -1,5 +1,5 @@
- <% if !FeatureToggle.new_data_protection_confirmation? || @organisation.data_protection_confirmed? %>
+ <% if @organisation.data_protection_confirmed? %>
<% if current_page?(controller: 'organisations', action: 'lettings_logs') %>
<%= govuk_button_to "Create a new lettings log for this organisation", lettings_logs_path(lettings_log: { owning_organisation_id: @organisation.id }, method: :post) %>
<% end %>
diff --git a/app/views/organisations/show.html.erb b/app/views/organisations/show.html.erb
index e39338651..07af1970a 100644
--- a/app/views/organisations/show.html.erb
+++ b/app/views/organisations/show.html.erb
@@ -33,9 +33,7 @@
<% end %>
<% end %>
<% end %>
- <% if FeatureToggle.new_data_protection_confirmation? %>
- <%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
- <% end %>
+ <%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
<% end %>
<% if FeatureToggle.merge_organisations_enabled? %>
Is your organisation merging with another? <%= govuk_link_to "Let us know using this form", merge_request_organisation_path(@organisation) %>
diff --git a/spec/components/create_log_actions_component_spec.rb b/spec/components/create_log_actions_component_spec.rb
index 3ae7851eb..a52f851f0 100644
--- a/spec/components/create_log_actions_component_spec.rb
+++ b/spec/components/create_log_actions_component_spec.rb
@@ -20,10 +20,8 @@ RSpec.describe CreateLogActionsComponent, type: :component do
context "when bulk upload nil" do
let(:bulk_upload) { nil }
- context "when flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
+ context "when support user" do
+ let(:user) { create(:user, :support) }
it "renders actions" do
expect(component.display_actions?).to eq(true)
@@ -65,12 +63,16 @@ RSpec.describe CreateLogActionsComponent, type: :component do
end
end
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
+ context "when not support user" do
+ context "without data sharing agreement" do
+ let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
+
+ it "does not render actions" do
+ expect(component).not_to be_display_actions
+ end
end
- context "when support user" do
+ context "when has data sharing agremeent" do
let(:user) { create(:user, :support) }
it "renders actions" do
@@ -112,59 +114,6 @@ RSpec.describe CreateLogActionsComponent, type: :component do
end
end
end
-
- context "when not support user" do
- context "without data sharing agreement" do
- let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
-
- it "does not render actions" do
- expect(component).not_to be_display_actions
- end
- end
-
- context "when has data sharing agremeent" do
- let(:user) { create(:user, :support) }
-
- it "renders actions" do
- expect(component.display_actions?).to eq(true)
- end
-
- it "returns create button copy" do
- expect(component.create_button_copy).to eq("Create a new lettings log")
- end
-
- it "returns create button href" do
- render
- expect(component.create_button_href).to eq("/lettings-logs")
- end
-
- it "returns upload button copy" do
- expect(component.upload_button_copy).to eq("Upload lettings logs in bulk")
- end
-
- it "returns upload button href" do
- render
- expect(component.upload_button_href).to eq("/lettings-logs/bulk-upload-logs/start")
- end
-
- context "when sales log type" do
- let(:log_type) { "sales" }
-
- it "renders actions" do
- expect(component.display_actions?).to eq(true)
- end
-
- it "returns create button copy" do
- expect(component.create_button_copy).to eq("Create a new sales log")
- end
-
- it "returns create button href" do
- render
- expect(component.create_button_href).to eq("/sales-logs")
- end
- end
- end
- end
end
end
end
diff --git a/spec/components/data_protection_confirmation_banner_component_spec.rb b/spec/components/data_protection_confirmation_banner_component_spec.rb
index c78724aa3..a024dc7bb 100644
--- a/spec/components/data_protection_confirmation_banner_component_spec.rb
+++ b/spec/components/data_protection_confirmation_banner_component_spec.rb
@@ -8,10 +8,9 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
let(:user) { create(:user) }
let(:organisation) { user.organisation }
- context "when flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
+ context "when user is support and organisation is blank" do
+ let(:user) { create(:user, :support) }
+ let(:organisation) { nil }
it "does not display banner" do
expect(component.display_banner?).to eq(false)
@@ -19,15 +18,52 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
end
end
- context "when flag enabled", :aggregate_failures do
+ context "when org does not have a DPO" do
before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
+ organisation.users.where(is_dpo: true).destroy_all
end
- context "when user is support and organisation is blank" do
- let(:user) { create(:user, :support) }
- let(:organisation) { nil }
+ it "displays the banner" do
+ expect(component.display_banner?).to eq(true)
+ expect(render).to have_link(
+ "Contact helpdesk to assign a data protection officer",
+ href: "https://digital.dclg.gov.uk/jira/servicedesk/customer/portal/4/group/21",
+ )
+ 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
+
+ context "when org has a DPO" do
+ context "when org does not have a signed data sharing agreement" do
+ context "when user is not a DPO" do
+ let(:organisation) { create(:organisation, :without_dpc) }
+ let(:user) { create(:user, organisation:) }
+ let!(:dpo) { create(:user, :data_protection_officer, organisation:) }
+
+ it "displays the banner and shows DPOs" do
+ expect(component.display_banner?).to eq(true)
+ expect(render.css("a")).to be_empty
+ expect(render).to have_selector("p", text: "Your data protection officer must accept the Data Sharing Agreement on CORE before you can create any logs.")
+ expect(render).to have_selector("p", text: "You can ask: #{dpo.name}")
+ end
+ end
+
+ context "when user is a DPO" do
+ let(:organisation) { create(:organisation, :without_dpc) }
+ let(:user) { create(:user, :data_protection_officer, organisation:) }
+
+ it "displays the banner and asks to sign" do
+ expect(component.display_banner?).to eq(true)
+ expect(render).to have_link(
+ "Read the Data Sharing Agreement",
+ href: "/organisations/#{organisation.id}/data-sharing-agreement",
+ )
+ expect(render).to have_selector("p", text: "Your organisation must accept the Data Sharing Agreement before you can create any logs.")
+ end
+ end
+ end
+ context "when org has a signed data sharing agremeent" do
it "does not display banner" do
expect(component.display_banner?).to eq(false)
expect(render.content).to be_empty
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index 1b0567a0f..0cdfc014e 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -234,47 +234,19 @@ RSpec.describe Organisation, type: :model do
describe "display_organisation_attributes" do
let(:organisation) { create(:organisation) }
- context "when new_data_protection_confirmation flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
- it "does not include data protection agreement" do
- expect(organisation.display_organisation_attributes).to eq(
- [{ editable: true, name: "Name", value: "DLUHC" },
- { editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
- { editable: true,
- name: "Address",
- value: "2 Marsham Street\nLondon\nSW1P 4DF" },
- { editable: true, name: "Telephone number", value: nil },
- { editable: false, name: "Type of provider", value: "Local authority" },
- { editable: false, name: "Registration number", value: "1234" },
- { editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
- { editable: false, name: "Owns housing stock", value: "Yes" }],
- )
- end
- end
-
- context "when new_data_protection_confirmation flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "includes data protection agreement" do
- expect(organisation.display_organisation_attributes).to eq(
- [{ editable: true, name: "Name", value: "DLUHC" },
- { editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
- { editable: true,
- name: "Address",
- value: "2 Marsham Street\nLondon\nSW1P 4DF" },
- { editable: true, name: "Telephone number", value: nil },
- { editable: false, name: "Type of provider", value: "Local authority" },
- { editable: false, name: "Registration number", value: "1234" },
- { editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
- { editable: false, name: "Owns housing stock", value: "Yes" },
- { editable: false, name: "Data protection agreement", value: "Accepted" }],
- )
- end
+ it "does not include data protection agreement" do
+ expect(organisation.display_organisation_attributes).to eq(
+ [{ editable: true, name: "Name", value: "DLUHC" },
+ { editable: false, name: "Organisation ID", value: "ORG#{organisation.id}" },
+ { editable: true,
+ name: "Address",
+ value: "2 Marsham Street\nLondon\nSW1P 4DF" },
+ { editable: true, name: "Telephone number", value: nil },
+ { editable: false, name: "Type of provider", value: "Local authority" },
+ { editable: false, name: "Registration number", value: "1234" },
+ { editable: false, format: :bullet, name: "Rent periods", value: %w[All] },
+ { editable: false, name: "Owns housing stock", value: "Yes" }],
+ )
end
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 69c5f8a7e..b9fb91c06 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -382,16 +382,6 @@ RSpec.describe User, type: :model do
args: [user],
)
end
-
- context "when feature flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "does not send the email" do
- expect { user.update!(is_dpo: true) }.not_to enqueue_job(ActionMailer::MailDeliveryJob)
- end
- end
end
context "when updating to non dpo" do
diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb
index 696667b43..20f6b1d25 100644
--- a/spec/models/validations/setup_validations_spec.rb
+++ b/spec/models/validations/setup_validations_spec.rb
@@ -444,34 +444,6 @@ RSpec.describe Validations::SetupValidations do
end
describe "#validate_managing_organisation_data_sharing_agremeent_signed" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "is valid if the DSA is signed" do
- log = build(:lettings_log, :in_progress, owning_organisation: create(:organisation))
-
- expect(log).to be_valid
- end
-
- it "is valid when owning_organisation nil" do
- log = build(:lettings_log, owning_organisation: nil)
-
- expect(log).to be_valid
- end
-
- it "is not valid if the DSA is not signed" do
- log = build(:lettings_log, owning_organisation: create(:organisation, :without_dpc))
-
- expect(log).to be_valid
- end
- end
-
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
it "is valid if the Data Protection Confirmation is signed" do
log = build(:lettings_log, :in_progress, managing_organisation: create(:organisation))
diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb
index 8751f443a..52b325c29 100644
--- a/spec/models/validations/shared_validations_spec.rb
+++ b/spec/models/validations/shared_validations_spec.rb
@@ -177,34 +177,6 @@ RSpec.describe Validations::SharedValidations do
%i[sales_log lettings_log].each do |log_type|
describe "validate_owning_organisation_data_sharing_agremeent_signed" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "is valid if the DSA is signed" do
- log = build(log_type, :in_progress, owning_organisation: create(:organisation))
-
- expect(log).to be_valid
- end
-
- it "is valid when owning_organisation nil" do
- log = build(log_type, owning_organisation: nil)
-
- expect(log).to be_valid
- end
-
- it "is not valid if the DSA is not signed" do
- log = build(log_type, owning_organisation: create(:organisation, :without_dpc))
-
- expect(log).to be_valid
- end
- end
-
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
it "is valid if the Data Protection Confirmation is signed" do
log = build(log_type, :in_progress, owning_organisation: create(:organisation))
diff --git a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb
index db5a3c4a6..f901cdb7e 100644
--- a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb
+++ b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb
@@ -18,18 +18,6 @@ RSpec.describe BulkUploadLettingsLogsController, type: :request do
expect(response).to redirect_to("/lettings-logs")
end
-
- context "when feature flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "does not redirect to lettings index page" do
- get "/lettings-logs/bulk-upload-logs/start", params: {}
-
- expect(response).not_to redirect_to("/lettings-logs")
- end
- end
end
context "when not in crossover period" do
diff --git a/spec/requests/bulk_upload_sales_logs_controller_spec.rb b/spec/requests/bulk_upload_sales_logs_controller_spec.rb
index c7de6598e..3220ff885 100644
--- a/spec/requests/bulk_upload_sales_logs_controller_spec.rb
+++ b/spec/requests/bulk_upload_sales_logs_controller_spec.rb
@@ -18,18 +18,6 @@ RSpec.describe BulkUploadSalesLogsController, type: :request do
expect(response).to redirect_to("/sales-logs")
end
-
- context "when feature flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "does not redirect to lettings index page" do
- get "/lettings-logs/bulk-upload-logs/start", params: {}
-
- expect(response).not_to redirect_to("/sales-logs")
- end
- end
end
context "when not in crossover period" do
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 9dc90fb8d..f4a3c2083 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -1501,26 +1501,9 @@ RSpec.describe OrganisationsController, type: :request do
sign_in user
end
- context "when flag not enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "returns not found" do
- get "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
- expect(response).to have_http_status(:not_found)
- end
- end
-
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
- it "returns ok" do
- get "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
- expect(response).to have_http_status(:ok)
- end
+ it "returns ok" do
+ get "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
+ expect(response).to have_http_status(:ok)
end
end
end
@@ -1541,10 +1524,8 @@ RSpec.describe OrganisationsController, type: :request do
sign_in user
end
- context "when flag not enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
+ context "when user not dpo" do
+ let(:user) { create(:user, is_dpo: false) }
it "returns not found" do
post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
@@ -1552,12 +1533,8 @@ RSpec.describe OrganisationsController, type: :request do
end
end
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
- context "when user not dpo" do
+ context "when user is dpo" do
+ context "when the organisation has a non-confirmed confirmation" do
let(:user) { create(:user, is_dpo: false) }
it "returns not found" do
@@ -1566,49 +1543,38 @@ RSpec.describe OrganisationsController, type: :request do
end
end
- context "when user is dpo" do
- context "when the organisation has a non-confirmed confirmation" do
- let(:user) { create(:user, is_dpo: false) }
+ context "when the organisation does not have a confirmation" do
+ let(:user) { create(:user, is_dpo: true, organisation:) }
- it "returns not found" do
- post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
- expect(response).to have_http_status(:not_found)
- end
- end
+ it "returns redirects to details page" do
+ post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
- context "when the organisation does not have a confirmation" do
- let(:user) { create(:user, is_dpo: true, organisation:) }
+ expect(response).to redirect_to("/organisations/#{organisation.id}/details")
+ expect(flash[:notice]).to eq("You have accepted the Data Sharing Agreement")
+ expect(flash[:notification_banner_body]).to eq("Your organisation can now submit logs.")
+ end
- it "returns redirects to details page" do
- post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
+ it "creates a data sharing agreement" do
+ expect(organisation.reload.data_protection_confirmation).to be_nil
- expect(response).to redirect_to("/organisations/#{organisation.id}/details")
- expect(flash[:notice]).to eq("You have accepted the Data Sharing Agreement")
- expect(flash[:notification_banner_body]).to eq("Your organisation can now submit logs.")
- end
+ post("/organisations/#{organisation.id}/data-sharing-agreement", headers:)
- it "creates a data sharing agreement" do
- expect(organisation.reload.data_protection_confirmation).to be_nil
+ data_protection_confirmation = organisation.reload.data_protection_confirmation
- post("/organisations/#{organisation.id}/data-sharing-agreement", headers:)
-
- data_protection_confirmation = organisation.reload.data_protection_confirmation
+ expect(data_protection_confirmation.organisation.address_row).to eq(organisation.address_row)
+ expect(data_protection_confirmation.organisation.name).to eq(organisation.name)
+ expect(data_protection_confirmation.organisation.phone).to eq(organisation.phone)
+ expect(data_protection_confirmation.data_protection_officer).to eq(user)
+ end
- expect(data_protection_confirmation.organisation.address_row).to eq(organisation.address_row)
- expect(data_protection_confirmation.organisation.name).to eq(organisation.name)
- expect(data_protection_confirmation.organisation.phone).to eq(organisation.phone)
- expect(data_protection_confirmation.data_protection_officer).to eq(user)
+ context "when the user has already accepted the agreement" do
+ before do
+ create(:data_protection_confirmation, data_protection_officer: user, organisation: user.organisation)
end
- context "when the user has already accepted the agreement" do
- before do
- create(:data_protection_confirmation, data_protection_officer: user, organisation: user.organisation)
- end
-
- it "returns not found" do
- post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
- expect(response).to have_http_status(:not_found)
- end
+ it "returns not found" do
+ post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers
+ expect(response).to have_http_status(:not_found)
end
end
end
diff --git a/spec/views/logs/_create_for_org_actions.html.erb_spec.rb b/spec/views/logs/_create_for_org_actions.html.erb_spec.rb
index f554778c2..1f2918218 100644
--- a/spec/views/logs/_create_for_org_actions.html.erb_spec.rb
+++ b/spec/views/logs/_create_for_org_actions.html.erb_spec.rb
@@ -11,40 +11,21 @@ RSpec.describe "logs/_create_for_org_actions.html.erb" do
let(:user) { create(:user) }
- context "when flag disabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "shows create buttons" do
+ context "with data sharing agreement" do
+ it "does include create log buttons" do
render
-
expect(fragment).to have_button("Create a new lettings log for this organisation")
expect(fragment).to have_button("Create a new sales log for this organisation")
end
end
- context "when flag enabled" do
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(true)
- end
-
- context "with data sharing agreement" do
- it "does include create log buttons" do
- render
- expect(fragment).to have_button("Create a new lettings log for this organisation")
- expect(fragment).to have_button("Create a new sales log for this organisation")
- end
- end
-
- context "without data sharing agreement" do
- let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
+ context "without data sharing agreement" do
+ let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
- it "does not include create log buttons" do
- render
- expect(fragment).not_to have_button("Create a new lettings log for this organisation")
- expect(fragment).not_to have_button("Create a new sales log for this organisation")
- end
+ it "does not include create log buttons" do
+ render
+ expect(fragment).not_to have_button("Create a new lettings log for this organisation")
+ expect(fragment).not_to have_button("Create a new sales log for this organisation")
end
end
end
diff --git a/spec/views/organisations/show.html.erb_spec.rb b/spec/views/organisations/show.html.erb_spec.rb
index 47ec10df4..142097c27 100644
--- a/spec/views/organisations/show.html.erb_spec.rb
+++ b/spec/views/organisations/show.html.erb_spec.rb
@@ -15,20 +15,6 @@ RSpec.describe "organisations/show.html.erb" do
let(:organisation_without_dpc) { create(:organisation, :without_dpc) }
let(:organisation_with_dsa) { create(:organisation) }
- context "when flag disabled" do
- let(:user) { create(:user, organisation: organisation_without_dpc) }
-
- before do
- allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false)
- end
-
- it "does not include data sharing agreement row" do
- render
-
- expect(fragment).not_to have_content("Data Sharing Agreement")
- end
- end
-
context "when dpo" do
let(:user) { create(:user, is_dpo: true, organisation: organisation_without_dpc) }