2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe Jobs::UserEmail do
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
before do
|
2016-01-27 09:19:49 +08:00
|
|
|
SiteSetting.email_time_window_mins = 10
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:user) { Fabricate(:user, last_seen_at: 11.minutes.ago) }
|
|
|
|
fab!(:staged) { Fabricate(:user, staged: true, last_seen_at: 11.minutes.ago) }
|
|
|
|
fab!(:suspended) { Fabricate(:user, last_seen_at: 10.minutes.ago, suspended_at: 5.minutes.ago, suspended_till: 7.days.from_now) }
|
|
|
|
fab!(:anonymous) { Fabricate(:anonymous, last_seen_at: 11.minutes.ago) }
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
it "raises an error when there is no user" do
|
2014-12-31 22:55:03 +08:00
|
|
|
expect { Jobs::UserEmail.new.execute(type: :digest) }.to raise_error(Discourse::InvalidParameters)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error when there is no type" do
|
2014-12-31 22:55:03 +08:00
|
|
|
expect { Jobs::UserEmail.new.execute(user_id: user.id) }.to raise_error(Discourse::InvalidParameters)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error when the type doesn't exist" do
|
2014-12-31 22:55:03 +08:00
|
|
|
expect { Jobs::UserEmail.new.execute(type: :no_method, user_id: user.id) }.to raise_error(Discourse::InvalidParameters)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2019-03-23 00:33:54 +08:00
|
|
|
context 'digest can be generated' do
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:user) { Fabricate(:user, last_seen_at: 8.days.ago, last_emailed_at: 8.days.ago) }
|
|
|
|
fab!(:popular_topic) { Fabricate(:topic, user: Fabricate(:admin), created_at: 1.hour.ago) }
|
2019-03-12 09:39:16 +08:00
|
|
|
|
2019-03-23 00:33:54 +08:00
|
|
|
it "doesn't call the mailer when the user is missing" do
|
2019-10-14 17:25:31 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: User.last.id + 10000)
|
2019-03-23 00:33:54 +08:00
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't call the mailer when the user is staged" do
|
2019-04-29 15:32:25 +08:00
|
|
|
staged.update!(last_seen_at: 8.days.ago, last_emailed_at: 8.days.ago)
|
2019-03-23 00:33:54 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: staged.id)
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'not emailed recently' do
|
|
|
|
before do
|
2020-10-07 22:30:38 +08:00
|
|
|
freeze_time
|
2019-04-29 15:32:25 +08:00
|
|
|
user.update!(last_emailed_at: 8.days.ago)
|
2019-03-23 00:33:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "calls the mailer when the user exists" do
|
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: user.id)
|
|
|
|
expect(ActionMailer::Base.deliveries).to_not be_empty
|
2020-10-07 22:30:38 +08:00
|
|
|
expect(user.user_stat.reload.digest_attempted_at).to eq_time(Time.zone.now)
|
2019-03-23 00:33:54 +08:00
|
|
|
end
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2019-03-23 00:33:54 +08:00
|
|
|
context 'recently emailed' do
|
|
|
|
before do
|
2020-10-07 22:30:38 +08:00
|
|
|
freeze_time
|
2019-04-29 15:32:25 +08:00
|
|
|
user.update!(last_emailed_at: 2.hours.ago)
|
|
|
|
user.user_option.update!(digest_after_minutes: 1.day.to_i / 60)
|
2019-03-23 00:33:54 +08:00
|
|
|
end
|
2019-03-12 09:39:16 +08:00
|
|
|
|
2019-03-23 00:33:54 +08:00
|
|
|
it 'skips sending digest email' do
|
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: user.id)
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2020-10-07 22:30:38 +08:00
|
|
|
expect(user.user_stat.reload.digest_attempted_at).to eq_time(Time.zone.now)
|
2019-03-23 00:33:54 +08:00
|
|
|
end
|
|
|
|
end
|
2015-11-07 02:19:13 +08:00
|
|
|
end
|
|
|
|
|
2017-03-08 17:06:16 +08:00
|
|
|
context "bounce score" do
|
|
|
|
|
|
|
|
it "always sends critical emails when bounce score threshold has been reached" do
|
|
|
|
email_token = Fabricate(:email_token)
|
|
|
|
user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold + 1)
|
|
|
|
|
|
|
|
Jobs::CriticalUserEmail.new.execute(type: "signup", user_id: user.id, email_token: email_token.token)
|
|
|
|
|
|
|
|
email_log = EmailLog.where(user_id: user.id).last
|
|
|
|
expect(email_log.email_type).to eq("signup")
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
2017-03-08 17:06:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
context 'to_address' do
|
|
|
|
it 'overwrites a to_address when present' do
|
2016-03-08 03:40:11 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, to_address: 'jake@adventuretime.ooo')
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
'jake@adventuretime.ooo'
|
|
|
|
)
|
2013-02-26 00:42:20 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2018-10-01 01:15:45 +08:00
|
|
|
context "disable_emails setting" do
|
|
|
|
it "sends when no" do
|
|
|
|
SiteSetting.disable_emails = 'no'
|
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
2018-10-01 01:15:45 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not send an email when yes" do
|
|
|
|
SiteSetting.disable_emails = 'yes'
|
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2018-10-01 01:15:45 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
context "recently seen" do
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:post) { Fabricate(:post, user: user) }
|
|
|
|
fab!(:notification) { Fabricate(
|
2019-03-15 22:55:11 +08:00
|
|
|
:notification,
|
|
|
|
user: user,
|
|
|
|
topic: post.topic,
|
|
|
|
post_number: post.post_number,
|
|
|
|
data: { original_post_id: post.id }.to_json
|
|
|
|
)
|
|
|
|
}
|
|
|
|
before do
|
|
|
|
user.update_column(:last_seen_at, 9.minutes.ago)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't send an email to a user that's been recently seen" do
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does send an email to a user that's been recently seen but has email_level set to always" do
|
2019-04-29 15:32:25 +08:00
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:always])
|
2019-03-15 22:55:11 +08:00
|
|
|
PostTiming.create!(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id, msecs: 100)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_replied,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-04-19 02:32:11 +08:00
|
|
|
it "doesn't send an email even if email_level is set to always if `force_respect_seen_recently` arg is true" do
|
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:always])
|
|
|
|
PostTiming.create!(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id, msecs: 100)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_replied,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
force_respect_seen_recently: true
|
|
|
|
)
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
2021-07-06 03:27:31 +08:00
|
|
|
it "sends an email with no gsub substitution bugs" do
|
|
|
|
upload = Fabricate(:upload)
|
|
|
|
|
|
|
|
post.update!(raw: <<~RAW)
|
|
|
|
This is a test post
|
|
|
|
|
|
|
|
With a \\0 \\1 \\2 in it
|
|
|
|
RAW
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
email = ActionMailer::Base.deliveries.first
|
|
|
|
|
|
|
|
expect(email.to).to contain_exactly(user.email)
|
|
|
|
|
|
|
|
html_part = email.parts.find { |x| x.content_type.include? "html" }
|
|
|
|
expect(html_part.body.to_s).to_not include('%{email_content}')
|
|
|
|
expect(html_part.body.to_s).to include('\0')
|
|
|
|
end
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
it "sends an email by default for a PM to a user that's been recently seen" do
|
2019-06-11 16:00:59 +08:00
|
|
|
upload = Fabricate(:upload)
|
|
|
|
|
|
|
|
post.update!(raw: <<~RAW)
|
|
|
|
This is a test post
|
|
|
|
|
|
|
|
<a class="attachment" href="#{upload.url}">test</a>
|
|
|
|
<img src="#{upload.url}"/>
|
|
|
|
RAW
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
2019-06-11 16:00:59 +08:00
|
|
|
email = ActionMailer::Base.deliveries.first
|
|
|
|
|
|
|
|
expect(email.to).to contain_exactly(user.email)
|
|
|
|
|
|
|
|
expect(email.parts[0].body.to_s).to include(<<~MD)
|
|
|
|
This is a test post
|
|
|
|
|
|
|
|
[test|attachment](#{Discourse.base_url}#{upload.url})
|
|
|
|
![](#{Discourse.base_url}#{upload.url})
|
|
|
|
MD
|
2019-03-15 22:55:11 +08:00
|
|
|
end
|
|
|
|
|
2020-09-24 00:13:21 +08:00
|
|
|
it "sends a PM email to a user that's been recently seen and has email_messages_level set to always" do
|
|
|
|
user.user_option.update(email_messages_level: UserOption.email_level_types[:always])
|
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:never])
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
it "doesn't send a PM email to a user that's been recently seen and has email_messages_level set to never" do
|
2019-04-29 15:32:25 +08:00
|
|
|
user.user_option.update(email_messages_level: UserOption.email_level_types[:never])
|
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:always])
|
2019-03-15 22:55:11 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't send a regular post email to a user that's been recently seen and has email_level set to never" do
|
2019-04-29 15:32:25 +08:00
|
|
|
user.user_option.update(email_messages_level: UserOption.email_level_types[:always])
|
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:never])
|
2019-03-15 22:55:11 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-29 02:01:35 +08:00
|
|
|
context "email_log" do
|
2020-03-11 05:13:17 +08:00
|
|
|
fab!(:post) { Fabricate(:post, created_at: 30.seconds.ago) }
|
2016-01-29 02:01:35 +08:00
|
|
|
|
2017-08-15 00:47:33 +08:00
|
|
|
before do
|
|
|
|
SiteSetting.editing_grace_period = 0
|
|
|
|
end
|
2016-01-29 23:49:49 +08:00
|
|
|
|
|
|
|
it "creates an email log when the mail is sent (via Email::Sender)" do
|
2020-03-11 05:13:17 +08:00
|
|
|
freeze_time
|
|
|
|
|
|
|
|
last_emailed_at = 7.days.ago
|
|
|
|
user.update!(last_emailed_at: last_emailed_at)
|
|
|
|
Topic.last.update(created_at: 1.minute.ago)
|
2016-01-29 02:30:38 +08:00
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
expect do
|
2020-03-11 05:13:17 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: user.id)
|
2018-07-24 12:55:43 +08:00
|
|
|
end.to change { EmailLog.count }.by(1)
|
2016-01-29 02:30:38 +08:00
|
|
|
|
2016-01-29 02:01:35 +08:00
|
|
|
email_log = EmailLog.last
|
2016-01-29 02:30:38 +08:00
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
expect(email_log.user).to eq(user)
|
|
|
|
expect(email_log.post).to eq(nil)
|
2016-01-29 02:30:38 +08:00
|
|
|
# last_emailed_at should have changed
|
2020-03-11 05:13:17 +08:00
|
|
|
expect(email_log.user.last_emailed_at).to_not eq_time(last_emailed_at)
|
2016-01-29 02:01:35 +08:00
|
|
|
end
|
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
it "creates a skipped email log when the mail is skipped" do
|
2020-03-11 05:13:17 +08:00
|
|
|
freeze_time
|
|
|
|
|
|
|
|
last_emailed_at = 7.days.ago
|
|
|
|
user.update!(
|
|
|
|
last_emailed_at: last_emailed_at,
|
|
|
|
suspended_till: 1.year.from_now
|
|
|
|
)
|
2016-01-29 02:30:38 +08:00
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
expect do
|
|
|
|
Jobs::UserEmail.new.execute(type: :digest, user_id: user.id)
|
|
|
|
end.to change { SkippedEmailLog.count }.by(1)
|
2016-01-29 02:30:38 +08:00
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
expect(SkippedEmailLog.exists?(
|
|
|
|
email_type: "digest",
|
|
|
|
user: user,
|
|
|
|
post: nil,
|
|
|
|
to_address: user.email,
|
|
|
|
reason_type: SkippedEmailLog.reason_types[:user_email_user_suspended_not_pm]
|
|
|
|
)).to eq(true)
|
2016-01-29 02:30:38 +08:00
|
|
|
|
|
|
|
# last_emailed_at doesn't change
|
2020-03-11 05:13:17 +08:00
|
|
|
expect(user.last_emailed_at).to eq_time(last_emailed_at)
|
2016-01-29 02:01:35 +08:00
|
|
|
end
|
|
|
|
|
2019-07-03 18:06:34 +08:00
|
|
|
it "creates a skipped email log when the user isn't allowed to see the post" do
|
2019-07-01 19:57:33 +08:00
|
|
|
user.user_option.update(email_level: UserOption.email_level_types[:always])
|
|
|
|
post.topic.convert_to_private_message(Discourse.system_user)
|
|
|
|
|
|
|
|
expect do
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_posted, user_id: user.id, post_id: post.id)
|
|
|
|
end.to change { SkippedEmailLog.count }.by(1)
|
|
|
|
|
|
|
|
expect(SkippedEmailLog.exists?(
|
|
|
|
email_type: "user_posted",
|
|
|
|
user: user,
|
|
|
|
post: post,
|
|
|
|
to_address: user.email,
|
|
|
|
reason_type: SkippedEmailLog.reason_types[:user_email_access_denied]
|
|
|
|
)).to eq(true)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
2016-01-29 02:01:35 +08:00
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
context 'args' do
|
2013-02-26 00:42:20 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
it 'passes a token as an argument when a token is present' do
|
|
|
|
Jobs::UserEmail.new.execute(type: :forgot_password, user_id: user.id, email_token: 'asdfasdf')
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
mail = ActionMailer::Base.deliveries.first
|
|
|
|
|
|
|
|
expect(mail.to).to contain_exactly(user.email)
|
|
|
|
expect(mail.body).to include("asdfasdf")
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2020-10-07 11:02:24 +08:00
|
|
|
context "confirm_new_email" do
|
|
|
|
let(:email_token) { Fabricate(:email_token, user: user) }
|
|
|
|
before do
|
|
|
|
EmailChangeRequest.create!(
|
|
|
|
user: user,
|
|
|
|
requested_by: requested_by,
|
|
|
|
new_email_token: email_token,
|
|
|
|
new_email: "testnew@test.com",
|
|
|
|
change_state: EmailChangeRequest.states[:authorizing_new]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the change was requested by admin" do
|
|
|
|
let(:requested_by) { Fabricate(:admin) }
|
|
|
|
it "passes along true for the requested_by_admin param which changes the wording in the email" do
|
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, email_token: email_token.token)
|
|
|
|
mail = ActionMailer::Base.deliveries.first
|
|
|
|
expect(mail.body).to include("This email change was requested by a site admin.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the change was requested by the user" do
|
|
|
|
let(:requested_by) { user }
|
|
|
|
it "passes along false for the requested_by_admin param which changes the wording in the email" do
|
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, email_token: email_token.token)
|
|
|
|
mail = ActionMailer::Base.deliveries.first
|
|
|
|
expect(mail.body).not_to include("This email change was requested by a site admin.")
|
|
|
|
end
|
|
|
|
end
|
2021-04-01 19:09:28 +08:00
|
|
|
|
|
|
|
context "when requested_by record is not present" do
|
|
|
|
let(:requested_by) { nil }
|
|
|
|
it "passes along false for the requested_by_admin param which changes the wording in the email" do
|
|
|
|
Jobs::UserEmail.new.execute(type: :confirm_new_email, user_id: user.id, email_token: email_token.token)
|
|
|
|
mail = ActionMailer::Base.deliveries.first
|
|
|
|
expect(mail.body).not_to include("This email change was requested by a site admin.")
|
|
|
|
end
|
|
|
|
end
|
2020-10-07 11:02:24 +08:00
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
context "post" do
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:post) { Fabricate(:post, user: user) }
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
it "doesn't send the email if you've seen the post" do
|
|
|
|
PostTiming.record_timing(topic_id: post.topic_id, user_id: user.id, post_number: post.post_number, msecs: 6666)
|
2017-01-05 16:15:55 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2013-03-26 01:39:57 +08:00
|
|
|
it "doesn't send the email if the user deleted the post" do
|
|
|
|
post.update_column(:user_deleted, true)
|
2017-01-05 16:15:55 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2013-03-26 01:39:57 +08:00
|
|
|
end
|
|
|
|
|
2016-05-17 23:42:15 +08:00
|
|
|
it "doesn't send the email if user of the post has been deleted" do
|
2019-04-29 15:32:25 +08:00
|
|
|
post.update!(user_id: nil)
|
2016-05-17 23:42:15 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2016-05-17 23:42:15 +08:00
|
|
|
end
|
|
|
|
|
2013-11-08 02:53:32 +08:00
|
|
|
context 'user is suspended' do
|
2013-10-31 03:31:16 +08:00
|
|
|
it "doesn't send email for a pm from a regular user" do
|
2017-01-05 16:15:55 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: suspended.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
|
|
|
|
2017-01-05 16:15:55 +08:00
|
|
|
it "does send an email for a pm from a staff user" do
|
2013-10-31 03:31:16 +08:00
|
|
|
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
2013-11-08 02:53:32 +08:00
|
|
|
pm_from_staff.topic.topic_allowed_users.create!(user_id: suspended.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
pm_notification = Fabricate(:notification,
|
|
|
|
user: suspended,
|
|
|
|
topic: pm_from_staff.topic,
|
|
|
|
post_number: pm_from_staff.post_number,
|
|
|
|
data: { original_post_id: pm_from_staff.id }.to_json
|
|
|
|
)
|
|
|
|
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: suspended.id,
|
|
|
|
post_id: pm_from_staff.id,
|
|
|
|
notification_id: pm_notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
suspended.email
|
|
|
|
)
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
2020-07-09 01:30:32 +08:00
|
|
|
|
|
|
|
it "doesn't send PM from system user" do
|
|
|
|
pm_from_system = SystemMessage.create(suspended, :unsilenced)
|
|
|
|
|
|
|
|
system_pm_notification = Fabricate(:notification,
|
|
|
|
user: suspended,
|
|
|
|
topic: pm_from_system.topic,
|
|
|
|
post_number: pm_from_system.post_number,
|
|
|
|
data: { original_post_id: pm_from_system.id }.to_json
|
|
|
|
)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
|
|
|
user_id: suspended.id,
|
|
|
|
post_id: pm_from_system.id,
|
|
|
|
notification_id: system_pm_notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
2015-05-11 07:10:10 +08:00
|
|
|
|
|
|
|
context 'user is anonymous' do
|
2017-07-07 14:09:14 +08:00
|
|
|
before { SiteSetting.allow_anonymous_posting = true }
|
2015-05-11 07:10:10 +08:00
|
|
|
|
|
|
|
it "doesn't send email for a pm from a regular user" do
|
2017-01-05 16:15:55 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: anonymous.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2015-05-11 07:10:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't send email for a pm from a staff user" do
|
|
|
|
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
|
|
|
pm_from_staff.topic.topic_allowed_users.create!(user_id: anonymous.id)
|
2017-01-05 16:15:55 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: anonymous.id, post_id: pm_from_staff.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2015-05-11 07:10:10 +08:00
|
|
|
end
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'notification' do
|
2019-05-07 11:12:20 +08:00
|
|
|
fab!(:post) { Fabricate(:post, user: user) }
|
|
|
|
fab!(:notification) {
|
2014-02-04 09:56:28 +08:00
|
|
|
Fabricate(:notification,
|
|
|
|
user: user,
|
|
|
|
topic: post.topic,
|
|
|
|
post_number: post.post_number,
|
|
|
|
data: {
|
|
|
|
original_post_id: post.id
|
|
|
|
}.to_json
|
|
|
|
)
|
|
|
|
}
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
it "doesn't send the email if the notification has been seen" do
|
|
|
|
notification.update_column(:read, true)
|
2016-01-27 09:19:49 +08:00
|
|
|
message, err = Jobs::UserEmail.new.message_for_email(
|
2017-09-14 04:44:47 +08:00
|
|
|
user,
|
|
|
|
post,
|
|
|
|
:user_mentioned,
|
|
|
|
notification,
|
|
|
|
notification_type: notification.notification_type,
|
|
|
|
notification_data_hash: notification.data_hash
|
|
|
|
)
|
2016-01-27 09:19:49 +08:00
|
|
|
|
2018-07-24 12:55:43 +08:00
|
|
|
expect(message).to eq(nil)
|
|
|
|
|
|
|
|
expect(SkippedEmailLog.exists?(
|
|
|
|
email_type: "user_mentioned",
|
|
|
|
user: user,
|
|
|
|
post: post,
|
|
|
|
to_address: user.email,
|
|
|
|
reason_type: SkippedEmailLog.reason_types[:user_email_notification_already_read]
|
|
|
|
)).to eq(true)
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
it "does send the email if the notification has been seen but user has email_level set to always" do
|
2014-06-09 19:09:36 +08:00
|
|
|
notification.update_column(:read, true)
|
2019-03-15 22:55:11 +08:00
|
|
|
user.user_option.update_column(:email_level, UserOption.email_level_types[:always])
|
2019-03-12 09:39:16 +08:00
|
|
|
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
2014-06-09 19:09:36 +08:00
|
|
|
end
|
|
|
|
|
2016-08-04 00:29:38 +08:00
|
|
|
it "does send the email if the user is using daily mailing list mode" do
|
|
|
|
user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 0)
|
|
|
|
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2021-03-17 23:39:10 +08:00
|
|
|
it "sends the mail if the user enabled mailing list mode, but mailing list mode is disabled globally" do
|
|
|
|
user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(user.email)
|
|
|
|
end
|
|
|
|
|
2019-03-12 09:39:16 +08:00
|
|
|
context "recently seen" do
|
|
|
|
it "doesn't send an email to a user that's been recently seen" do
|
|
|
|
user.update!(last_seen_at: 9.minutes.ago)
|
|
|
|
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_replied,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
|
|
|
end
|
|
|
|
|
2019-03-15 22:55:11 +08:00
|
|
|
it "does send an email to a user that's been recently seen but has email_level set to always" do
|
2019-03-12 09:39:16 +08:00
|
|
|
user.update!(last_seen_at: 9.minutes.ago)
|
2019-03-15 22:55:11 +08:00
|
|
|
user.user_option.update!(email_level: UserOption.email_level_types[:always])
|
2019-03-12 09:39:16 +08:00
|
|
|
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_replied,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: user.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.first.to).to contain_exactly(
|
|
|
|
user.email
|
|
|
|
)
|
|
|
|
end
|
2016-08-04 00:29:38 +08:00
|
|
|
end
|
|
|
|
|
2017-05-03 16:03:43 +08:00
|
|
|
context 'max_emails_per_day_per_user limit is reached' do
|
|
|
|
before do
|
|
|
|
SiteSetting.max_emails_per_day_per_user = 2
|
2017-05-03 20:14:32 +08:00
|
|
|
2.times { Fabricate(:email_log, user: user, email_type: 'blah', to_address: user.email) }
|
2017-05-03 16:03:43 +08:00
|
|
|
end
|
2016-03-23 12:08:34 +08:00
|
|
|
|
2017-05-03 16:03:43 +08:00
|
|
|
it "does not send notification if limit is reached" do
|
2018-07-24 12:55:43 +08:00
|
|
|
expect do
|
2018-08-21 11:14:43 +08:00
|
|
|
2.times do
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
post_id: post.id
|
|
|
|
)
|
|
|
|
end
|
2018-07-24 12:55:43 +08:00
|
|
|
end.to change { SkippedEmailLog.count }.by(1)
|
|
|
|
|
|
|
|
expect(SkippedEmailLog.exists?(
|
|
|
|
email_type: "user_mentioned",
|
|
|
|
user: user,
|
|
|
|
post: post,
|
|
|
|
to_address: user.email,
|
|
|
|
reason_type: SkippedEmailLog.reason_types[:exceeded_emails_limit]
|
|
|
|
)).to eq(true)
|
2018-08-21 11:14:43 +08:00
|
|
|
|
|
|
|
freeze_time(Time.zone.now.tomorrow + 1.second)
|
|
|
|
|
|
|
|
expect do
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
post_id: post.id
|
|
|
|
)
|
2022-07-19 22:03:03 +08:00
|
|
|
end.not_to change { SkippedEmailLog.count }
|
2017-05-03 16:03:43 +08:00
|
|
|
end
|
2016-03-23 12:08:34 +08:00
|
|
|
|
2017-05-03 19:36:01 +08:00
|
|
|
it "sends critical email" do
|
2018-07-24 12:55:43 +08:00
|
|
|
expect do
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :forgot_password,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
)
|
|
|
|
end.to change { EmailLog.count }.by(1)
|
|
|
|
|
|
|
|
expect(EmailLog.exists?(
|
|
|
|
email_type: "forgot_password",
|
|
|
|
user: user,
|
|
|
|
)).to eq(true)
|
2017-05-03 16:03:43 +08:00
|
|
|
end
|
2016-03-23 12:08:34 +08:00
|
|
|
end
|
|
|
|
|
2018-08-28 15:01:44 +08:00
|
|
|
it "erodes bounce score each time an email is sent" do
|
|
|
|
SiteSetting.bounce_score_erode_on_send = 0.2
|
|
|
|
|
|
|
|
user.user_stat.update(bounce_score: 2.7)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
post_id: post.id
|
|
|
|
)
|
|
|
|
|
|
|
|
user.user_stat.reload
|
|
|
|
expect(user.user_stat.bounce_score).to eq(2.5)
|
|
|
|
|
|
|
|
user.user_stat.update(bounce_score: 0)
|
|
|
|
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
post_id: post.id
|
|
|
|
)
|
|
|
|
|
|
|
|
user.user_stat.reload
|
|
|
|
expect(user.user_stat.bounce_score).to eq(0)
|
|
|
|
end
|
|
|
|
|
2016-05-03 05:15:32 +08:00
|
|
|
it "does not send notification if bounce threshold is reached" do
|
|
|
|
user.user_stat.update(bounce_score: SiteSetting.bounce_score_threshold)
|
2018-07-24 12:55:43 +08:00
|
|
|
|
|
|
|
expect do
|
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_mentioned,
|
|
|
|
user_id: user.id,
|
|
|
|
notification_id: notification.id,
|
|
|
|
post_id: post.id
|
|
|
|
)
|
|
|
|
end.to change { SkippedEmailLog.count }.by(1)
|
|
|
|
|
|
|
|
expect(SkippedEmailLog.exists?(
|
|
|
|
email_type: "user_mentioned",
|
|
|
|
user: user,
|
|
|
|
post: post,
|
|
|
|
to_address: user.email,
|
|
|
|
reason_type: SkippedEmailLog.reason_types[:exceeded_bounces_limit]
|
|
|
|
)).to eq(true)
|
2016-05-03 05:15:32 +08:00
|
|
|
end
|
|
|
|
|
2016-08-04 00:29:38 +08:00
|
|
|
it "doesn't send the mail if the user is using individual mailing list mode" do
|
2021-03-17 23:39:10 +08:00
|
|
|
SiteSetting.disable_mailing_list_mode = false
|
|
|
|
|
2016-08-04 00:29:38 +08:00
|
|
|
user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1)
|
2016-02-06 03:07:30 +08:00
|
|
|
# sometimes, we pass the notification_id
|
2016-02-04 02:27:58 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
2016-02-06 03:07:30 +08:00
|
|
|
# other times, we only pass the type of notification
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
2016-02-24 14:30:28 +08:00
|
|
|
# When post is nil
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted")
|
|
|
|
# When post does not have a topic
|
|
|
|
post = Fabricate(:post)
|
|
|
|
post.topic.destroy
|
2016-03-23 12:08:34 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2016-02-04 02:27:58 +08:00
|
|
|
end
|
|
|
|
|
2016-10-06 07:28:58 +08:00
|
|
|
it "doesn't send the mail if the user is using individual mailing list mode with no echo" do
|
2021-03-17 23:39:10 +08:00
|
|
|
SiteSetting.disable_mailing_list_mode = false
|
|
|
|
|
2016-10-06 07:28:58 +08:00
|
|
|
user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 2)
|
|
|
|
# sometimes, we pass the notification_id
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
|
|
|
# other times, we only pass the type of notification
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
|
|
|
# When post is nil
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted")
|
|
|
|
# When post does not have a topic
|
|
|
|
post = Fabricate(:post)
|
|
|
|
post.topic.destroy
|
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_type: "posted", post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2016-10-06 07:28:58 +08:00
|
|
|
end
|
|
|
|
|
2013-06-11 00:02:04 +08:00
|
|
|
it "doesn't send the email if the post has been user deleted" do
|
|
|
|
post.update_column(:user_deleted, true)
|
2016-02-04 02:27:58 +08:00
|
|
|
Jobs::UserEmail.new.execute(type: :user_mentioned, user_id: user.id, notification_id: notification.id, post_id: post.id)
|
2019-03-12 09:39:16 +08:00
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2013-06-11 00:02:04 +08:00
|
|
|
end
|
|
|
|
|
2013-11-08 02:53:32 +08:00
|
|
|
context 'user is suspended' do
|
2013-10-31 03:31:16 +08:00
|
|
|
it "doesn't send email for a pm from a regular user" do
|
2016-01-27 09:19:49 +08:00
|
|
|
msg, err = Jobs::UserEmail.new.message_for_email(
|
|
|
|
suspended,
|
|
|
|
Fabricate.build(:post),
|
|
|
|
:user_private_message,
|
|
|
|
notification
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(msg).to eq(nil)
|
|
|
|
expect(err).not_to eq(nil)
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'pm from staff' do
|
|
|
|
before do
|
|
|
|
@pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
2013-11-08 02:53:32 +08:00
|
|
|
@pm_from_staff.topic.topic_allowed_users.create!(user_id: suspended.id)
|
2014-02-04 09:56:28 +08:00
|
|
|
@pm_notification = Fabricate(:notification,
|
|
|
|
user: suspended,
|
|
|
|
topic: @pm_from_staff.topic,
|
|
|
|
post_number: @pm_from_staff.post_number,
|
|
|
|
data: { original_post_id: @pm_from_staff.id }.to_json
|
|
|
|
)
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
|
|
|
|
2016-01-27 09:19:49 +08:00
|
|
|
let :sent_message do
|
|
|
|
Jobs::UserEmail.new.message_for_email(
|
|
|
|
suspended,
|
|
|
|
@pm_from_staff,
|
|
|
|
:user_private_message,
|
|
|
|
@pm_notification
|
|
|
|
)
|
|
|
|
end
|
2013-10-31 03:31:16 +08:00
|
|
|
|
|
|
|
it "sends an email" do
|
2016-01-27 09:19:49 +08:00
|
|
|
msg, err = sent_message
|
|
|
|
expect(msg).not_to be(nil)
|
|
|
|
expect(err).to be(nil)
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "sends an email even if user was last seen recently" do
|
2013-11-08 02:53:32 +08:00
|
|
|
suspended.update_column(:last_seen_at, 1.minute.ago)
|
2016-01-27 09:19:49 +08:00
|
|
|
|
|
|
|
msg, err = sent_message
|
|
|
|
expect(msg).not_to be(nil)
|
|
|
|
expect(err).to be(nil)
|
2013-10-31 03:31:16 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-05-11 07:10:10 +08:00
|
|
|
|
|
|
|
context 'user is anonymous' do
|
2017-07-07 14:09:14 +08:00
|
|
|
before { SiteSetting.allow_anonymous_posting = true }
|
2015-05-11 07:10:10 +08:00
|
|
|
|
|
|
|
it "doesn't send email for a pm from a regular user" do
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: anonymous.id,
|
|
|
|
post_id: post.id,
|
|
|
|
notification_id: notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2015-05-11 07:10:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't send email for a pm from staff" do
|
|
|
|
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
|
|
|
pm_from_staff.topic.topic_allowed_users.create!(user_id: anonymous.id)
|
|
|
|
pm_notification = Fabricate(:notification,
|
|
|
|
user: anonymous,
|
|
|
|
topic: pm_from_staff.topic,
|
|
|
|
post_number: pm_from_staff.post_number,
|
|
|
|
data: { original_post_id: pm_from_staff.id }.to_json
|
|
|
|
)
|
2019-03-12 10:33:24 +08:00
|
|
|
Jobs::UserEmail.new.execute(
|
|
|
|
type: :user_private_message,
|
2019-03-12 09:39:16 +08:00
|
|
|
user_id: anonymous.id,
|
|
|
|
post_id: pm_from_staff.id,
|
|
|
|
notification_id: pm_notification.id
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries).to eq([])
|
2015-05-11 07:10:10 +08:00
|
|
|
end
|
|
|
|
end
|
2013-02-26 00:42:20 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|