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

@ -505,6 +505,48 @@ describe Post do
end
describe 'delete_by' do
let(:moderator) { Fabricate(:moderator) }
let(:post) { Fabricate(:post) }
context "as the creator of the post" do
before do
post.delete_by(post.user)
post.reload
end
it "doesn't delete the post" do
post.deleted_at.should be_blank
end
it "updates the text of the post" do
post.raw.should == I18n.t('js.post.deleted_by_author')
end
it "creates a new version" do
post.version.should == 2
end
end
context "as a moderator" do
before do
post.delete_by(post.user)
post.reload
end
it "deletes the post" do
post.deleted_at.should be_blank
end
end
end
describe 'after delete' do
let!(:coding_horror) { Fabricate(:coding_horror) }
@ -550,6 +592,10 @@ describe Post do
let(:post) { Fabricate(:post, post_args) }
it "defaults to not user_deleted" do
post.user_deleted?.should be_false
end
it 'has a post nubmer' do
post.post_number.should be_present
end