flags: adjust limit to 5 flags at once.
This commit is contained in:
@@ -356,7 +356,7 @@ class User < ApplicationRecord
|
|||||||
|
|
||||||
def is_flag_limited?
|
def is_flag_limited?
|
||||||
return false if has_unlimited_flags?
|
return false if has_unlimited_flags?
|
||||||
post_flags.pending.count >= 10
|
post_flags.pending.count >= 5
|
||||||
end
|
end
|
||||||
|
|
||||||
# Flags are unlimited if you're an approver or you have at least 30 flags
|
# Flags are unlimited if you're an approver or you have at least 30 flags
|
||||||
|
|||||||
@@ -21,15 +21,15 @@ class PostFlagTest < ActiveSupport::TestCase
|
|||||||
assert_equal(false, @user.is_flag_limited?)
|
assert_equal(false, @user.is_flag_limited?)
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
create_list(:post_flag, 11, creator: @user, status: :pending)
|
create_list(:post_flag, 6, creator: @user, status: :pending)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "a basic user" do
|
context "a basic user" do
|
||||||
should "be able to flag up to 10 posts" do
|
should "be able to flag up to 5 posts" do
|
||||||
@user = create(:user)
|
@user = create(:user)
|
||||||
@flags = create_list(:post_flag, 10, creator: @user, status: :pending)
|
@flags = create_list(:post_flag, 5, creator: @user, status: :pending)
|
||||||
@flag = build(:post_flag, creator: @user, status: :pending)
|
@flag = build(:post_flag, creator: @user, status: :pending)
|
||||||
|
|
||||||
assert_equal(false, @flag.valid?)
|
assert_equal(false, @flag.valid?)
|
||||||
|
|||||||
Reference in New Issue
Block a user