summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-28 15:39:54 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-10-17 07:25:20 +0000
commit9622ef64e41058b8dec97c98f568d8fdea95fd61 (patch)
tree1a8858d6e6d555b822663c03be3ce10c57f2552e /spec
parent12a6bbc36a85fce8e4025470ea559a2830617eb9 (diff)
downloadgitlab-ce-9622ef64e41058b8dec97c98f568d8fdea95fd61.tar.gz
Introduce email_recipients and use include? Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6342#note_16075554 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6342#note_16075622
Diffstat (limited to 'spec')
-rw-r--r--spec/support/email_helpers.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/spec/support/email_helpers.rb b/spec/support/email_helpers.rb
index 2931967de35..caa6ab1345a 100644
--- a/spec/support/email_helpers.rb
+++ b/spec/support/email_helpers.rb
@@ -1,8 +1,6 @@
module EmailHelpers
- def sent_to_user?(user, recipients = nil)
- recipients ||= ActionMailer::Base.deliveries.flat_map(&:to)
-
- recipients.count(user.email) == 1
+ def sent_to_user?(user, recipients = email_recipients)
+ recipients.include?(user.email)
end
def reset_delivered_emails!
@@ -10,22 +8,26 @@ module EmailHelpers
end
def should_only_email(*users)
- recipients = ActionMailer::Base.deliveries.flat_map(&:to)
+ recipients = email_recipients
users.each { |user| should_email(user, recipients) }
expect(recipients.count).to eq(users.count)
end
- def should_email(user, recipients = nil)
+ def should_email(user, recipients = email_recipients)
expect(sent_to_user?(user, recipients)).to be_truthy
end
- def should_not_email(user, recipients = nil)
+ def should_not_email(user, recipients = email_recipients)
expect(sent_to_user?(user, recipients)).to be_falsey
end
def should_email_no_one
expect(ActionMailer::Base.deliveries).to be_empty
end
+
+ def email_recipients
+ ActionMailer::Base.deliveries.flat_map(&:to)
+ end
end