revert e7b3fae215
This commit is contained in:
@@ -95,10 +95,12 @@ class PostFlag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def validate_creator_is_not_limited
|
def validate_creator_is_not_limited
|
||||||
if creator.created_at > 1.week.ago
|
if CurrentUser.can_approve_posts?
|
||||||
|
# do nothing
|
||||||
|
elsif creator.created_at > 1.week.ago
|
||||||
errors[:creator] << "cannot flag within the first week of sign up"
|
errors[:creator] << "cannot flag within the first week of sign up"
|
||||||
elsif creator.is_gold? && flag_count_for_creator >= 5
|
elsif creator.is_gold? && flag_count_for_creator >= 10
|
||||||
errors[:creator] << "can flag 5 posts a day"
|
errors[:creator] << "can flag 10 posts a day"
|
||||||
elsif !creator.is_gold? && flag_count_for_creator >= 1
|
elsif !creator.is_gold? && flag_count_for_creator >= 1
|
||||||
errors[:creator] << "can flag 1 post a day"
|
errors[:creator] << "can flag 1 post a day"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ class PostFlagTest < ActiveSupport::TestCase
|
|||||||
assert_equal(["You have already flagged this post"], @post_flag.errors.full_messages)
|
assert_equal(["You have already flagged this post"], @post_flag.errors.full_messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not be able to flag more than 5 posts in 24 hours" do
|
should "not be able to flag more than 10 posts in 24 hours" do
|
||||||
@post_flag = PostFlag.new(:post => @post, :reason => "aaa", :is_resolved => false)
|
@post_flag = PostFlag.new(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||||
@post_flag.expects(:flag_count_for_creator).returns(5)
|
@post_flag.expects(:flag_count_for_creator).returns(10)
|
||||||
assert_difference("PostFlag.count", 0) do
|
assert_difference("PostFlag.count", 0) do
|
||||||
@post_flag.save
|
@post_flag.save
|
||||||
end
|
end
|
||||||
assert_equal(["You can flag 5 posts a day"], @post_flag.errors.full_messages)
|
assert_equal(["You can flag 10 posts a day"], @post_flag.errors.full_messages)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not be able to flag a deleted post" do
|
should "not be able to flag a deleted post" do
|
||||||
|
|||||||
Reference in New Issue
Block a user