diff options
author | jurre <jurrestender+github@gmail.com> | 2016-12-15 21:48:26 +0100 |
---|---|---|
committer | jurre <jurrestender+github@gmail.com> | 2017-01-19 12:30:34 +0100 |
commit | e59623e7388d67433ede87db1dad134f6f176f98 (patch) | |
tree | a93e528ba7791c73b4f6907593258d6a3ecec78e /spec | |
parent | d3f26be6f08cd0656589306eb06991b93d1c5825 (diff) | |
download | gitlab-ce-e59623e7388d67433ede87db1dad134f6f176f98.tar.gz |
Mark MR as WIP when pushing WIP commits
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/commit_spec.rb | 28 | ||||
-rw-r--r-- | spec/services/merge_requests/refresh_service_spec.rb | 64 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 23 | ||||
-rw-r--r-- | spec/support/test_env.rb | 3 |
4 files changed, 117 insertions, 1 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 74b50d2908d..0d425ab7fd4 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -323,4 +323,32 @@ eos expect(new_commit.message).to eq(commit.message) end end + + describe '#work_in_progress?' do + ['squash! ', 'fixup! ', 'wip: ', 'WIP: ', '[WIP] '].each do |wip_prefix| + it "detects the '#{wip_prefix}' prefix" do + commit.message = "#{wip_prefix}#{commit.message}" + + expect(commit).to be_work_in_progress + end + end + + it "detects WIP for a commit just saying 'wip'" do + commit.message = "wip" + + expect(commit).to be_work_in_progress + end + + it "doesn't detect WIP for a commit that begins with 'FIXUP! '" do + commit.message = "FIXUP! #{commit.message}" + + expect(commit).not_to be_work_in_progress + end + + it "doesn't detect WIP for words starting with WIP" do + commit.message = "Wipout #{commit.message}" + + expect(commit).not_to be_work_in_progress + end + end end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 7e3705983fb..00d0e20f47c 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -237,6 +237,70 @@ describe MergeRequests::RefreshService, services: true do end end + context 'marking the merge request as work in progress' do + let(:refresh_service) { service.new(@project, @user) } + before do + allow(refresh_service).to receive(:execute_hooks) + end + + it 'marks the merge request as work in progress from fixup commits' do + fixup_merge_request = create(:merge_request, + source_project: @project, + source_branch: 'wip', + target_branch: 'master', + target_project: @project) + commits = fixup_merge_request.commits + oldrev = commits.last.id + newrev = commits.first.id + + refresh_service.execute(oldrev, newrev, 'refs/heads/wip') + fixup_merge_request.reload + + expect(fixup_merge_request.work_in_progress?).to eq(true) + expect(fixup_merge_request.notes.last.note).to match( + /marked as a \*\*Work In Progress\*\* from #{Commit.reference_pattern}/ + ) + end + + it 'references the commit that caused the Work in Progress status' do + refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') + + allow(refresh_service).to receive(:find_new_commits) + refresh_service.instance_variable_set("@commits", [ + instance_double( + Commit, + id: 'aaaaaaa', + short_id: 'aaaaaaa', + title: 'Fix issue', + work_in_progress?: false + ), + instance_double( + Commit, + id: 'bbbbbbb', + short_id: 'bbbbbbb', + title: 'fixup! Fix issue', + work_in_progress?: true, + to_reference: 'bbbbbbb' + ), + instance_double( + Commit, + id: 'ccccccc', + short_id: 'ccccccc', + title: 'fixup! Fix issue', + work_in_progress?: true, + to_reference: 'ccccccc' + ), + ]) + + refresh_service.execute(@oldrev, @newrev, 'refs/heads/wip') + reload_mrs + + expect(@merge_request.notes.last.note).to eq( + "marked as a **Work In Progress** from bbbbbbb" + ) + end + end + def reload_mrs @merge_request.reload @fork_merge_request.reload diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 4042f2b0512..9f5a0ac4ec6 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -805,4 +805,27 @@ describe SystemNoteService, services: true do noteable.save! end end + + describe '.add_merge_request_wip_from_commit' do + let(:noteable) do + create(:merge_request, source_project: project, target_project: project) + end + + subject do + described_class.add_merge_request_wip_from_commit( + noteable, + project, + author, + noteable.diff_head_commit + ) + end + + it_behaves_like 'a system note' + + it "posts the 'marked as a Work In Progress from commit' system note" do + expect(subject.note).to match( + /marked as a \*\*Work In Progress\*\* from #{Commit.reference_pattern}/ + ) + end + end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 4cf81be3adc..90f1a9c8798 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -35,7 +35,8 @@ module TestEnv 'conflict-missing-side' => 'eb227b3', 'conflict-non-utf8' => 'd0a293c', 'conflict-too-large' => '39fa04f', - 'deleted-image-test' => '6c17798' + 'deleted-image-test' => '6c17798', + 'wip' => 'b9238ee' } # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily |