Non-staff users may not delete their posts in archived topics.
This commit is contained in:
parent
55397361be
commit
8c29ed870e
|
@ -77,6 +77,9 @@ module PostGuardain
|
|||
# Can't delete after post_edit_time_limit minutes have passed
|
||||
return false if !is_staff? && post.edit_time_limit_expired?
|
||||
|
||||
# Can't delete posts in archived topics unless you are staff
|
||||
return false if !is_staff? && post.topic.archived?
|
||||
|
||||
# You can delete your own posts
|
||||
return !post.user_deleted? if is_my_own?(post)
|
||||
|
||||
|
@ -107,4 +110,4 @@ module PostGuardain
|
|||
def can_vote?(post, opts={})
|
||||
post_can_act?(post,:vote, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -833,6 +833,22 @@ describe Guardian do
|
|||
Guardian.new(coding_horror).can_delete?(old_post).should eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'the topic is archived' do
|
||||
before do
|
||||
post.topic.archived = true
|
||||
end
|
||||
|
||||
it "allows a staff member to delete it" do
|
||||
Guardian.new(moderator).can_delete?(post).should be_true
|
||||
end
|
||||
|
||||
it "doesn't allow a regular user to delete it" do
|
||||
Guardian.new(post.user).can_delete?(post).should be_false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'a Category' do
|
||||
|
|
Loading…
Reference in New Issue