|
|
|
@ -445,7 +445,9 @@ RSpec.describe User, type: :model do
|
|
|
|
|
context "when updating to dpo" do |
|
|
|
|
let!(:user) { create(:user, is_dpo: false) } |
|
|
|
|
|
|
|
|
|
context "when data_protection_confirmed? is false" do |
|
|
|
|
it "sends the email" do |
|
|
|
|
allow(user.organisation).to receive(:data_protection_confirmed?).and_return(false) |
|
|
|
|
expect { user.update!(is_dpo: true) }.to enqueue_job(ActionMailer::MailDeliveryJob).with( |
|
|
|
|
"DataProtectionConfirmationMailer", |
|
|
|
|
"send_confirmation_email", |
|
|
|
@ -455,6 +457,14 @@ RSpec.describe User, type: :model do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when data_protection_confirmed? is true" do |
|
|
|
|
it "does not send the email" do |
|
|
|
|
allow(user.organisation).to receive(:data_protection_confirmed?).and_return(true) |
|
|
|
|
expect { user.update!(is_dpo: true) }.not_to enqueue_job(ActionMailer::MailDeliveryJob) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when updating to non dpo" do |
|
|
|
|
let!(:user) { create(:user, is_dpo: true) } |
|
|
|
|
|
|
|
|
|