mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 17:40:43 +08:00
FIX: only admin can edit faq, tos, and privacy policy
This commit is contained in:
@ -354,6 +354,15 @@ describe Guardian do
|
||||
Guardian.new(moderator).can_see?(private_topic).should be_false
|
||||
Guardian.new(admin).can_see?(private_topic).should be_true
|
||||
end
|
||||
|
||||
it "restricts static doc topics" do
|
||||
tos_topic = Fabricate(:topic, user: Discourse.system_user)
|
||||
SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id)
|
||||
|
||||
Guardian.new(build(:user)).can_edit?(tos_topic).should be_false
|
||||
Guardian.new(moderator).can_edit?(tos_topic).should be_false
|
||||
Guardian.new(admin).can_edit?(tos_topic).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'a Post' do
|
||||
@ -784,6 +793,18 @@ describe Guardian do
|
||||
Guardian.new(post.user).can_edit?(post).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
context "first post of a static page doc" do
|
||||
let!(:tos_topic) { Fabricate(:topic, user: Discourse.system_user) }
|
||||
let!(:tos_first_post) { build(:post, topic: tos_topic, user: tos_topic.user) }
|
||||
before { SiteSetting.stubs(:tos_topic_id).returns(tos_topic.id) }
|
||||
|
||||
it "restricts static doc posts" do
|
||||
Guardian.new(build(:user)).can_edit?(tos_first_post).should be_false
|
||||
Guardian.new(moderator).can_edit?(tos_first_post).should be_false
|
||||
Guardian.new(admin).can_edit?(tos_first_post).should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'a Topic' do
|
||||
|
Reference in New Issue
Block a user