mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: Convert min_trust_to_post_links to groups (#25298)
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_to_post_links site setting to post_links_allowed_groups. This isn't used by any of our plugins or themes, so very little fallout.
This commit is contained in:
@ -50,15 +50,15 @@ RSpec.describe Guardian do
|
||||
end
|
||||
|
||||
it "is none for a user of a low trust level" do
|
||||
user.trust_level = 0
|
||||
SiteSetting.min_trust_to_post_links = 1
|
||||
user.change_trust_level!(TrustLevel[0])
|
||||
SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:trust_level_1]
|
||||
expect(Guardian.new(user).link_posting_access).to eq("none")
|
||||
end
|
||||
|
||||
it "is limited for a user of a low trust level with a allowlist" do
|
||||
SiteSetting.allowed_link_domains = "example.com"
|
||||
user.trust_level = 0
|
||||
SiteSetting.min_trust_to_post_links = 1
|
||||
user.change_trust_level!(TrustLevel[0])
|
||||
SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:trust_level_1]
|
||||
expect(Guardian.new(user).link_posting_access).to eq("limited")
|
||||
end
|
||||
end
|
||||
@ -75,10 +75,10 @@ RSpec.describe Guardian do
|
||||
end
|
||||
|
||||
it "supports customization by site setting" do
|
||||
user.trust_level = 0
|
||||
SiteSetting.min_trust_to_post_links = 0
|
||||
user.change_trust_level!(TrustLevel[0])
|
||||
SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:trust_level_0]
|
||||
expect(Guardian.new(user).can_post_link?(host: host)).to eq(true)
|
||||
SiteSetting.min_trust_to_post_links = 1
|
||||
SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:trust_level_1]
|
||||
expect(Guardian.new(user).can_post_link?(host: host)).to eq(false)
|
||||
end
|
||||
|
||||
@ -86,8 +86,8 @@ RSpec.describe Guardian do
|
||||
before { SiteSetting.allowed_link_domains = host }
|
||||
|
||||
it "allows a new user to post the link to the host" do
|
||||
user.trust_level = 0
|
||||
SiteSetting.min_trust_to_post_links = 1
|
||||
user.change_trust_level!(TrustLevel[0])
|
||||
SiteSetting.post_links_allowed_groups = Group::AUTO_GROUPS[:trust_level_1]
|
||||
expect(Guardian.new(user).can_post_link?(host: host)).to eq(true)
|
||||
expect(Guardian.new(user).can_post_link?(host: "another-host.com")).to eq(false)
|
||||
end
|
||||
|
Reference in New Issue
Block a user