diff options
author | Stan Hu <stanhu@gmail.com> | 2017-03-08 11:39:56 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-03-08 11:39:56 +0300 |
commit | ccaf66b8ccbd9dc7f5d9dcd297cdcdb35fa4d8ea (patch) | |
tree | 4ee819f301afb0418cccb3e081d3fd33b002d865 /spec/services/merge_requests | |
parent | cb19fd140fda6fd8adc05a00889e7567cabcaa62 (diff) |
Speed up MergeRequest::RefreshService spec by combining examples
Diffstat (limited to 'spec/services/merge_requests')
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 104 |
1 files changed, 57 insertions, 47 deletions
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index ff367f54d2a..92729f68e5f 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -58,16 +58,16 @@ describe MergeRequests::RefreshService, services: true do it 'executes hooks with update action' do expect(refresh_service).to have_received(:execute_hooks). with(@merge_request, 'update', @oldrev) - end - it { expect(@merge_request.notes).not_to be_empty } - it { expect(@merge_request).to be_open } - it { expect(@merge_request.merge_when_pipeline_succeeds).to be_falsey } - it { expect(@merge_request.diff_head_sha).to eq(@newrev) } - it { expect(@fork_merge_request).to be_open } - it { expect(@fork_merge_request.notes).to be_empty } - it { expect(@build_failed_todo).to be_done } - it { expect(@fork_build_failed_todo).to be_done } + expect(@merge_request.notes).not_to be_empty + expect(@merge_request).to be_open + expect(@merge_request.merge_when_pipeline_succeeds).to be_falsey + expect(@merge_request.diff_head_sha).to eq(@newrev) + expect(@fork_merge_request).to be_open + expect(@fork_merge_request.notes).to be_empty + expect(@build_failed_todo).to be_done + expect(@fork_build_failed_todo).to be_done + end end context 'push to origin repo target branch' do @@ -76,12 +76,14 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it { expect(@merge_request.notes.last.note).to include('merged') } - it { expect(@merge_request).to be_merged } - it { expect(@fork_merge_request).to be_merged } - it { expect(@fork_merge_request.notes.last.note).to include('merged') } - it { expect(@build_failed_todo).to be_done } - it { expect(@fork_build_failed_todo).to be_done } + it 'updates the merge state' do + expect(@merge_request.notes.last.note).to include('merged') + expect(@merge_request).to be_merged + expect(@fork_merge_request).to be_merged + expect(@fork_merge_request.notes.last.note).to include('merged') + expect(@build_failed_todo).to be_done + expect(@fork_build_failed_todo).to be_done + end end context 'manual merge of source branch' do @@ -95,13 +97,15 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it { expect(@merge_request.notes.last.note).to include('merged') } - it { expect(@merge_request).to be_merged } - it { expect(@merge_request.diffs.size).to be > 0 } - it { expect(@fork_merge_request).to be_merged } - it { expect(@fork_merge_request.notes.last.note).to include('merged') } - it { expect(@build_failed_todo).to be_done } - it { expect(@fork_build_failed_todo).to be_done } + it 'updates the merge state' do + expect(@merge_request.notes.last.note).to include('merged') + expect(@merge_request).to be_merged + expect(@merge_request.diffs.size).to be > 0 + expect(@fork_merge_request).to be_merged + expect(@fork_merge_request.notes.last.note).to include('merged') + expect(@build_failed_todo).to be_done + expect(@fork_build_failed_todo).to be_done + end end context 'push to fork repo source branch' do @@ -117,14 +121,14 @@ describe MergeRequests::RefreshService, services: true do it 'executes hooks with update action' do expect(refresh_service).to have_received(:execute_hooks). with(@fork_merge_request, 'update', @oldrev) - end - it { expect(@merge_request.notes).to be_empty } - it { expect(@merge_request).to be_open } - it { expect(@fork_merge_request.notes.last.note).to include('added 28 commits') } - it { expect(@fork_merge_request).to be_open } - it { expect(@build_failed_todo).to be_pending } - it { expect(@fork_build_failed_todo).to be_pending } + expect(@merge_request.notes).to be_empty + expect(@merge_request).to be_open + expect(@fork_merge_request.notes.last.note).to include('added 28 commits') + expect(@fork_merge_request).to be_open + expect(@build_failed_todo).to be_pending + expect(@fork_build_failed_todo).to be_pending + end end context 'closed fork merge request' do @@ -139,12 +143,14 @@ describe MergeRequests::RefreshService, services: true do expect(refresh_service).not_to have_received(:execute_hooks) end - it { expect(@merge_request.notes).to be_empty } - it { expect(@merge_request).to be_open } - it { expect(@fork_merge_request.notes).to be_empty } - it { expect(@fork_merge_request).to be_closed } - it { expect(@build_failed_todo).to be_pending } - it { expect(@fork_build_failed_todo).to be_pending } + it 'updates merge request to closed state' do + expect(@merge_request.notes).to be_empty + expect(@merge_request).to be_open + expect(@fork_merge_request.notes).to be_empty + expect(@fork_merge_request).to be_closed + expect(@build_failed_todo).to be_pending + expect(@fork_build_failed_todo).to be_pending + end end end @@ -155,12 +161,14 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it { expect(@merge_request.notes).to be_empty } - it { expect(@merge_request).to be_open } - it { expect(@fork_merge_request.notes).to be_empty } - it { expect(@fork_merge_request).to be_open } - it { expect(@build_failed_todo).to be_pending } - it { expect(@fork_build_failed_todo).to be_pending } + it 'updates the merge request state' do + expect(@merge_request.notes).to be_empty + expect(@merge_request).to be_open + expect(@fork_merge_request.notes).to be_empty + expect(@fork_merge_request).to be_open + expect(@build_failed_todo).to be_pending + expect(@fork_build_failed_todo).to be_pending + end end describe 'merge request diff' do @@ -179,12 +187,14 @@ describe MergeRequests::RefreshService, services: true do reload_mrs end - it { expect(@merge_request.notes.last.note).to include('merged') } - it { expect(@merge_request).to be_merged } - it { expect(@fork_merge_request).to be_open } - it { expect(@fork_merge_request.notes).to be_empty } - it { expect(@build_failed_todo).to be_done } - it { expect(@fork_build_failed_todo).to be_done } + it 'updates the merge request state' do + expect(@merge_request.notes.last.note).to include('merged') + expect(@merge_request).to be_merged + expect(@fork_merge_request).to be_open + expect(@fork_merge_request.notes).to be_empty + expect(@build_failed_todo).to be_done + expect(@fork_build_failed_todo).to be_done + end end context 'push new branch that exists in a merge request' do |