diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-02-20 14:59:18 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-02-20 14:59:18 +0000 |
commit | 5aa4d7bfb4a3ffa7881bdba0a0dcc50cdb245684 (patch) | |
tree | 977602ffd37d6b248be78241635119485ec9c73d /spec/workers | |
parent | 3619c9174558bd2b2ae625ac6db480c437eb8484 (diff) | |
parent | b876a52bf7c2287d438ff8df371720c5bb75ed51 (diff) | |
download | gitlab-ce-5aa4d7bfb4a3ffa7881bdba0a0dcc50cdb245684.tar.gz |
Merge branch 'master' into 42643-persist-external-ip-of-ingress-controller-gke
* master: (30 commits)
Docs: Pages - clean up articles
Only use features for events
Put all event metrics exposed to prometheus behind a feature flag
Add version which LFS lock was introduced
Remove unecessary validate: true from belongs_to :project
fix broken specs
remove common_d3 bundle
remove graphs_show webpack bundle
Chart.html.haml refactor
Remove extraneous tests from Issues API spec
[GH Import] Create an empty wiki if wiki import failed
Resolve "group request membership mail with too long list of "To:""
Add changelog entry
Fix single digit value clipping
specify date format
Increase feature flag cache TTL to one hour
Convert Gitaly commit parent IDs to array as early as possible
Clarify changelog for squash encoding fix
Avoid slow File Lock checks when not used
Fix squash rebase not working when diff contained encoded data
...
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/process_commit_worker_spec.rb | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index 24f8ca67594..76ef57b6b1e 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -20,6 +20,32 @@ describe ProcessCommitWorker do worker.perform(project.id, -1, commit.to_hash) end + context 'when commit is a merge request merge commit' do + let(:merge_request) do + create(:merge_request, + description: "Closes #{issue.to_reference}", + source_branch: 'feature-merged', + target_branch: 'master', + source_project: project) + end + + let(:commit) do + project.repository.create_branch('feature-merged', 'feature') + + sha = project.repository.merge(user, + merge_request.diff_head_sha, + merge_request, + "Closes #{issue.to_reference}") + project.repository.commit(sha) + end + + it 'it does not close any issues from the commit message' do + expect(worker).not_to receive(:close_issues) + + worker.perform(project.id, user.id, commit.to_hash) + end + end + it 'processes the commit message' do expect(worker).to receive(:process_commit_message).and_call_original @@ -48,11 +74,9 @@ describe ProcessCommitWorker do describe '#process_commit_message' do context 'when pushing to the default branch' do it 'closes issues that should be closed per the commit message' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}") - expect(worker).to receive(:close_issues) - .with(project, user, user, commit, [issue]) + expect(worker).to receive(:close_issues).with(project, user, user, commit, [issue]) worker.process_commit_message(project, commit, user, user, true) end @@ -60,8 +84,7 @@ describe ProcessCommitWorker do context 'when pushing to a non-default branch' do it 'does not close any issues' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}") expect(worker).not_to receive(:close_issues) @@ -102,8 +125,7 @@ describe ProcessCommitWorker do describe '#update_issue_metrics' do it 'updates any existing issue metrics' do - allow(commit).to receive(:safe_message) - .and_return("Closes #{issue.to_reference}") + allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}") worker.update_issue_metrics(commit, user) @@ -113,10 +135,10 @@ describe ProcessCommitWorker do end it "doesn't execute any queries with false conditions" do - allow(commit).to receive(:safe_message) - .and_return("Lorem Ipsum") + allow(commit).to receive(:safe_message).and_return("Lorem Ipsum") - expect { worker.update_issue_metrics(commit, user) }.not_to make_queries_matching(/WHERE (?:1=0|0=1)/) + expect { worker.update_issue_metrics(commit, user) } + .not_to make_queries_matching(/WHERE (?:1=0|0=1)/) end end @@ -128,8 +150,9 @@ describe ProcessCommitWorker do end it 'parses date strings into Time instances' do - commit = worker - .build_commit(project, id: '123', authored_date: Time.now.to_s) + commit = worker.build_commit(project, + id: '123', + authored_date: Time.now.to_s) expect(commit.authored_date).to be_an_instance_of(Time) end |