Skip to content

Commit

Permalink
[issue-4351] add test cases to both UserInfoChangedMailerWorker and U…
Browse files Browse the repository at this point in the history
…serInfoChangedMailer
  • Loading branch information
Tooyosi committed Sep 2, 2024
1 parent 0297f29 commit 16e2a9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 6 additions & 1 deletion spec/mailers/user_info_changed_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
end

context "email address was changed" do
let(:mail) { UserInfoChangedMailer.user_info_changed(user, "email")}
prev_email = '[email protected]'
let(:mail) { UserInfoChangedMailer.user_info_changed(user, "email", prev_email)}
it 'should have the correct subject' do
expect(mail.subject).to eq("Your Zooniverse email address has been changed")
end

it 'should notify the previous mail' do
expect(mail.to).to include(prev_email)
end
end
end
end
13 changes: 11 additions & 2 deletions spec/workers/user_info_changed_mailer_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@
let(:project) { create(:project) }
let(:user) { create(:user) }

it 'should deliver the mail' do
expect{ subject.perform(user.id, "password") }.to change{ ActionMailer::Base.deliveries.count }.by(1)
context 'email delivery' do
it 'should deliver the mail' do
expect{ subject.perform(user.id, "password") }.to change{ ActionMailer::Base.deliveries.count }.by(1)
end

it 'should deliver to the right recipients' do
prev_pass = '[email protected]'
subject.perform(user.id, "email", prev_pass)
mail = ActionMailer::Base.deliveries.last
expect(mail.to).to eq([user.email, prev_pass])
end
end

context "without a user" do
Expand Down

0 comments on commit 16e2a9c

Please sign in to comment.