mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 08:35:20 +08:00
add specs for min_trust_to_create_tag set to staff and admin
This commit is contained in:
parent
eabc8f7fbd
commit
211981ef23
@ -2624,37 +2624,72 @@ describe Guardian do
|
||||
context "tagging is enabled" do
|
||||
before do
|
||||
SiteSetting.tagging_enabled = true
|
||||
SiteSetting.min_trust_to_create_tag = 3
|
||||
SiteSetting.min_trust_level_to_tag_topics = 1
|
||||
end
|
||||
|
||||
describe "can_create_tag" do
|
||||
it "returns false if trust level is too low" do
|
||||
expect(Guardian.new(trust_level_2).can_create_tag?).to be_falsey
|
||||
context 'min_trust_to_create_tag is 3' do
|
||||
before do
|
||||
SiteSetting.min_trust_to_create_tag = 3
|
||||
end
|
||||
|
||||
it "returns true if trust level is high enough" do
|
||||
expect(Guardian.new(trust_level_3).can_create_tag?).to be_truthy
|
||||
describe "can_create_tag" do
|
||||
it "returns false if trust level is too low" do
|
||||
expect(Guardian.new(trust_level_2).can_create_tag?).to be_falsey
|
||||
end
|
||||
|
||||
it "returns true if trust level is high enough" do
|
||||
expect(Guardian.new(trust_level_3).can_create_tag?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true for staff" do
|
||||
expect(Guardian.new(admin).can_create_tag?).to be_truthy
|
||||
expect(Guardian.new(moderator).can_create_tag?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
it "returns true for staff" do
|
||||
describe "can_tag_topics" do
|
||||
it "returns false if trust level is too low" do
|
||||
expect(Guardian.new(Fabricate(:user, trust_level: 0)).can_tag_topics?).to be_falsey
|
||||
end
|
||||
|
||||
it "returns true if trust level is high enough" do
|
||||
expect(Guardian.new(Fabricate(:user, trust_level: 1)).can_tag_topics?).to be_truthy
|
||||
end
|
||||
|
||||
it "returns true for staff" do
|
||||
expect(Guardian.new(admin).can_tag_topics?).to be_truthy
|
||||
expect(Guardian.new(moderator).can_tag_topics?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'min_trust_to_create_tag is "staff"' do
|
||||
before do
|
||||
SiteSetting.min_trust_to_create_tag = 'staff'
|
||||
end
|
||||
|
||||
it "returns false if not staff" do
|
||||
expect(Guardian.new(trust_level_4).can_create_tag?).to eq(false)
|
||||
end
|
||||
|
||||
it "returns true if staff" do
|
||||
expect(Guardian.new(admin).can_create_tag?).to be_truthy
|
||||
expect(Guardian.new(moderator).can_create_tag?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe "can_tag_topics" do
|
||||
it "returns false if trust level is too low" do
|
||||
expect(Guardian.new(Fabricate(:user, trust_level: 0)).can_tag_topics?).to be_falsey
|
||||
context 'min_trust_to_create_tag is "admin"' do
|
||||
before do
|
||||
SiteSetting.min_trust_to_create_tag = 'admin'
|
||||
end
|
||||
|
||||
it "returns true if trust level is high enough" do
|
||||
expect(Guardian.new(Fabricate(:user, trust_level: 1)).can_tag_topics?).to be_truthy
|
||||
it "returns false if not admin" do
|
||||
expect(Guardian.new(trust_level_4).can_create_tag?).to eq(false)
|
||||
expect(Guardian.new(moderator).can_create_tag?).to eq(false)
|
||||
end
|
||||
|
||||
it "returns true for staff" do
|
||||
expect(Guardian.new(admin).can_tag_topics?).to be_truthy
|
||||
expect(Guardian.new(moderator).can_tag_topics?).to be_truthy
|
||||
it "returns true if admin" do
|
||||
expect(Guardian.new(admin).can_create_tag?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user