flags: disallow flagging pending posts.

This commit is contained in:
evazion
2017-05-19 14:37:38 -05:00
parent a4220854a3
commit 2259506bc2
3 changed files with 22 additions and 0 deletions

View File

@@ -64,6 +64,13 @@ class PostFlagTest < ActiveSupport::TestCase
assert_equal(["Post is deleted"], @post_flag.errors.full_messages)
end
should "not be able to flag a pending post" do
@post.update_columns(is_pending: true)
@flag = @post.flags.create(reason: "test")
assert_equal(["Post is pending and cannot be flagged"], @flag.errors.full_messages)
end
should "not be able to flag a post in the cooldown period" do
users = FactoryGirl.create_list(:user, 2, created_at: 2.weeks.ago)
flag1 = FactoryGirl.create(:post_flag, post: @post, creator: users.first)