fixes #2448: Approvers can undelete posts they already approved/uploaded

This commit is contained in:
r888888888
2015-07-24 14:19:40 -07:00
parent 9fb68cee94
commit abb232d4e6
3 changed files with 40 additions and 2 deletions

View File

@@ -301,6 +301,37 @@ class PostTest < ActiveSupport::TestCase
end
end
context "that is undeleted" do
setup do
@mod = FactoryGirl.create(:moderator_user)
CurrentUser.user = @mod
end
context "by the approver" do
setup do
@post.update_attribute(:approver_id, @mod.id)
end
should "not be permitted" do
assert_raises(::Post::ApprovalError) do
@post.undelete!
end
end
end
context "by the uploader" do
setup do
@post.update_attribute(:uploader_id, @mod.id)
end
should "not be permitted" do
assert_raises(::Post::ApprovalError) do
@post.undelete!
end
end
end
end
should "be undeleted" do
@post.undelete!
@post.reload