Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-19 09:01:58 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-10-17 10:25:20 +0300
commitbeb47c257a6673addb44fc6573c176f6be6cbd1b (patch)
tree493a9fc39f95b16df6c52c1acbca07187090a46d /spec/support/email_helpers.rb
parent230bae9d48505ac59bfdc61ae739192416d18e92 (diff)
Try to slightly optimize EmailHeleprs
Diffstat (limited to 'spec/support/email_helpers.rb')
-rw-r--r--spec/support/email_helpers.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/support/email_helpers.rb b/spec/support/email_helpers.rb
index dfb252544e7..2931967de35 100644
--- a/spec/support/email_helpers.rb
+++ b/spec/support/email_helpers.rb
@@ -1,6 +1,8 @@
module EmailHelpers
- def sent_to_user?(user)
- ActionMailer::Base.deliveries.flat_map(&:to).count(user.email) == 1
+ def sent_to_user?(user, recipients = nil)
+ recipients ||= ActionMailer::Base.deliveries.flat_map(&:to)
+
+ recipients.count(user.email) == 1
end
def reset_delivered_emails!
@@ -8,17 +10,19 @@ module EmailHelpers
end
def should_only_email(*users)
- users.each {|user| should_email(user) }
recipients = ActionMailer::Base.deliveries.flat_map(&:to)
+
+ users.each { |user| should_email(user, recipients) }
+
expect(recipients.count).to eq(users.count)
end
- def should_email(user)
- expect(sent_to_user?(user)).to be_truthy
+ def should_email(user, recipients = nil)
+ expect(sent_to_user?(user, recipients)).to be_truthy
end
- def should_not_email(user)
- expect(sent_to_user?(user)).to be_falsey
+ def should_not_email(user, recipients = nil)
+ expect(sent_to_user?(user, recipients)).to be_falsey
end
def should_email_no_one