diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-02 00:09:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-02 00:09:22 +0300 |
commit | 1e0d9b713469904253f2452d8d34922d316a766a (patch) | |
tree | 11f46c168733068698e025bf440fc37afecb4bfc /spec/models/ci/build_spec.rb | |
parent | 1769b59b9fd05325e3016b1a53a82ae6cf56adb5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/ci/build_spec.rb')
-rw-r--r-- | spec/models/ci/build_spec.rb | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index aa3cc0800a8..fa0e72e7ad4 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3582,10 +3582,10 @@ RSpec.describe Ci::Build do end describe 'state transition when build fails' do - let(:service) { MergeRequests::AddTodoWhenBuildFailsService.new(project, user) } + let(:service) { ::MergeRequests::AddTodoWhenBuildFailsService.new(project, user) } before do - allow(MergeRequests::AddTodoWhenBuildFailsService).to receive(:new).and_return(service) + allow(::MergeRequests::AddTodoWhenBuildFailsService).to receive(:new).and_return(service) allow(service).to receive(:close) end @@ -3670,15 +3670,42 @@ RSpec.describe Ci::Build do subject.drop! end - it 'creates a todo' do - project.add_developer(user) + context 'when async_add_build_failure_todo flag enabled' do + it 'creates a todo async', :sidekiq_inline do + project.add_developer(user) + + expect_next_instance_of(TodoService) do |todo_service| + expect(todo_service) + .to receive(:merge_request_build_failed).with(merge_request) + end - expect_next_instance_of(TodoService) do |todo_service| - expect(todo_service) - .to receive(:merge_request_build_failed).with(merge_request) + subject.drop! end - subject.drop! + it 'does not create a sync todo' do + project.add_developer(user) + + expect(TodoService).not_to receive(:new) + + subject.drop! + end + end + + context 'when async_add_build_failure_todo flag disabled' do + before do + stub_feature_flags(async_add_build_failure_todo: false) + end + + it 'creates a todo sync' do + project.add_developer(user) + + expect_next_instance_of(TodoService) do |todo_service| + expect(todo_service) + .to receive(:merge_request_build_failed).with(merge_request) + end + + subject.drop! + end end end |