diff options
Diffstat (limited to 'spec/controllers/projects/issues_controller_spec.rb')
-rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 31e297e5773..9c272872a73 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::IssuesController do +RSpec.describe Projects::IssuesController, feature_category: :team_planning do include ProjectForksHelper include_context 'includes Spam constants' @@ -647,9 +647,8 @@ RSpec.describe Projects::IssuesController do end end - context 'when allow_possible_spam feature flag is false' do + context 'when allow_possible_spam application setting is false' do before do - stub_feature_flags(allow_possible_spam: false) expect(controller).to(receive(:spam_action_response_fields).with(issue)) do spam_action_response_fields end @@ -662,7 +661,11 @@ RSpec.describe Projects::IssuesController do end end - context 'when allow_possible_spam feature flag is true' do + context 'when allow_possible_spam application setting is true' do + before do + stub_application_setting(allow_possible_spam: true) + end + it 'updates the issue' do subject @@ -887,11 +890,7 @@ RSpec.describe Projects::IssuesController do end end - context 'when allow_possible_spam feature flag is false' do - before do - stub_feature_flags(allow_possible_spam: false) - end - + context 'when allow_possible_spam application setting is false' do it 'rejects an issue recognized as spam' do expect { update_issue }.not_to change { issue.reload.title } end @@ -925,7 +924,11 @@ RSpec.describe Projects::IssuesController do end end - context 'when allow_possible_spam feature flag is true' do + context 'when allow_possible_spam application setting is true' do + before do + stub_application_setting(allow_possible_spam: true) + end + it 'updates the issue recognized as spam' do expect { update_issue }.to change { issue.reload.title } end @@ -1234,8 +1237,6 @@ RSpec.describe Projects::IssuesController do context 'when SpamVerdictService allows the issue' do before do - stub_feature_flags(allow_possible_spam: false) - expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service| expect(verdict_service).to receive(:execute).and_return(ALLOW) end @@ -1258,11 +1259,7 @@ RSpec.describe Projects::IssuesController do post_new_issue(title: 'Spam Title', description: 'Spam lives here') end - context 'when allow_possible_spam feature flag is false' do - before do - stub_feature_flags(allow_possible_spam: false) - end - + context 'when allow_possible_spam application setting is false' do it 'rejects an issue recognized as spam' do expect { post_spam_issue }.not_to change(Issue, :count) end @@ -1283,7 +1280,11 @@ RSpec.describe Projects::IssuesController do end end - context 'when allow_possible_spam feature flag is true' do + context 'when allow_possible_spam application setting is true' do + before do + stub_application_setting(allow_possible_spam: true) + end + it 'creates an issue recognized as spam' do expect { post_spam_issue }.to change(Issue, :count) end @@ -1377,13 +1378,13 @@ RSpec.describe Projects::IssuesController do end context 'when issue creation limits imposed' do - it 'prevents from creating more issues', :request_store do - post_new_issue - - expect { post_new_issue } - .to change { Gitlab::GitalyClient.get_request_count }.by(1) # creates 1 projects and 0 issues + before do + project.add_developer(user) + sign_in(user) + end - post_new_issue + it 'prevents from creating more issues', :request_store do + 2.times { post_new_issue_in_project } 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) @@ -1402,16 +1403,15 @@ RSpec.describe Projects::IssuesController do expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once - project.add_developer(user) - sign_in(user) + 2.times { post_new_issue_in_project } + end - 2.times do - post :create, params: { - namespace_id: project.namespace.to_param, - project_id: project, - issue: { title: 'Title', description: 'Description' } - } - end + def post_new_issue_in_project + post :create, params: { + namespace_id: project.namespace.to_param, + project_id: project, + issue: { title: 'Title', description: 'Description' } + } end end end |