Commit cc9604f9 authored by Christian Couder's avatar Christian Couder

Refactor all tests even more

parent bc0c52f2
...@@ -105,6 +105,18 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -105,6 +105,18 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
include_examples 'a service that does not update a merge request' include_examples 'a service that does not update a merge request'
end end
shared_examples 'with a deleted branch' do
let(:changes) { deleted_branch_changes }
it_behaves_like 'a service that does nothing'
end
shared_examples 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
describe '`create` push option' do describe '`create` push option' do
let(:push_options) { { create: true } } let(:push_options) { { create: true } }
...@@ -127,17 +139,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -127,17 +139,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that does not create a merge request' it_behaves_like 'a service that does not create a merge request'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`merge_when_pipeline_succeeds` push option' do describe '`merge_when_pipeline_succeeds` push option' do
...@@ -189,17 +192,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -189,17 +192,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can set the merge request to merge when pipeline succeeds' it_behaves_like 'a service that can set the merge request to merge when pipeline succeeds'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`remove_source_branch` push option' do describe '`remove_source_branch` push option' do
...@@ -251,17 +245,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -251,17 +245,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can remove the source branch when it is merged' it_behaves_like 'a service that can remove the source branch when it is merged'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`target` push option' do describe '`target` push option' do
...@@ -313,17 +298,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -313,17 +298,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can set the target of a merge request' it_behaves_like 'a service that can set the target of a merge request'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`title` push option' do describe '`title` push option' do
...@@ -375,17 +351,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -375,17 +351,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can set the title of a merge request' it_behaves_like 'a service that can set the title of a merge request'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`description` push option' do describe '`description` push option' do
...@@ -437,17 +404,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -437,17 +404,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can set the description of a merge request' it_behaves_like 'a service that can set the description of a merge request'
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`label` push option' do describe '`label` push option' do
...@@ -499,17 +457,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -499,17 +457,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can change labels of a merge request', 2 it_behaves_like 'a service that can change labels of a merge request', 2
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`unlabel` push option' do describe '`unlabel` push option' do
...@@ -561,17 +510,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -561,17 +510,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'a service that can change labels of a merge request', 1 it_behaves_like 'a service that can change labels of a merge request', 1
end end
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
shared_examples 'with an existing branch that has a merge request open in foss' do shared_examples 'with an existing branch that has a merge request open in foss' do
...@@ -591,17 +531,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -591,17 +531,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'with an existing branch but no open MR', 1 it_behaves_like 'with an existing branch but no open MR', 1
it_behaves_like 'with an existing branch that has a merge request open in foss' it_behaves_like 'with an existing branch that has a merge request open in foss'
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe '`unassign` push option' do describe '`unassign` push option' do
...@@ -613,17 +544,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do ...@@ -613,17 +544,8 @@ RSpec.describe MergeRequests::PushOptionsHandlerService do
it_behaves_like 'with an existing branch but no open MR', 1 it_behaves_like 'with an existing branch but no open MR', 1
it_behaves_like 'with an existing branch that has a merge request open in foss' it_behaves_like 'with an existing branch that has a merge request open in foss'
context 'with a deleted branch' do it_behaves_like 'with a deleted branch'
let(:changes) { deleted_branch_changes } it_behaves_like 'with the project default branch'
it_behaves_like 'a service that does nothing'
end
context 'with the project default branch' do
let(:changes) { default_branch_changes }
it_behaves_like 'a service that does nothing'
end
end end
describe 'multiple pushed branches' do describe 'multiple pushed branches' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment