diff options
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 977879b453c..0b3bd4d78ac 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -1411,39 +1411,42 @@ RSpec.describe Projects::IssuesController do stub_application_setting(issues_create_limit: 5) end - it 'prevents from creating more issues', :request_store do - 5.times { post_new_issue } - - expect { post_new_issue } - .to change { Gitlab::GitalyClient.get_request_count }.by(1) # creates 1 projects and 0 issues - - post_new_issue - expect(response.body).to eq(_('This endpoint has been requested too many times. Try again later.')) - expect(response).to have_gitlab_http_status(:too_many_requests) - end - - it 'logs the event on auth.log' do - attributes = { - message: 'Application_Rate_Limiter_Request', - env: :issues_create_request_limit, - remote_ip: '0.0.0.0', - request_method: 'POST', - path: "/#{project.full_path}/-/issues", - user_id: user.id, - username: user.username - } + context 'when issue creation limits imposed' do + it 'prevents from creating more issues', :request_store do + 5.times { post_new_issue } - expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once + expect { post_new_issue } + .to change { Gitlab::GitalyClient.get_request_count }.by(1) # creates 1 projects and 0 issues - project.add_developer(user) - sign_in(user) + post_new_issue - 6.times do - post :create, params: { - namespace_id: project.namespace.to_param, - project_id: project, - issue: { title: 'Title', description: 'Description' } + expect(response.body).to eq(_('This endpoint has been requested too many times. Try again later.')) + expect(response).to have_gitlab_http_status(:too_many_requests) + end + + it 'logs the event on auth.log' do + attributes = { + message: 'Application_Rate_Limiter_Request', + env: :issues_create_request_limit, + remote_ip: '0.0.0.0', + request_method: 'POST', + path: "/#{project.full_path}/-/issues", + user_id: user.id, + username: user.username } + + expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once + + project.add_developer(user) + sign_in(user) + + 6.times do + post :create, params: { + namespace_id: project.namespace.to_param, + project_id: project, + issue: { title: 'Title', description: 'Description' } + } + end end end end |