UX: Don't change topic notification level when unassigning (#513)

* UX: Don't change topic notification level when unassigning

* Update test
This commit is contained in:
Natalie Tay 2023-10-16 12:41:44 +08:00 committed by GitHub
parent 2185513d96
commit e434be7969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 25 deletions

View File

@ -372,22 +372,6 @@ class ::Assigner
assigned_to_type: assignment.assigned_to_type,
)
if assignment.assigned_to_user?
if TopicUser.exists?(
user_id: assignment.assigned_to_id,
topic: topic,
notification_level: TopicUser.notification_levels[:watching],
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed],
)
TopicUser.change(
assignment.assigned_to_id,
topic.id,
notification_level: TopicUser.notification_levels[:tracking],
notifications_reason_id: TopicUser.notification_reasons[:plugin_changed],
)
end
end
assigned_to = assignment.assigned_to
if SiteSetting.unassign_creates_tracking_post && !silent

View File

@ -39,7 +39,7 @@ RSpec.describe Assigner do
expect(TopicQuery.new(moderator, assigned: moderator.username).list_latest.topics).to eq([])
expect(TopicUser.find_by(user: moderator).notification_level).to eq(
TopicUser.notification_levels[:tracking],
TopicUser.notification_levels[:watching],
)
end
@ -122,23 +122,17 @@ RSpec.describe Assigner do
}
end
it "does not update notification level if it is not set by the plugin" do
it "does not update notification level when unassigned" do
assigner.assign(moderator)
expect(TopicUser.find_by(user: moderator).notification_level).to eq(
TopicUser.notification_levels[:watching],
)
TopicUser.change(
moderator.id,
topic.id,
notification_level: TopicUser.notification_levels[:muted],
)
assigner.unassign
expect(TopicUser.find_by(user: moderator, topic: topic).notification_level).to eq(
TopicUser.notification_levels[:muted],
TopicUser.notification_levels[:watching],
)
end