mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Don't let users edit wiki posts unless they can reply
This commit is contained in:
@ -106,7 +106,7 @@ module PostGuardian
|
|||||||
end
|
end
|
||||||
|
|
||||||
if post.wiki && (@user.trust_level >= SiteSetting.min_trust_to_edit_wiki_post.to_i)
|
if post.wiki && (@user.trust_level >= SiteSetting.min_trust_to_edit_wiki_post.to_i)
|
||||||
return true
|
return can_create_post?(post.topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user.trust_level < SiteSetting.min_trust_to_edit_post
|
if @user.trust_level < SiteSetting.min_trust_to_edit_post
|
||||||
|
@ -1050,6 +1050,19 @@ describe Guardian do
|
|||||||
expect(Guardian.new(coding_horror).can_edit?(post)).to be_truthy
|
expect(Guardian.new(coding_horror).can_edit?(post)).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns false if a wiki but the user can't create a post" do
|
||||||
|
c = Fabricate(:category)
|
||||||
|
c.set_permissions(:everyone => :readonly)
|
||||||
|
c.save
|
||||||
|
|
||||||
|
topic = Fabricate(:topic, category: c)
|
||||||
|
post = Fabricate(:post, topic: topic)
|
||||||
|
post.wiki = true
|
||||||
|
|
||||||
|
user = Fabricate(:user)
|
||||||
|
expect(Guardian.new(user).can_edit?(post)).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns true as a moderator' do
|
it 'returns true as a moderator' do
|
||||||
expect(Guardian.new(moderator).can_edit?(post)).to be_truthy
|
expect(Guardian.new(moderator).can_edit?(post)).to be_truthy
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user