Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensures tag notification level is changed (#21106)

Joffrey JAFFEUX2535381f440e
diff --git a/app/assets/javascripts/discourse/app/controllers/tag-show.js b/app/assets/javascripts/discourse/app/controllers/tag-show.js
index cc32873bbc8..48a3964fec9 100644
--- a/app/assets/javascripts/discourse/app/controllers/tag-show.js
+++ b/app/assets/javascripts/discourse/app/controllers/tag-show.js
@@ -184,6 +184,8 @@ export default DiscoverySortableController.extend(
.then((response) => {
const payload = response.responseJson;
+ this.tagNotification.set("notification_level", notificationLevel);
+
this.currentUser.setProperties({
watched_tags: payload.watched_tags,
watching_first_post_tags: payload.watching_first_post_tags,
diff --git a/spec/system/page_objects/components/select_kit.rb b/spec/system/page_objects/components/select_kit.rb
index 7bbdc4f7937..05786ac44c4 100644
--- a/spec/system/page_objects/components/select_kit.rb
+++ b/spec/system/page_objects/components/select_kit.rb
@@ -37,6 +37,11 @@ module PageObjects
expand
element.find(".select-kit-row[data-value='#{value}']").click
end
+
+ def select_row_by_name(name)
+ expand
+ element.find(".select-kit-row[data-name='#{name}']").click
+ end
end
end
end
diff --git a/spec/system/tag_notification_level_spec.rb b/spec/system/tag_notification_level_spec.rb
new file mode 100644
index 00000000000..7ec02905ff0
--- /dev/null
+++ b/spec/system/tag_notification_level_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+describe "Tag notification level", type: :system, js: true do
+ let(:tags_page) { PageObjects::Pages::Tag.new }
+ let(:select_kit) do
+ PageObjects::Components::SelectKit.new(page.find(".tag-notifications-button"))
+ end
+
+ fab!(:tag_1) { Fabricate(:tag) }
+ fab!(:current_user) { Fabricate(:admin) }
+
+ before { sign_in(current_user) }
+
+ describe "when changing a tag's notification level" do
+ it "should change instantly" do
+ tags_page.visit_tag(tag_1)
+ expect(select_kit).to have_selected_name("regular")
+
+ select_kit.select_row_by_name("watching")
+
+ expect(select_kit).to have_selected_name("watching")
+ end
+ end
+end