Skip to content

Commit 4965b39

Browse files
committed
added test for flag rate-limiting
1 parent b7d4ffb commit 4965b39

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/controllers/flags_controller_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ class FlagsControllerTest < ActionController::TestCase
4040
assert_equal I18n.t('flags.errors.create_generic'), JSON.parse(response.body)['message']
4141
end
4242

43+
test 'should fail to create flags for rate-limited users' do
44+
{
45+
RL_NewUserFlags: users(:basic_user),
46+
RL_Flags: users(:standard_user)
47+
}.each_pair do |setting, user|
48+
sign_in(user)
49+
50+
SiteSetting[setting] = 0
51+
52+
try_create_flag(posts(:question_one), reason: 'testing flag rate limits')
53+
54+
assert_response(:forbidden)
55+
assert_equal 'failed', JSON.parse(response.body)['status']
56+
assert_equal I18n.t('flags.errors.rate_limited', count: 0), JSON.parse(response.body)['message']
57+
end
58+
end
59+
4360
test 'should retrieve flag queue' do
4461
sign_in users(:moderator)
4562
get :queue

0 commit comments

Comments
 (0)