Skip to content

Commit

Permalink
UX: Don't change topic notification level when unassigning (#513)
Browse files Browse the repository at this point in the history
* UX: Don't change topic notification level when unassigning

* Update test
  • Loading branch information
nattsw authored Oct 16, 2023
1 parent 2185513 commit e434be7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
16 changes: 0 additions & 16 deletions lib/assigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,22 +372,6 @@ def unassign(silent: false, deactivate: false)
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
Expand Down
12 changes: 3 additions & 9 deletions spec/lib/assigner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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

Expand Down Expand Up @@ -122,23 +122,17 @@
}
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

Expand Down

0 comments on commit e434be7

Please sign in to comment.