Skip to content
Snippets Groups Projects
Commit beb47c25 authored by Lin Jen-Shin's avatar Lin Jen-Shin :cookie:
Browse files

Try to slightly optimize EmailHeleprs

parent 230bae9d
No related branches found
No related tags found
1 merge request!6342Integrate CI emails into notification system
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 @@ def reset_delivered_emails!
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment