FIX: Don't let users edit wiki posts unless they can reply

This commit is contained in:
Robin Ward
2017-05-08 16:23:11 -04:00
parent 009e120e13
commit addc85cd08
2 changed files with 14 additions and 1 deletions

View File

@ -1050,6 +1050,19 @@ describe Guardian do
expect(Guardian.new(coding_horror).can_edit?(post)).to be_truthy
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
expect(Guardian.new(moderator).can_edit?(post)).to be_truthy
end