new hidden 'allow_staged_accounts' setting
This commit is contained in:
parent
09bfe49254
commit
0d54c18c8b
|
@ -23,7 +23,7 @@ module Jobs
|
||||||
return if @user.staged && args[:type] == :digest
|
return if @user.staged && args[:type] == :digest
|
||||||
|
|
||||||
seen_recently = (@user.last_seen_at.present? && @user.last_seen_at > SiteSetting.email_time_window_mins.minutes.ago)
|
seen_recently = (@user.last_seen_at.present? && @user.last_seen_at > SiteSetting.email_time_window_mins.minutes.ago)
|
||||||
seen_recently = false if @user.email_always
|
seen_recently = false if @user.email_always || @user.staged
|
||||||
|
|
||||||
email_args = {}
|
email_args = {}
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ class UserNotifications < ActionMailer::Base
|
||||||
topic_id: post.topic_id,
|
topic_id: post.topic_id,
|
||||||
context: context,
|
context: context,
|
||||||
username: username,
|
username: username,
|
||||||
add_unsubscribe_link: true,
|
add_unsubscribe_link: !user.staged,
|
||||||
unsubscribe_url: post.topic.unsubscribe_url,
|
unsubscribe_url: post.topic.unsubscribe_url,
|
||||||
allow_reply_by_email: allow_reply_by_email,
|
allow_reply_by_email: allow_reply_by_email,
|
||||||
use_site_subject: use_site_subject,
|
use_site_subject: use_site_subject,
|
||||||
|
|
|
@ -39,7 +39,7 @@ class UserEmailObserver < ActiveRecord::Observer
|
||||||
private
|
private
|
||||||
|
|
||||||
def enqueue(type)
|
def enqueue(type)
|
||||||
return unless (notification.user.email_direct? && notification.user.active?)
|
return unless notification.user.email_direct? && (notification.user.active? || notification.user.staged?)
|
||||||
|
|
||||||
Jobs.enqueue_in(delay,
|
Jobs.enqueue_in(delay,
|
||||||
:user_email,
|
:user_email,
|
||||||
|
@ -49,7 +49,7 @@ class UserEmailObserver < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_private(type)
|
def enqueue_private(type)
|
||||||
return unless (notification.user.email_private_messages? && notification.user.active?)
|
return unless notification.user.email_private_messages? && (notification.user.active? || notification.user.staged?)
|
||||||
|
|
||||||
Jobs.enqueue_in(delay,
|
Jobs.enqueue_in(delay,
|
||||||
:user_email,
|
:user_email,
|
||||||
|
|
|
@ -224,10 +224,11 @@ class PostAlerter
|
||||||
exclude_user_ids << reply_to_user.id if reply_to_user.present?
|
exclude_user_ids << reply_to_user.id if reply_to_user.present?
|
||||||
exclude_user_ids.flatten!
|
exclude_user_ids.flatten!
|
||||||
|
|
||||||
TopicUser
|
TopicUser.where(topic_id: post.topic_id)
|
||||||
.where(topic_id: post.topic_id, notification_level: TopicUser.notification_levels[:watching])
|
.where(notification_level: TopicUser.notification_levels[:watching])
|
||||||
.includes(:user).each do |tu|
|
.where("user_id NOT IN (?)", exclude_user_ids)
|
||||||
create_notification(tu.user, Notification.types[:posted], post) unless exclude_user_ids.include?(tu.user_id)
|
.includes(:user).each do |tu|
|
||||||
|
create_notification(tu.user, Notification.types[:posted], post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -792,6 +792,9 @@ developer:
|
||||||
default: 500
|
default: 500
|
||||||
client: true
|
client: true
|
||||||
hidden: true
|
hidden: true
|
||||||
|
allow_staged_accounts:
|
||||||
|
default: false
|
||||||
|
hidden: true
|
||||||
|
|
||||||
embedding:
|
embedding:
|
||||||
feed_polling_enabled:
|
feed_polling_enabled:
|
||||||
|
|
|
@ -59,13 +59,17 @@ module Email
|
||||||
return unless html_override = @opts[:html_override]
|
return unless html_override = @opts[:html_override]
|
||||||
|
|
||||||
if @opts[:add_unsubscribe_link]
|
if @opts[:add_unsubscribe_link]
|
||||||
if response_instructions = @template_args[:respond_instructions]
|
|
||||||
respond_instructions = PrettyText.cook(response_instructions).html_safe
|
|
||||||
html_override.gsub!("%{respond_instructions}", respond_instructions)
|
|
||||||
end
|
|
||||||
|
|
||||||
unsubscribe_link = PrettyText.cook(I18n.t('unsubscribe_link', template_args)).html_safe
|
unsubscribe_link = PrettyText.cook(I18n.t('unsubscribe_link', template_args)).html_safe
|
||||||
html_override.gsub!("%{unsubscribe_link}", unsubscribe_link)
|
html_override.gsub!("%{unsubscribe_link}", unsubscribe_link)
|
||||||
|
else
|
||||||
|
html_override.gsub!("%{unsubscribe_link}", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
if response_instructions = @template_args[:respond_instructions]
|
||||||
|
respond_instructions = PrettyText.cook(response_instructions).html_safe
|
||||||
|
html_override.gsub!("%{respond_instructions}", respond_instructions)
|
||||||
|
else
|
||||||
|
html_override.gsub!("%{respond_instructions}", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
styled = Email::Styles.new(html_override, @opts)
|
styled = Email::Styles.new(html_override, @opts)
|
||||||
|
|
|
@ -58,12 +58,17 @@ module Email
|
||||||
|
|
||||||
user_email = @message.from.first
|
user_email = @message.from.first
|
||||||
@user = User.find_by_email(user_email)
|
@user = User.find_by_email(user_email)
|
||||||
if @user.blank? && @allow_strangers
|
|
||||||
|
|
||||||
wrap_body_in_quote user_email
|
# create staged account when user doesn't exist
|
||||||
# TODO This is WRONG it should register an account
|
if @user.blank? && @allow_strangers
|
||||||
# and email the user details on how to log in / activate
|
if SiteSetting.allow_staged_accounts
|
||||||
@user = Discourse.system_user
|
username = UserNameSuggester.suggest(user_email)
|
||||||
|
name = User.suggest_name(user_email)
|
||||||
|
@user = User.create(email: user_email, username: username, name: name, staged: true)
|
||||||
|
else
|
||||||
|
wrap_body_in_quote(user_email)
|
||||||
|
@user = Discourse.system_user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
raise UserNotFoundError if @user.blank?
|
raise UserNotFoundError if @user.blank?
|
||||||
|
@ -196,14 +201,12 @@ module Email
|
||||||
lines[range_start..range_end].join.strip
|
lines[range_start..range_end].join.strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrap_body_in_quote(user_email)
|
|
||||||
@body = "[quote=\"#{user_email}\"]
|
|
||||||
#{@body}
|
|
||||||
[/quote]"
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def wrap_body_in_quote(user_email)
|
||||||
|
@body = "[quote=\"#{user_email}\"]\n#{@body}\n[/quote]"
|
||||||
|
end
|
||||||
|
|
||||||
def create_reply
|
def create_reply
|
||||||
create_post_with_attachments(@email_log.user,
|
create_post_with_attachments(@email_log.user,
|
||||||
raw: @body,
|
raw: @body,
|
||||||
|
|
|
@ -69,7 +69,7 @@ class NewPostManager
|
||||||
def self.user_needs_approval?(manager)
|
def self.user_needs_approval?(manager)
|
||||||
user = manager.user
|
user = manager.user
|
||||||
|
|
||||||
return false if user.staff?
|
return false if user.staff? || user.staged
|
||||||
|
|
||||||
(user.post_count < SiteSetting.approve_post_count) ||
|
(user.post_count < SiteSetting.approve_post_count) ||
|
||||||
(user.trust_level < SiteSetting.approve_unless_trust_level.to_i) ||
|
(user.trust_level < SiteSetting.approve_unless_trust_level.to_i) ||
|
||||||
|
@ -105,7 +105,6 @@ class NewPostManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
|
||||||
# We never queue private messages
|
# We never queue private messages
|
||||||
return perform_create_post if @args[:archetype] == Archetype.private_message
|
return perform_create_post if @args[:archetype] == Archetype.private_message
|
||||||
if args[:topic_id] && Topic.where(id: args[:topic_id], archetype: Archetype.private_message).exists?
|
if args[:topic_id] && Topic.where(id: args[:topic_id], archetype: Archetype.private_message).exists?
|
||||||
|
@ -145,7 +144,6 @@ class NewPostManager
|
||||||
|
|
||||||
def perform_create_post
|
def perform_create_post
|
||||||
result = NewPostResult.new(:create_post)
|
result = NewPostResult.new(:create_post)
|
||||||
|
|
||||||
creator = PostCreator.new(@user, @args)
|
creator = PostCreator.new(@user, @args)
|
||||||
post = creator.create
|
post = creator.create
|
||||||
result.check_errors_from(creator)
|
result.check_errors_from(creator)
|
||||||
|
|
|
@ -7,8 +7,8 @@ class PostJobsEnqueuer
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_jobs
|
def enqueue_jobs
|
||||||
# We need to enqueue jobs after the transaction. Otherwise they might begin before the data has
|
# We need to enqueue jobs after the transaction.
|
||||||
# been comitted.
|
# Otherwise they might begin before the data has been comitted.
|
||||||
enqueue_post_alerts unless @opts[:import_mode]
|
enqueue_post_alerts unless @opts[:import_mode]
|
||||||
feature_topic_users unless @opts[:import_mode]
|
feature_topic_users unless @opts[:import_mode]
|
||||||
trigger_post_post_process
|
trigger_post_post_process
|
||||||
|
|
|
@ -604,7 +604,6 @@ greatest show ever created. Everyone should watch it.
|
||||||
SiteSetting.email_in = true
|
SiteSetting.email_in = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it "rejects anon email" do
|
it "rejects anon email" do
|
||||||
Fabricate(:category, email_in_allow_strangers: false, email_in: "bob@bob.com")
|
Fabricate(:category, email_in_allow_strangers: false, email_in: "bob@bob.com")
|
||||||
expect { process_email(from: "test@test.com", to: "bob@bob.com") }.to raise_error(Email::Receiver::UserNotFoundError)
|
expect { process_email(from: "test@test.com", to: "bob@bob.com") }.to raise_error(Email::Receiver::UserNotFoundError)
|
||||||
|
|
|
@ -3,184 +3,111 @@ require 'spec_helper'
|
||||||
describe UserEmailObserver do
|
describe UserEmailObserver do
|
||||||
|
|
||||||
# something is off with fabricator
|
# something is off with fabricator
|
||||||
def create_notification(type=nil, user=nil)
|
def create_notification(type, user=nil)
|
||||||
user ||= Fabricate(:user)
|
user ||= Fabricate(:user)
|
||||||
type ||= Notification.types[:mentioned]
|
|
||||||
Notification.create(data: '', user: user, notification_type: type)
|
Notification.create(data: '', user: user, notification_type: type)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user_mentioned' do
|
shared_examples "enqueue" do
|
||||||
let!(:notification) do
|
|
||||||
create_notification
|
|
||||||
end
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_mentioned, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: type, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueue a delayed job for users that are online" do
|
context "inactive user" do
|
||||||
notification.user.last_seen_at = 1.minute.ago
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_mentioned, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
before { notification.user.active = false }
|
||||||
notification.user.expects(:email_direct?).returns(false)
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_mentioned)).never
|
it "doesn't enqueue a job" do
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: type)).never
|
||||||
end
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "enqueues a job if the user is staged" do
|
||||||
|
notification.user.staged = true
|
||||||
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: type, user_id: notification.user_id, notification_id: notification.id)
|
||||||
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
notification.user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_mentioned)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'posted' do
|
shared_examples "enqueue_public" do
|
||||||
|
include_examples "enqueue"
|
||||||
|
|
||||||
let!(:notification) { create_notification(9) }
|
it "doesn't enqueue a job if the user has mention emails disabled" do
|
||||||
let(:user) { notification.user }
|
notification.user.expects(:email_direct?).returns(false)
|
||||||
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: type)).never
|
||||||
it "enqueues a job for the email" do
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_posted, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
shared_examples "enqueue_private" do
|
||||||
user.expects(:email_direct?).returns(false)
|
include_examples "enqueue"
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_posted)).never
|
|
||||||
|
it "doesn't enqueue a job if the user has private message emails disabled" do
|
||||||
|
notification.user.expects(:email_private_messages?).returns(false)
|
||||||
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: type)).never
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
context 'user_mentioned' do
|
||||||
user.active = false
|
let(:type) { :user_mentioned }
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_posted)).never
|
let!(:notification) { create_notification(1) }
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
|
|
||||||
|
it "enqueue a delayed job for users that are online" do
|
||||||
|
notification.user.last_seen_at = 1.minute.ago
|
||||||
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: type, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user_replied' do
|
context 'user_replied' do
|
||||||
|
let(:type) { :user_replied }
|
||||||
let!(:notification) { create_notification(2) }
|
let!(:notification) { create_notification(2) }
|
||||||
let(:user) { notification.user }
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_replied, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
|
||||||
user.expects(:email_direct?).returns(false)
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_replied)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_replied)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user_quoted' do
|
context 'user_quoted' do
|
||||||
|
let(:type) { :user_quoted }
|
||||||
let!(:notification) { create_notification(3) }
|
let!(:notification) { create_notification(3) }
|
||||||
let(:user) { notification.user }
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_quoted, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
|
||||||
user.expects(:email_direct?).returns(false)
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_quoted)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_quoted)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'email_user_invited_to_private_message' do
|
context 'user_posted' do
|
||||||
|
let(:type) { :user_posted }
|
||||||
let!(:notification) { create_notification(7) }
|
let!(:notification) { create_notification(9) }
|
||||||
let(:user) { notification.user }
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_invited_to_private_message, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
|
||||||
user.expects(:email_direct?).returns(false)
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_invited_to_private_message)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_invited_to_private_message)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'private_message' do
|
context 'user_private_message' do
|
||||||
|
let(:type) { :user_private_message }
|
||||||
let!(:notification) { create_notification(6) }
|
let!(:notification) { create_notification(6) }
|
||||||
let(:user) { notification.user }
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
include_examples "enqueue_private"
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_private_message, user_id: notification.user_id, notification_id: notification.id)
|
end
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has private message emails disabled" do
|
context 'user_invited_to_private_message' do
|
||||||
user.expects(:email_private_messages?).returns(false)
|
let(:type) { :user_invited_to_private_message }
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_private_message)).never
|
let!(:notification) { create_notification(7) }
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_private_message)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'user_invited_to_topic' do
|
context 'user_invited_to_topic' do
|
||||||
|
let(:type) { :user_invited_to_topic }
|
||||||
let!(:notification) { create_notification(13) }
|
let!(:notification) { create_notification(13) }
|
||||||
let(:user) { notification.user }
|
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_invited_to_topic, user_id: notification.user_id, notification_id: notification.id)
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
|
||||||
user.expects(:email_direct?).returns(false)
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_invited_to_topic)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user account is deactivated" do
|
|
||||||
user.active = false
|
|
||||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_invited_to_topic)).never
|
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
include_examples "enqueue_public"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue