Give regular users a delete button. If they click it, their post will be revised to

say it was deleted.
This commit is contained in:
Robin Ward
2013-02-07 15:12:55 -05:00
parent af11547108
commit 084a873b91
16 changed files with 183 additions and 34 deletions

View File

@ -361,6 +361,26 @@ describe Guardian do
end
end
describe "can_recover_post?" do
it "returns false for a nil user" do
Guardian.new(nil).can_recover_post?(post).should be_false
end
it "returns false for a nil object" do
Guardian.new(user).can_recover_post?(nil).should be_false
end
it "returns false for a regular user" do
Guardian.new(user).can_recover_post?(post).should be_false
end
it "returns true for a moderator" do
Guardian.new(moderator).can_recover_post?(post).should be_true
end
end
describe 'can_edit?' do
it 'returns false with a nil object' do
@ -576,10 +596,20 @@ describe Guardian do
Guardian.new.can_delete?(post).should be_false
end
it 'returns false when not a moderator' do
it "returns false when trying to delete your own post that has already been deleted" do
post.delete_by(user)
post.reload
Guardian.new(user).can_delete?(post).should be_false
end
it 'returns true when trying to delete your own post' do
Guardian.new(user).can_delete?(post).should be_true
end
it "returns false when trying to delete another user's own post" do
Guardian.new(Fabricate(:user)).can_delete?(post).should be_false
end
it "returns false when it's the OP, even as a moderator" do
post.update_attribute :post_number, 1
Guardian.new(moderator).can_delete?(post).should be_false