Browse Source

Fix up DSA creations

pull/2507/head
Kat 2 years ago
parent
commit
5d804e2284
  1. 2
      spec/components/create_log_actions_component_spec.rb
  2. 16
      spec/components/data_protection_confirmation_banner_component_spec.rb
  3. 4
      spec/factories/organisation.rb
  4. 8
      spec/factories/user.rb
  5. 2
      spec/policies/user_policy_spec.rb
  6. 2
      spec/requests/bulk_upload_lettings_logs_controller_spec.rb
  7. 2
      spec/requests/bulk_upload_sales_logs_controller_spec.rb
  8. 2
      spec/requests/organisations_controller_spec.rb
  9. 2
      spec/views/logs/_create_for_org_actions.html.erb_spec.rb
  10. 2
      spec/views/organisations/data_sharing_agreement.html.erb_spec.rb
  11. 12
      spec/views/organisations/show.html.erb_spec.rb

2
spec/components/create_log_actions_component_spec.rb

@ -66,7 +66,7 @@ RSpec.describe CreateLogActionsComponent, type: :component do
context "when not support user" do
context "without data sharing agreement" do
let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
let(:user) { create(:user, organisation: create(:organisation, :without_dpc), with_dsa: false) }
it "does not render actions" do
expect(component).not_to be_display_actions

16
spec/components/data_protection_confirmation_banner_component_spec.rb

@ -5,11 +5,11 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
let(:component) { described_class.new(user:, organisation:) }
let(:render) { render_inline(component) }
let(:user) { create(:user) }
let(:user) { create(:user, with_dsa: false) }
let(:organisation) { user.organisation }
context "when user is support and organisation is blank" do
let(:user) { create(:user, :support) }
let(:user) { create(:user, :support, with_dsa: false) }
let(:organisation) { nil }
it "does not display banner" do
@ -37,8 +37,8 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component 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:) }
let(:user) { create(:user, organisation:, with_dsa: false) }
let!(:dpo) { create(:user, :data_protection_officer, organisation:, with_dsa: false) }
it "displays the banner and shows DPOs" do
expect(component.display_banner?).to eq(true)
@ -50,7 +50,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
context "when user is a DPO" do
let(:organisation) { create(:organisation, :without_dpc) }
let(:user) { create(:user, :data_protection_officer, organisation:) }
let(:user) { create(:user, :data_protection_officer, organisation:, with_dsa: false) }
it "displays the banner and asks to sign" do
expect(component.display_banner?).to eq(true)
@ -141,8 +141,8 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component 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:) }
let(:user) { create(:user, organisation:, with_dsa: false) }
let!(:dpo) { create(:user, :data_protection_officer, organisation:, with_dsa: false) }
it "displays the banner and shows DPOs" do
expect(component.display_banner?).to eq(true)
@ -168,7 +168,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do
context "when user is a DPO" do
let(:organisation) { create(:organisation, :without_dpc) }
let(:user) { create(:user, :data_protection_officer, organisation:) }
let(:user) { create(:user, :data_protection_officer, organisation:, with_dsa: false) }
it "displays the banner and asks to sign" do
expect(component.display_banner?).to eq(true)

4
spec/factories/organisation.rb

@ -25,11 +25,11 @@ FactoryBot.define do
end
after(:create) do |org, evaluator|
if evaluator.with_dsa
if evaluator.with_dsa && !org.data_protection_confirmed?
create(
:data_protection_confirmation,
organisation: org,
data_protection_officer: org.users.any? ? org.users.first : create(:user, :data_protection_officer, organisation: org),
data_protection_officer: org.users.any? ? org.users.first : create(:user, :data_protection_officer, organisation: org, with_dsa: false),
)
end
end

8
spec/factories/user.rb

@ -27,8 +27,12 @@ FactoryBot.define do
old_user_id { SecureRandom.uuid }
end
after(:create) do |user, _evaluator|
unless user.organisation.data_protection_confirmed?
transient do
with_dsa { true }
end
after(:create) do |user, evaluator|
if evaluator.with_dsa && !user.organisation.data_protection_confirmed?
create(
:data_protection_confirmation,
organisation: user.organisation,

2
spec/policies/user_policy_spec.rb

@ -201,7 +201,7 @@ RSpec.describe UserPolicy do
end
context "and user is the DPO that hasn't signed the agreement" do
let(:user) { create(:user, active: false, is_dpo: true) }
let(:user) { create(:user, active: false, is_dpo: true, with_dsa: false) }
it "does not allow deleting a user as a provider" do
expect(policy).not_to permit(data_provider, user)

2
spec/requests/bulk_upload_lettings_logs_controller_spec.rb

@ -13,7 +13,7 @@ RSpec.describe BulkUploadLettingsLogsController, type: :request do
describe "GET /lettings-logs/bulk-upload-logs/start" do
context "when data protection confirmation not signed" do
let(:organisation) { create(:organisation, :without_dpc) }
let(:user) { create(:user, organisation:) }
let(:user) { create(:user, organisation:, with_dsa: false) }
it "redirects to lettings index page" do
get "/lettings-logs/bulk-upload-logs/start", params: {}

2
spec/requests/bulk_upload_sales_logs_controller_spec.rb

@ -13,7 +13,7 @@ RSpec.describe BulkUploadSalesLogsController, type: :request do
describe "GET /sales-logs/bulk-upload-logs/start" do
context "when data protection confirmation not signed" do
let(:organisation) { create(:organisation, :without_dpc) }
let(:user) { create(:user, organisation:) }
let(:user) { create(:user, organisation:, with_dsa: false) }
it "redirects to sales index page" do
get "/sales-logs/bulk-upload-logs/start", params: {}

2
spec/requests/organisations_controller_spec.rb

@ -2145,7 +2145,7 @@ RSpec.describe OrganisationsController, type: :request do
Timecop.unfreeze
end
let(:user) { create(:user, is_dpo: true, organisation:) }
let(:user) { create(:user, is_dpo: true, organisation:, with_dsa: false) }
it "returns redirects to details page" do
post "/organisations/#{organisation.id}/data-sharing-agreement", headers: headers

2
spec/views/logs/_create_for_org_actions.html.erb_spec.rb

@ -20,7 +20,7 @@ RSpec.describe "logs/_create_for_org_actions.html.erb" do
end
context "without data sharing agreement" do
let(:user) { create(:user, organisation: create(:organisation, :without_dpc)) }
let(:user) { create(:user, organisation: create(:organisation, :without_dpc), with_dsa: false) }
it "does not include create log buttons" do
render

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

@ -17,7 +17,7 @@ RSpec.describe "organisations/data_sharing_agreement.html.erb", :aggregate_failu
let(:data_protection_confirmation) { nil }
context "when dpo" do
let(:user) { create(:user, is_dpo: true, organisation: create(:organisation, :without_dpc)) }
let(:user) { create(:user, is_dpo: true, organisation: create(:organisation, :without_dpc), with_dsa: false) }
it "renders dynamic content" do
render

12
spec/views/organisations/show.html.erb_spec.rb

@ -11,7 +11,7 @@ RSpec.describe "organisations/show.html.erb" do
let(:organisation_with_dsa) { create(:organisation) }
context "when dpo" do
let(:user) { create(:user, is_dpo: true, organisation: organisation_without_dpc) }
let(:user) { create(:user, is_dpo: true, organisation: organisation_without_dpc, with_dsa: false) }
it "includes data sharing agreement row" do
render
@ -32,7 +32,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when accepted" do
let(:user) { create(:user, organisation: organisation_with_dsa) }
let(:user) { create(:user, organisation: organisation_with_dsa, with_dsa: false) }
it "includes data sharing agreement row" do
render
@ -55,7 +55,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when support user" do
let(:user) { create(:user, :support, organisation: organisation_without_dpc) }
let(:user) { create(:user, :support, organisation: organisation_without_dpc, with_dsa: false) }
it "includes data sharing agreement row" do
render
@ -82,7 +82,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when accepted" do
let(:user) { create(:user, :support, organisation: organisation_with_dsa) }
let(:user) { create(:user, :support, organisation: organisation_with_dsa, with_dsa: false) }
it "includes data sharing agreement row" do
render
@ -125,7 +125,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when not dpo" do
let(:user) { create(:user, organisation: organisation_without_dpc) }
let(:user) { create(:user, organisation: organisation_without_dpc, with_dsa: false) }
it "includes data sharing agreement row" do
render
@ -149,7 +149,7 @@ RSpec.describe "organisations/show.html.erb" do
end
context "when accepted" do
let(:user) { create(:user, organisation: organisation_with_dsa) }
let(:user) { create(:user, organisation: organisation_with_dsa, with_dsa: false) }
it "includes data sharing agreement row" do
render

Loading…
Cancel
Save