Commit 138c0af8 authored by Arturo Herrero's avatar Arturo Herrero Committed by Mayra Cabrera

Update RSpec helper methods to *_next_instance_of

Auto-correct some references in RSpec as:
- expect_any_instance_of -> expect_next_instance_of
- allow_any_instance_of -> allow_next_instance_of

Related to https://gitlab.com/gitlab-org/gitlab/issues/34997
parent 357e5611
...@@ -74,7 +74,9 @@ describe MergeRequests::Conflicts::ListService do ...@@ -74,7 +74,9 @@ describe MergeRequests::Conflicts::ListService do
it 'returns a falsey value when the MR has a missing ref after a force push' do it 'returns a falsey value when the MR has a missing ref after a force push' do
merge_request = create_merge_request('conflict-resolvable') merge_request = create_merge_request('conflict-resolvable')
service = conflicts_service(merge_request) service = conflicts_service(merge_request)
allow_any_instance_of(Gitlab::GitalyClient::ConflictsService).to receive(:list_conflict_files).and_raise(GRPC::Unknown) allow_next_instance_of(Gitlab::GitalyClient::ConflictsService) do |instance|
allow(instance).to receive(:list_conflict_files).and_raise(GRPC::Unknown)
end
expect(service.can_be_resolved_in_ui?).to be_falsey expect(service.can_be_resolved_in_ui?).to be_falsey
end end
......
...@@ -55,7 +55,9 @@ describe MergeRequests::CreateFromIssueService do ...@@ -55,7 +55,9 @@ describe MergeRequests::CreateFromIssueService do
end end
it 'creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created', :sidekiq_might_not_need_inline do it 'creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created', :sidekiq_might_not_need_inline do
expect_any_instance_of(MergeRequest).to receive(:valid?).at_least(:once).and_return(false) expect_next_instance_of(MergeRequest) do |instance|
expect(instance).to receive(:valid?).at_least(:once).and_return(false)
end
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name, branch_project: target_project) expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name, branch_project: target_project)
......
...@@ -714,9 +714,9 @@ describe MergeRequests::PushOptionsHandlerService do ...@@ -714,9 +714,9 @@ describe MergeRequests::PushOptionsHandlerService do
let(:exception) { StandardError.new('My standard error') } let(:exception) { StandardError.new('My standard error') }
def run_service_with_exception def run_service_with_exception
allow_any_instance_of( allow_next_instance_of(MergeRequests::BuildService) do |instance|
MergeRequests::BuildService allow(instance).to receive(:execute).and_raise(exception)
).to receive(:execute).and_raise(exception) end
service.execute service.execute
end end
...@@ -766,9 +766,9 @@ describe MergeRequests::PushOptionsHandlerService do ...@@ -766,9 +766,9 @@ describe MergeRequests::PushOptionsHandlerService do
invalid_merge_request = MergeRequest.new invalid_merge_request = MergeRequest.new
invalid_merge_request.errors.add(:base, 'my error') invalid_merge_request.errors.add(:base, 'my error')
expect_any_instance_of( expect_next_instance_of(MergeRequests::CreateService) do |instance|
MergeRequests::CreateService expect(instance).to receive(:execute).and_return(invalid_merge_request)
).to receive(:execute).and_return(invalid_merge_request) end
service.execute service.execute
......
...@@ -31,7 +31,9 @@ describe Milestones::PromoteService do ...@@ -31,7 +31,9 @@ describe Milestones::PromoteService do
it 'does not promote milestone and update issuables if promoted milestone is not valid' do it 'does not promote milestone and update issuables if promoted milestone is not valid' do
issue = create(:issue, milestone: milestone, project: project) issue = create(:issue, milestone: milestone, project: project)
merge_request = create(:merge_request, milestone: milestone, source_project: project) merge_request = create(:merge_request, milestone: milestone, source_project: project)
allow_any_instance_of(Milestone).to receive(:valid?).and_return(false) allow_next_instance_of(Milestone) do |instance|
allow(instance).to receive(:valid?).and_return(false)
end
expect { service.execute(milestone) }.to raise_error(described_class::PromoteMilestoneError) expect { service.execute(milestone) }.to raise_error(described_class::PromoteMilestoneError)
......
...@@ -71,7 +71,9 @@ describe Milestones::TransferService do ...@@ -71,7 +71,9 @@ describe Milestones::TransferService do
context 'when find_or_create_milestone returns nil' do context 'when find_or_create_milestone returns nil' do
before do before do
allow_any_instance_of(Milestones::FindOrCreateService).to receive(:execute).and_return(nil) allow_next_instance_of(Milestones::FindOrCreateService) do |instance|
allow(instance).to receive(:execute).and_return(nil)
end
end end
it 'removes issues group milestone' do it 'removes issues group milestone' do
......
...@@ -17,7 +17,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do ...@@ -17,7 +17,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do
end end
it 'recalculate the namespace statistics' do it 'recalculate the namespace statistics' do
expect_any_instance_of(Namespace::RootStorageStatistics).to receive(:recalculate!).once expect_next_instance_of(Namespace::RootStorageStatistics) do |instance|
expect(instance).to receive(:recalculate!).once
end
service.execute(group) service.execute(group)
end end
...@@ -45,8 +47,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do ...@@ -45,8 +47,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do
context 'when something goes wrong' do context 'when something goes wrong' do
before do before do
allow_any_instance_of(Namespace::RootStorageStatistics) allow_next_instance_of(Namespace::RootStorageStatistics) do |instance|
.to receive(:recalculate!).and_raise(ActiveRecord::ActiveRecordError) allow(instance).to receive(:recalculate!).and_raise(ActiveRecord::ActiveRecordError)
end
end end
it 'raises RefreshError' do it 'raises RefreshError' do
......
...@@ -17,7 +17,9 @@ describe Notes::ResolveService do ...@@ -17,7 +17,9 @@ describe Notes::ResolveService do
end end
it "sends notifications if all discussions are resolved" do it "sends notifications if all discussions are resolved" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService).to receive(:execute).with(merge_request) expect_next_instance_of(MergeRequests::ResolvedDiscussionNotificationService) do |instance|
expect(instance).to receive(:execute).with(merge_request)
end
described_class.new(merge_request.project, user).execute(note) described_class.new(merge_request.project, user).execute(note)
end end
......
...@@ -32,9 +32,9 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do ...@@ -32,9 +32,9 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do
def stub_lets_encrypt_order(url, status) def stub_lets_encrypt_order(url, status)
order = ::Gitlab::LetsEncrypt::Order.new(acme_order_double(status: status)) order = ::Gitlab::LetsEncrypt::Order.new(acme_order_double(status: status))
allow_any_instance_of(::Gitlab::LetsEncrypt::Client).to( allow_next_instance_of(::Gitlab::LetsEncrypt::Client) do |instance|
receive(:load_order).with(url).and_return(order) allow(instance).to receive(:load_order).with(url).and_return(order)
) end
order order
end end
......
...@@ -247,7 +247,9 @@ describe Projects::CreateService, '#execute' do ...@@ -247,7 +247,9 @@ describe Projects::CreateService, '#execute' do
context 'repository creation' do context 'repository creation' do
it 'synchronously creates the repository' do it 'synchronously creates the repository' do
expect_any_instance_of(Project).to receive(:create_repository) expect_next_instance_of(Project) do |instance|
expect(instance).to receive(:create_repository)
end
project = create_project(user, opts) project = create_project(user, opts)
expect(project).to be_valid expect(project).to be_valid
......
...@@ -94,7 +94,9 @@ describe Projects::ImportExport::ExportService do ...@@ -94,7 +94,9 @@ describe Projects::ImportExport::ExportService do
end end
it 'notifies the user' do it 'notifies the user' do
expect_any_instance_of(NotificationService).to receive(:project_not_exported) expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:project_not_exported)
end
end end
it 'notifies logger' do it 'notifies logger' do
...@@ -122,7 +124,9 @@ describe Projects::ImportExport::ExportService do ...@@ -122,7 +124,9 @@ describe Projects::ImportExport::ExportService do
end end
it 'notifies the user' do it 'notifies the user' do
expect_any_instance_of(NotificationService).to receive(:project_not_exported) expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:project_not_exported)
end
end end
it 'notifies logger' do it 'notifies logger' do
......
...@@ -16,7 +16,9 @@ describe Projects::LfsPointers::LfsImportService do ...@@ -16,7 +16,9 @@ describe Projects::LfsPointers::LfsImportService do
it 'downloads lfs objects' do it 'downloads lfs objects' do
service = double service = double
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_return(oid_download_links) expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_return(oid_download_links)
end
expect(Projects::LfsPointers::LfsDownloadService).to receive(:new).and_return(service).twice expect(Projects::LfsPointers::LfsDownloadService).to receive(:new).and_return(service).twice
expect(service).to receive(:execute).twice expect(service).to receive(:execute).twice
...@@ -27,7 +29,9 @@ describe Projects::LfsPointers::LfsImportService do ...@@ -27,7 +29,9 @@ describe Projects::LfsPointers::LfsImportService do
context 'when no downloadable lfs object links' do context 'when no downloadable lfs object links' do
it 'does not call LfsDownloadService' do it 'does not call LfsDownloadService' do
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_return({}) expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_return({})
end
expect(Projects::LfsPointers::LfsDownloadService).not_to receive(:new) expect(Projects::LfsPointers::LfsDownloadService).not_to receive(:new)
result = subject.execute result = subject.execute
...@@ -39,7 +43,9 @@ describe Projects::LfsPointers::LfsImportService do ...@@ -39,7 +43,9 @@ describe Projects::LfsPointers::LfsImportService do
context 'when an exception is raised' do context 'when an exception is raised' do
it 'returns error' do it 'returns error' do
error_message = "error message" error_message = "error message"
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_raise(StandardError, error_message) expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_raise(StandardError, error_message)
end
result = subject.execute result = subject.execute
......
...@@ -110,8 +110,9 @@ describe Projects::UpdatePagesService do ...@@ -110,8 +110,9 @@ describe Projects::UpdatePagesService do
context 'when timeout happens by DNS error' do context 'when timeout happens by DNS error' do
before do before do
allow_any_instance_of(described_class) allow_next_instance_of(described_class) do |instance|
.to receive(:extract_zip_archive!).and_raise(SocketError) allow(instance).to receive(:extract_zip_archive!).and_raise(SocketError)
end
end end
it 'raises an error' do it 'raises an error' do
...@@ -125,9 +126,10 @@ describe Projects::UpdatePagesService do ...@@ -125,9 +126,10 @@ describe Projects::UpdatePagesService do
context 'when failed to extract zip artifacts' do context 'when failed to extract zip artifacts' do
before do before do
expect_any_instance_of(described_class) expect_next_instance_of(described_class) do |instance|
.to receive(:extract_zip_archive!) expect(instance).to receive(:extract_zip_archive!)
.and_raise(Projects::UpdatePagesService::FailedToExtractError) .and_raise(Projects::UpdatePagesService::FailedToExtractError)
end
end end
it 'raises an error' do it 'raises an error' do
......
...@@ -265,7 +265,9 @@ describe ::SystemNotes::IssuablesService do ...@@ -265,7 +265,9 @@ describe ::SystemNotes::IssuablesService do
context 'when cross-reference disallowed' do context 'when cross-reference disallowed' do
before do before do
expect_any_instance_of(described_class).to receive(:cross_reference_disallowed?).and_return(true) expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:cross_reference_disallowed?).and_return(true)
end
end end
it 'returns nil' do it 'returns nil' do
...@@ -279,7 +281,9 @@ describe ::SystemNotes::IssuablesService do ...@@ -279,7 +281,9 @@ describe ::SystemNotes::IssuablesService do
context 'when cross-reference allowed' do context 'when cross-reference allowed' do
before do before do
expect_any_instance_of(described_class).to receive(:cross_reference_disallowed?).and_return(false) expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:cross_reference_disallowed?).and_return(false)
end
end end
it_behaves_like 'a system note' do it_behaves_like 'a system note' do
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
module ImportExport module ImportExport
module CommonUtil module CommonUtil
def setup_symlink(tmpdir, symlink_name) def setup_symlink(tmpdir, symlink_name)
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(tmpdir) allow_next_instance_of(Gitlab::ImportExport) do |instance|
allow(instance).to receive(:storage_path).and_return(tmpdir)
end
File.open("#{tmpdir}/test", 'w') { |file| file.write("test") } File.open("#{tmpdir}/test", 'w') { |file| file.write("test") }
FileUtils.ln_s("#{tmpdir}/test", "#{tmpdir}/#{symlink_name}") FileUtils.ln_s("#{tmpdir}/test", "#{tmpdir}/#{symlink_name}")
......
...@@ -35,8 +35,9 @@ describe Ci::ArchiveTracesCronWorker do ...@@ -35,8 +35,9 @@ describe Ci::ArchiveTracesCronWorker do
it_behaves_like 'archives trace' it_behaves_like 'archives trace'
it 'executes service' do it 'executes service' do
expect_any_instance_of(Ci::ArchiveTraceService) expect_next_instance_of(Ci::ArchiveTraceService) do |instance|
.to receive(:execute).with(build, anything) expect(instance).to receive(:execute).with(build, anything)
end
subject subject
end end
...@@ -64,7 +65,9 @@ describe Ci::ArchiveTracesCronWorker do ...@@ -64,7 +65,9 @@ describe Ci::ArchiveTracesCronWorker do
before do before do
allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception) allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!).and_raise('Unexpected error') allow_next_instance_of(Gitlab::Ci::Trace) do |instance|
allow(instance).to receive(:archive!).and_raise('Unexpected error')
end
end end
it 'puts a log' do it 'puts a log' do
......
...@@ -57,9 +57,9 @@ describe Gitlab::GithubImport::ReschedulingMethods do ...@@ -57,9 +57,9 @@ describe Gitlab::GithubImport::ReschedulingMethods do
expect(worker) expect(worker)
.not_to receive(:notify_waiter) .not_to receive(:notify_waiter)
expect_any_instance_of(Gitlab::GithubImport::Client) expect_next_instance_of(Gitlab::GithubImport::Client) do |instance|
.to receive(:rate_limit_resets_in) expect(instance).to receive(:rate_limit_resets_in).and_return(14)
.and_return(14) end
expect(worker.class) expect(worker.class)
.to receive(:perform_in) .to receive(:perform_in)
......
...@@ -9,7 +9,9 @@ describe DeleteMergedBranchesWorker do ...@@ -9,7 +9,9 @@ describe DeleteMergedBranchesWorker do
describe "#perform" do describe "#perform" do
it "delegates to Branches::DeleteMergedService" do it "delegates to Branches::DeleteMergedService" do
expect_any_instance_of(::Branches::DeleteMergedService).to receive(:execute).and_return(true) expect_next_instance_of(::Branches::DeleteMergedService) do |instance|
expect(instance).to receive(:execute).and_return(true)
end
worker.perform(project.id, project.owner.id) worker.perform(project.id, project.owner.id)
end end
......
...@@ -7,7 +7,9 @@ describe ExpireBuildArtifactsWorker do ...@@ -7,7 +7,9 @@ describe ExpireBuildArtifactsWorker do
describe '#perform' do describe '#perform' do
it 'executes a service' do it 'executes a service' do
expect_any_instance_of(Ci::DestroyExpiredJobArtifactsService).to receive(:execute) expect_next_instance_of(Ci::DestroyExpiredJobArtifactsService) do |instance|
expect(instance).to receive(:execute)
end
worker.perform worker.perform
end end
......
...@@ -21,9 +21,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do ...@@ -21,9 +21,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
it 'schedules the importing of the base data' do it 'schedules the importing of the base data' do
client = double(:client) client = double(:client)
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
.to receive(:execute) expect(instance).to receive(:execute).and_return(true)
.and_return(true) end
expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker) expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
.to receive(:perform_async) .to receive(:perform_async)
...@@ -37,9 +37,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do ...@@ -37,9 +37,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
it 'does not schedule the importing of the base data' do it 'does not schedule the importing of the base data' do
client = double(:client) client = double(:client)
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
.to receive(:execute) expect(instance).to receive(:execute).and_return(false)
.and_return(false) end
expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker) expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
.not_to receive(:perform_async) .not_to receive(:perform_async)
......
...@@ -7,7 +7,9 @@ describe GitlabShellWorker do ...@@ -7,7 +7,9 @@ describe GitlabShellWorker do
describe '#perform with add_key' do describe '#perform with add_key' do
it 'calls add_key on Gitlab::Shell' do it 'calls add_key on Gitlab::Shell' do
expect_any_instance_of(Gitlab::Shell).to receive(:add_key).with('foo', 'bar') expect_next_instance_of(Gitlab::Shell) do |instance|
expect(instance).to receive(:add_key).with('foo', 'bar')
end
worker.perform(:add_key, 'foo', 'bar') worker.perform(:add_key, 'foo', 'bar')
end end
end end
......
...@@ -8,7 +8,9 @@ describe GitlabUsagePingWorker do ...@@ -8,7 +8,9 @@ describe GitlabUsagePingWorker do
it 'delegates to SubmitUsagePingService' do it 'delegates to SubmitUsagePingService' do
allow(subject).to receive(:try_obtain_lease).and_return(true) allow(subject).to receive(:try_obtain_lease).and_return(true)
expect_any_instance_of(SubmitUsagePingService).to receive(:execute) expect_next_instance_of(SubmitUsagePingService) do |instance|
expect(instance).to receive(:execute)
end
subject.perform subject.perform
end end
......
...@@ -10,7 +10,9 @@ describe HashedStorage::MigratorWorker do ...@@ -10,7 +10,9 @@ describe HashedStorage::MigratorWorker do
describe '#perform' do describe '#perform' do
it 'delegates to MigratorService' do it 'delegates to MigratorService' do
expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(start: 5, finish: 10) expect_next_instance_of(Gitlab::HashedStorage::Migrator) do |instance|
expect(instance).to receive(:bulk_migrate).with(start: 5, finish: 10)
end
worker.perform(5, 10) worker.perform(5, 10)
end end
......
...@@ -10,7 +10,9 @@ describe HashedStorage::RollbackerWorker do ...@@ -10,7 +10,9 @@ describe HashedStorage::RollbackerWorker do
describe '#perform' do describe '#perform' do
it 'delegates to MigratorService' do it 'delegates to MigratorService' do
expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_rollback).with(start: 5, finish: 10) expect_next_instance_of(Gitlab::HashedStorage::Migrator) do |instance|
expect(instance).to receive(:bulk_rollback).with(start: 5, finish: 10)
end
worker.perform(5, 10) worker.perform(5, 10)
end end
......
...@@ -11,7 +11,9 @@ describe ImportIssuesCsvWorker do ...@@ -11,7 +11,9 @@ describe ImportIssuesCsvWorker do
describe '#perform' do describe '#perform' do
it 'calls #execute on Issues::ImportCsvService and destroys upload' do it 'calls #execute on Issues::ImportCsvService and destroys upload' do
expect_any_instance_of(Issues::ImportCsvService).to receive(:execute).and_return({ success: 5, errors: [], valid_file: true }) expect_next_instance_of(Issues::ImportCsvService) do |instance|
expect(instance).to receive(:execute).and_return({ success: 5, errors: [], valid_file: true })
end
worker.perform(user.id, project.id, upload.id) worker.perform(user.id, project.id, upload.id)
......
...@@ -6,7 +6,9 @@ describe NewReleaseWorker do ...@@ -6,7 +6,9 @@ describe NewReleaseWorker do
let(:release) { create(:release) } let(:release) { create(:release) }
it 'sends a new release notification' do it 'sends a new release notification' do
expect_any_instance_of(NotificationService).to receive(:send_new_release_notifications).with(release) expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:send_new_release_notifications).with(release)
end
described_class.new.perform(release.id) described_class.new.perform(release.id)
end end
......
...@@ -21,8 +21,9 @@ describe RepositoryImportWorker do ...@@ -21,8 +21,9 @@ describe RepositoryImportWorker do
allow(subject).to receive(:jid).and_return(jid) allow(subject).to receive(:jid).and_return(jid)
expect_any_instance_of(Projects::ImportService).to receive(:execute) expect_next_instance_of(Projects::ImportService) do |instance|
.and_return({ status: :ok }) expect(instance).to receive(:execute).and_return({ status: :ok })
end
# Works around https://github.com/rspec/rspec-mocks/issues/910 # Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(started_project.id).and_return(started_project) expect(Project).to receive(:find).with(started_project.id).and_return(started_project)
...@@ -36,8 +37,9 @@ describe RepositoryImportWorker do ...@@ -36,8 +37,9 @@ describe RepositoryImportWorker do
context 'when the import was successful' do context 'when the import was successful' do
it 'imports a project' do it 'imports a project' do
expect_any_instance_of(Projects::ImportService).to receive(:execute) expect_next_instance_of(Projects::ImportService) do |instance|
.and_return({ status: :ok }) expect(instance).to receive(:execute).and_return({ status: :ok })
end
# Works around https://github.com/rspec/rspec-mocks/issues/910 # Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(project.id).and_return(project) expect(Project).to receive(:find).with(project.id).and_return(project)
...@@ -54,7 +56,9 @@ describe RepositoryImportWorker do ...@@ -54,7 +56,9 @@ describe RepositoryImportWorker do
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
import_state.update(jid: '123') import_state.update(jid: '123')
expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error }) expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end
expect do expect do
subject.perform(project.id) subject.perform(project.id)
...@@ -67,7 +71,9 @@ describe RepositoryImportWorker do ...@@ -67,7 +71,9 @@ describe RepositoryImportWorker do
project.update(import_type: 'gitlab_project') project.update(import_type: 'gitlab_project')
import_state.update(jid: '123') import_state.update(jid: '123')
expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error }) expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :error, message: error })
end
expect do expect do
subject.perform(project.id) subject.perform(project.id)
...@@ -93,8 +99,9 @@ describe RepositoryImportWorker do ...@@ -93,8 +99,9 @@ describe RepositoryImportWorker do
.to receive(:async?) .to receive(:async?)
.and_return(true) .and_return(true)
expect_any_instance_of(ProjectImportState) expect_next_instance_of(ProjectImportState) do |instance|
.not_to receive(:finish) expect(instance).not_to receive(:finish)
end
subject.perform(project.id) subject.perform(project.id)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment