diff options
author | Sean McGivern <sean@gitlab.com> | 2018-07-10 19:11:31 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-07-10 19:11:31 +0300 |
commit | 5b0210a0c8db13b6e538dfea7bc07d090224bbca (patch) | |
tree | 08b56fdda44762bab34bdc6ea5e4879e23e6b77a /spec | |
parent | 49d7f92fd7476b4fb10e44ff92f36be99de0df49 (diff) |
Fix ProcessCommitWorker when upstream project is deleted
Diffstat (limited to 'spec')
-rw-r--r-- | spec/workers/process_commit_worker_spec.rb | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index ac79d9c0ac1..2d071c181c2 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe ProcessCommitWorker do + include ProjectForksHelper + let(:worker) { described_class.new } let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } @@ -32,15 +34,41 @@ describe ProcessCommitWorker do worker.perform(project.id, user.id, commit.to_hash) end - context 'when commit already exists in upstream project' do - let(:forked) { create(:project, :public, :repository) } + context 'when the project is forked' do + context 'when commit already exists in the upstream project' do + it 'does not process the commit message' do + forked = fork_project(project, user, repository: true) + + expect(worker).not_to receive(:process_commit_message) + + worker.perform(forked.id, user.id, forked.commit.to_hash) + end + end + + context 'when the commit does not exist in the upstream project' do + it 'processes the commit message' do + empty_project = create(:project, :public) + forked = fork_project(empty_project, user, repository: true) + + TestEnv.copy_repo(forked, + bare_repo: TestEnv.factory_repo_path_bare, + refs: TestEnv::BRANCH_SHA) + + expect(worker).to receive(:process_commit_message) + + worker.perform(forked.id, user.id, forked.commit.to_hash) + end + end - it 'does not process commit message' do - create(:forked_project_link, forked_to_project: forked, forked_from_project: project) + context 'when the upstream project no longer exists' do + it 'processes the commit message' do + forked = fork_project(project, user, repository: true) + project.destroy! - expect(worker).not_to receive(:process_commit_message) + expect(worker).to receive(:process_commit_message) - worker.perform(forked.id, user.id, forked.commit.to_hash) + worker.perform(forked.id, user.id, forked.commit.to_hash) + end end end end |