mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Convert min_trust_level_to_tag_topics to groups (#25258)
We're changing the implementation of trust levels to use groups. Part of this is to have site settings that reference trust levels use groups instead. It converts the min_trust_level_to_tag_topics site setting to tag_topic_allowed_groups.
This commit is contained in:
@@ -2057,6 +2057,7 @@ RSpec.describe PostAlerter do
|
||||
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.tag_topic_allowed_groups = Group::AUTO_GROUPS[:trust_level_0]
|
||||
Jobs.run_immediately!
|
||||
TagUser.change(user.id, watched_tag.id, TagUser.notification_levels[:watching_first_post])
|
||||
TopicUser.change(
|
||||
@@ -2075,7 +2076,10 @@ RSpec.describe PostAlerter do
|
||||
).to eq(0)
|
||||
|
||||
expect {
|
||||
PostRevisor.new(post).revise!(Fabricate(:user), tags: [other_tag.name, watched_tag.name])
|
||||
PostRevisor.new(post).revise!(
|
||||
Fabricate(:user, refresh_auto_groups: true),
|
||||
tags: [other_tag.name, watched_tag.name],
|
||||
)
|
||||
}.to change { Notification.where(user_id: user.id).count }.by(1)
|
||||
expect(
|
||||
user
|
||||
@@ -2085,7 +2089,10 @@ RSpec.describe PostAlerter do
|
||||
).to eq(1)
|
||||
|
||||
expect {
|
||||
PostRevisor.new(post).revise!(Fabricate(:user), tags: [watched_tag.name, other_tag.name])
|
||||
PostRevisor.new(post).revise!(
|
||||
Fabricate(:user, refresh_auto_groups: true),
|
||||
tags: [watched_tag.name, other_tag.name],
|
||||
)
|
||||
}.not_to change { Notification.count }
|
||||
expect(
|
||||
user
|
||||
@@ -2149,11 +2156,26 @@ RSpec.describe PostAlerter do
|
||||
end
|
||||
|
||||
it "only notifies staff watching added tag" do
|
||||
expect(PostRevisor.new(post).revise!(Fabricate(:admin), tags: [other_tag.name])).to be true
|
||||
expect(
|
||||
PostRevisor.new(post).revise!(
|
||||
Fabricate(:admin, refresh_auto_groups: true),
|
||||
tags: [other_tag.name],
|
||||
),
|
||||
).to be true
|
||||
expect(Notification.where(user_id: staged.id).count).to eq(0)
|
||||
expect(PostRevisor.new(post).revise!(Fabricate(:admin), tags: [other_tag2.name])).to be true
|
||||
expect(
|
||||
PostRevisor.new(post).revise!(
|
||||
Fabricate(:admin, refresh_auto_groups: true),
|
||||
tags: [other_tag2.name],
|
||||
),
|
||||
).to be true
|
||||
expect(Notification.where(user_id: admin.id).count).to eq(0)
|
||||
expect(PostRevisor.new(post).revise!(Fabricate(:admin), tags: [other_tag3.name])).to be true
|
||||
expect(
|
||||
PostRevisor.new(post).revise!(
|
||||
Fabricate(:admin, refresh_auto_groups: true),
|
||||
tags: [other_tag3.name],
|
||||
),
|
||||
).to be true
|
||||
expect(Notification.where(user_id: admin.id).count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user