diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 09:41:27 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-11-27 12:58:13 +0000 |
commit | 4bd8a427d4e8127f1badc7365b35702472918956 (patch) | |
tree | d8e64bd046f35b64ad6f88bdd062e1e8f364c327 /spec/workers/gitlab | |
parent | d3f033d69cec33e8058ee9f029718882990175b0 (diff) | |
download | gitlab-ce-4bd8a427d4e8127f1badc7365b35702472918956.tar.gz |
Removes all the irrelevant import related code and columns
Clears the import related columns and code from the Project
model over to the ProjectImportState model
Diffstat (limited to 'spec/workers/gitlab')
4 files changed, 29 insertions, 31 deletions
diff --git a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb index 0f78c5cc644..fc7aafbc0c9 100644 --- a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb +++ b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb @@ -17,8 +17,8 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st context 'when there are remaining jobs' do before do allow(worker) - .to receive(:find_project) - .and_return(project) + .to receive(:find_import_state) + .and_return(import_state) end it 'reschedules itself' do @@ -38,8 +38,8 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st context 'when there are no remaining jobs' do before do allow(worker) - .to receive(:find_project) - .and_return(project) + .to receive(:find_import_state) + .and_return(import_state) allow(worker) .to receive(:wait_for_jobs) @@ -48,8 +48,8 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st end it 'schedules the next stage' do - expect(project) - .to receive(:refresh_import_jid_expiration) + expect(import_state) + .to receive(:refresh_jid_expiration) expect(Gitlab::GithubImport::Stage::FinishImportWorker) .to receive(:perform_async) @@ -96,22 +96,18 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st end end - describe '#find_project' do - it 'returns a Project' do - project.update_column(:import_status, 'started') + describe '#find_import_state' do + it 'returns a ProjectImportState' do + import_state.update_column(:status, 'started') - found = worker.find_project(project.id) + found = worker.find_import_state(project.id) - expect(found).to be_an_instance_of(Project) - - # This test is there to make sure we only select the columns we care - # about. - # TODO: enable this assertion back again - # expect(found.attributes).to include({ 'id' => nil, 'import_jid' => '123' }) + expect(found).to be_an_instance_of(ProjectImportState) + expect(found.attributes.keys).to match_array(%w(id jid)) end it 'returns nil if the project import is not running' do - expect(worker.find_project(project.id)).to be_nil + expect(worker.find_import_state(project.id)).to be_nil end end end diff --git a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb index 25ada575a44..7ff133f1049 100644 --- a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb +++ b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb @@ -29,7 +29,7 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do context 'when the job is running' do it 'refreshes the import JID and reschedules itself' do allow(worker) - .to receive(:find_project) + .to receive(:find_import_state) .with(project.id) .and_return(project) @@ -39,7 +39,7 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do .and_return(true) expect(project) - .to receive(:refresh_import_jid_expiration) + .to receive(:refresh_jid_expiration) expect(worker.class) .to receive(:perform_in_the_future) @@ -52,7 +52,7 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do context 'when the job is no longer running' do it 'returns' do allow(worker) - .to receive(:find_project) + .to receive(:find_import_state) .with(project.id) .and_return(project) @@ -62,18 +62,18 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do .and_return(false) expect(project) - .not_to receive(:refresh_import_jid_expiration) + .not_to receive(:refresh_jid_expiration) worker.perform(project.id, '123') end end end - describe '#find_project' do - it 'returns a Project' do + describe '#find_import_state' do + it 'returns a ProjectImportState' do project = create(:project, :import_started) - expect(worker.find_project(project.id)).to be_an_instance_of(Project) + expect(worker.find_import_state(project.id)).to be_an_instance_of(ProjectImportState) end # it 'only selects the import JID field' do @@ -84,14 +84,14 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do # .to eq({ 'id' => nil, 'import_jid' => '123abc' }) # end - it 'returns nil for a project for which the import process failed' do + it 'returns nil for a import state for which the import process failed' do project = create(:project, :import_failed) - expect(worker.find_project(project.id)).to be_nil + expect(worker.find_import_state(project.id)).to be_nil end - it 'returns nil for a non-existing project' do - expect(worker.find_project(-1)).to be_nil + it 'returns nil for a non-existing find_import_state' do + expect(worker.find_import_state(-1)).to be_nil end end end diff --git a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb index 8c80d660287..ad6154cc4a4 100644 --- a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe Gitlab::GithubImport::Stage::ImportBaseDataWorker do let(:project) { create(:project) } + let(:import_state) { create(:import_state, project: project) } let(:worker) { described_class.new } describe '#import' do @@ -18,7 +19,7 @@ describe Gitlab::GithubImport::Stage::ImportBaseDataWorker do expect(importer).to receive(:execute) end - expect(project).to receive(:refresh_import_jid_expiration) + expect(import_state).to receive(:refresh_jid_expiration) expect(Gitlab::GithubImport::Stage::ImportPullRequestsWorker) .to receive(:perform_async) diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb index 2fc91a3e80a..1fbb073a34a 100644 --- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do let(:project) { create(:project) } + let(:import_state) { create(:import_state, project: project) } let(:worker) { described_class.new } describe '#import' do @@ -19,8 +20,8 @@ describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do .to receive(:execute) .and_return(waiter) - expect(project) - .to receive(:refresh_import_jid_expiration) + expect(import_state) + .to receive(:refresh_jid_expiration) expect(Gitlab::GithubImport::AdvanceStageWorker) .to receive(:perform_async) |