diff --git a/lib/guardian.rb b/lib/guardian.rb index 4488b395ab1..936f4ba3473 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -210,7 +210,7 @@ class Guardian end def can_delete_all_posts?(user) - return false unless is_admin? + return false unless is_staff? return false if user.created_at < 7.days.ago true diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 5ba314e1d68..c5a2515b011 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -9,8 +9,8 @@ class PostDestroyer end def destroy - if @user.moderator? - moderator_destroyed + if @user.staff? + staff_destroyed elsif @user.id == @post.user_id user_destroyed end @@ -18,7 +18,7 @@ class PostDestroyer # When a post is properly deleted. Well, it's still soft deleted, but it will no longer # show up in the topic - def moderator_destroyed + def staff_destroyed Post.transaction do # Update the last post id to the previous post if it exists @@ -65,4 +65,4 @@ class PostDestroyer end end -end \ No newline at end of file +end diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rb index a22f92d8766..668806ac98d 100644 --- a/spec/components/post_destroyer_spec.rb +++ b/spec/components/post_destroyer_spec.rb @@ -9,6 +9,7 @@ describe PostDestroyer do describe 'basic destroying' do let(:moderator) { Fabricate(:moderator) } + let(:admin) { Fabricate(:admin) } context "as the creator of the post" do before do @@ -38,6 +39,16 @@ describe PostDestroyer do post.deleted_at.should be_present end end + + context "as an admin" do + before do + PostDestroyer.new(admin, post).destroy + end + + it "deletes the post" do + post.deleted_at.should be_present + end + end end