DEV: Add test (#10064)

Follow-up-to 84dfaad137
This commit is contained in:
Dan Ungureanu 2020-06-17 21:41:16 +03:00 committed by GitHub
parent a60a67c431
commit 7ed7b1ef64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -159,6 +159,8 @@ describe EmailUpdater do
context 'confirming a valid token' do
it "adds a user email" do
expect(UserHistory.where(action: UserHistory.actions[:add_email], acting_user_id: user.id).last).to be_present
Jobs.expects(:enqueue).once.with(:critical_user_email, has_entries(type: :notify_old_email_add, to_address: old_email))
updater.confirm(@change_req.new_email_token.token)
expect(updater.errors).to be_blank

View File

@ -2581,7 +2581,8 @@ describe UsersController do
expect(user_email.reload.primary).to eq(true)
expect(other_email.reload.primary).to eq(false)
put "/u/#{user.username}/preferences/primary-email.json", params: { email: other_email.email }
expect { put "/u/#{user.username}/preferences/primary-email.json", params: { email: other_email.email } }
.to change { UserHistory.where(action: UserHistory.actions[:update_email], acting_user_id: user.id).count }.by(1)
expect(response.status).to eq(200)
expect(user_email.reload.primary).to eq(false)
expect(other_email.reload.primary).to eq(true)
@ -2604,7 +2605,8 @@ describe UsersController do
expect(response.status).to eq(428)
expect(user.reload.user_emails.pluck(:email)).to contain_exactly(user_email.email, other_email.email)
delete "/u/#{user.username}/preferences/email.json", params: { email: other_email.email }
expect { delete "/u/#{user.username}/preferences/email.json", params: { email: other_email.email } }
.to change { UserHistory.where(action: UserHistory.actions[:destroy_email], acting_user_id: user.id).count }.by(1)
expect(response.status).to eq(200)
expect(user.reload.user_emails.pluck(:email)).to contain_exactly(user_email.email)
end