From 0c019b2e45787b9062605904e4a9dff07b4f2331 Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:01:20 -0300 Subject: [PATCH] FIX: Error when moving the group default notification state (#28910) --- .../app/templates/group/manage/tags.hbs | 10 +++++----- app/models/group_tag_notification_default.rb | 11 ++++++++--- spec/models/group_spec.rb | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/app/templates/group/manage/tags.hbs b/app/assets/javascripts/discourse/app/templates/group/manage/tags.hbs index caebf64bd86..5635b458422 100644 --- a/app/assets/javascripts/discourse/app/templates/group/manage/tags.hbs +++ b/app/assets/javascripts/discourse/app/templates/group/manage/tags.hbs @@ -19,7 +19,7 @@ 0 end changed diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index fafaf1b328c..27fd72e427d 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -1380,6 +1380,24 @@ RSpec.describe Group do expect(GroupTagNotificationDefault.lookup(group, :watching)).to be_empty end + it "can change the notification level for a tag" do + GroupTagNotificationDefault.create!( + group: group, + tag: tag1, + notification_level: GroupTagNotificationDefault.notification_levels[:watching], + ) + + group.watching_tags = [tag1.name] + group.save! + expect(GroupTagNotificationDefault.lookup(group, :watching).pluck(:tag_id)).to eq([tag1.id]) + + group.watching_tags = [] + group.tracking_tags = [tag1.name] + group.save! + expect(GroupTagNotificationDefault.lookup(group, :watching)).to be_empty + expect(GroupTagNotificationDefault.lookup(group, :tracking).pluck(:tag_id)).to eq([tag1.id]) + end + it "can apply default notifications for admins group" do group = Group.find(Group::AUTO_GROUPS[:admins]) group.tracking_category_ids = [category1.id]