Use EmailHelpers where possible, feedback:

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6342#note_15434860
This commit is contained in:
Lin Jen-Shin 2016-09-19 13:54:16 +08:00
parent d39b1959d8
commit 572585665f
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
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