FIX: Don't set notification level to `watching` when already watching.
This commit is contained in:
parent
7663268584
commit
ed1f942c52
|
@ -149,13 +149,20 @@ SQL
|
|||
|
||||
publish_topic_tracking_state(@topic, assign_to.id)
|
||||
|
||||
TopicUser.change(
|
||||
assign_to.id,
|
||||
@topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching],
|
||||
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed]
|
||||
if !TopicUser.exists?(
|
||||
user_id: assign_to.id,
|
||||
topic_id: @topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching]
|
||||
)
|
||||
|
||||
TopicUser.change(
|
||||
assign_to.id,
|
||||
@topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching],
|
||||
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed]
|
||||
)
|
||||
end
|
||||
|
||||
if SiteSetting.assign_mailer_enabled
|
||||
if !@topic.muted?(assign_to)
|
||||
message = AssignMailer.send_assignment(assign_to.email, @topic, @assigned_by)
|
||||
|
|
|
@ -49,6 +49,16 @@ RSpec.describe TopicAssigner do
|
|||
.to eq(TopicUser.notification_levels[:tracking])
|
||||
end
|
||||
|
||||
it 'does not update notification level if already watching' do
|
||||
TopicUser.change(moderator.id, topic.id,
|
||||
notification_level: TopicUser.notification_levels[:watching]
|
||||
)
|
||||
|
||||
expect do
|
||||
assigner.assign(moderator)
|
||||
end.to_not change { TopicUser.last.notifications_reason_id }
|
||||
end
|
||||
|
||||
it 'does not update notification level if it is not set by the plugin' do
|
||||
assigner.assign(moderator)
|
||||
|
||||
|
|
Loading…
Reference in New Issue