BigW Consortium Gitlab

Commit 57258566 by Lin Jen-Shin
parent d39b1959
......@@ -535,14 +535,13 @@ describe Ci::Pipeline, models: true do
shared_examples 'sending a notification' do
it 'sends an email' do
sent_to = ActionMailer::Base.deliveries.flat_map(&:to)
expect(sent_to).to contain_exactly(pipeline.user.email)
should_only_email(pipeline.user)
end
end
shared_examples 'not sending any notification' do
it 'does not send any email' do
expect(ActionMailer::Base.deliveries).to be_empty
should_email_no_one
end
end
......
module EmailHelpers
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
def reset_delivered_emails!
......@@ -20,4 +20,8 @@ module EmailHelpers
def should_not_email(user)
expect(sent_to_user?(user)).to be_falsey
end
def should_email_no_one
expect(ActionMailer::Base.deliveries).to be_empty
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