|
|
|
|
@ -1551,27 +1551,6 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
user.legacy_users.destroy_all |
|
|
|
|
|
|
|
|
|
allow(FeatureToggle).to receive(:new_email_journey?).and_return(false) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "allows changing email and dpo" do |
|
|
|
|
request |
|
|
|
|
user.reload |
|
|
|
|
expect(user.unconfirmed_email).to eq(new_email) |
|
|
|
|
expect(user.is_data_protection_officer?).to be true |
|
|
|
|
expect(user.is_key_contact?).to be true |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "sends a confirmation email to both emails" do |
|
|
|
|
expect(notify_client).to receive(:send_email).with(email_address: new_email, template_id: User::CONFIRMABLE_TEMPLATE_ID, personalisation:).once |
|
|
|
|
expect(notify_client).to receive(:send_email).with(email_address: user.email, template_id: User::CONFIRMABLE_TEMPLATE_ID, personalisation:).once |
|
|
|
|
request |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with new email journy enabled" do |
|
|
|
|
before do |
|
|
|
|
allow(FeatureToggle).to receive(:new_email_journey?).and_return(true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows flash notice" do |
|
|
|
|
@ -1647,7 +1626,6 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when we update the user password" do |
|
|
|
|
let(:params) do |
|
|
|
|
@ -1778,37 +1756,6 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
other_user.legacy_users.destroy_all |
|
|
|
|
|
|
|
|
|
allow(FeatureToggle).to receive(:new_email_journey?).and_return(false) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does not update the password" do |
|
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
|
.not_to change(other_user, :encrypted_password) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "does update other values" do |
|
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
|
.to change { other_user.reload.name }.from("Danny Rojas").to("new name") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "allows changing email" do |
|
|
|
|
expect { patch "/users/#{other_user.id}", headers:, params: } |
|
|
|
|
.to change { other_user.reload.unconfirmed_email }.from(nil).to(new_email) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "sends a confirmation email to both emails" do |
|
|
|
|
expect(notify_client).to receive(:send_email).with(email_address: other_user.email, template_id: User::CONFIRMABLE_TEMPLATE_ID, personalisation:).once |
|
|
|
|
expect(notify_client).to receive(:send_email).with(email_address: new_email, template_id: User::CONFIRMABLE_TEMPLATE_ID, personalisation:).once |
|
|
|
|
|
|
|
|
|
expect(notify_client).not_to receive(:send_email) |
|
|
|
|
|
|
|
|
|
patch "/users/#{other_user.id}", headers:, params: |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with new user email flow enabled" do |
|
|
|
|
before do |
|
|
|
|
allow(FeatureToggle).to receive(:new_email_journey?).and_return(true) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows flash notice" do |
|
|
|
|
@ -1845,7 +1792,6 @@ RSpec.describe UsersController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when the update fails to persist" do |
|
|
|
|
before do |
|
|
|
|
|