Commit 57258566 authored by Lin Jen-Shin's avatar Lin Jen-Shin
parent d39b1959
...@@ -535,14 +535,13 @@ describe Ci::Pipeline, models: true do ...@@ -535,14 +535,13 @@ describe Ci::Pipeline, models: true do
shared_examples 'sending a notification' do shared_examples 'sending a notification' do
it 'sends an email' do it 'sends an email' do
sent_to = ActionMailer::Base.deliveries.flat_map(&:to) should_only_email(pipeline.user)
expect(sent_to).to contain_exactly(pipeline.user.email)
end end
end end
shared_examples 'not sending any notification' do shared_examples 'not sending any notification' do
it 'does not send any email' do it 'does not send any email' do
expect(ActionMailer::Base.deliveries).to be_empty should_email_no_one
end end
end end
......
module EmailHelpers module EmailHelpers
def sent_to_user?(user) def sent_to_user?(user)
ActionMailer::Base.deliveries.map(&:to).flatten.count(user.email) == 1 ActionMailer::Base.deliveries.flat_map(&:to).count(user.email) == 1
end end
def reset_delivered_emails! def reset_delivered_emails!
...@@ -20,4 +20,8 @@ module EmailHelpers ...@@ -20,4 +20,8 @@ module EmailHelpers
def should_not_email(user) def should_not_email(user)
expect(sent_to_user?(user)).to be_falsey expect(sent_to_user?(user)).to be_falsey
end end
def should_email_no_one
expect(ActionMailer::Base.deliveries).to be_empty
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment