Skip to content
Snippets Groups Projects
Commit 40254b9a authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 22a0d312
No related branches found
No related tags found
No related merge requests found
Showing
with 100 additions and 29 deletions
Loading
Loading
@@ -28,6 +28,17 @@ module FilterSpecHelper
described_class.call(html, context)
end
 
# Get an instance of the Filter class
#
# Use this for testing instance methods, but remember to test the result of
# the full pipeline by calling #call using the other methods in this helper.
def filter_instance
render_context = Banzai::RenderContext.new(project, current_user)
context = { project: project, current_user: current_user, render_context: render_context }
described_class.new(input_text, context)
end
# Run text through HTML::Pipeline with the current filter and return the
# result Hash
#
Loading
Loading
Loading
Loading
@@ -3,7 +3,9 @@
module ImportExport
module CommonUtil
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") }
FileUtils.ln_s("#{tmpdir}/test", "#{tmpdir}/#{symlink_name}")
Loading
Loading
# frozen_string_literal: true
shared_examples 'log import failure' do |importable_column|
it 'tracks error' do
extra = {
relation_key: relation_key,
relation_index: relation_index,
retry_count: retry_count
}
extra[importable_column] = importable.id
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(exception, extra)
subject.log_import_failure(relation_key, relation_index, exception, retry_count)
end
it 'saves data to ImportFailure' do
log_import_failure
import_failure = ImportFailure.last
aggregate_failures do
expect(import_failure[importable_column]).to eq(importable.id)
expect(import_failure.relation_key).to eq(relation_key)
expect(import_failure.relation_index).to eq(relation_index)
expect(import_failure.exception_class).to eq('StandardError')
expect(import_failure.exception_message).to eq(standard_error_message)
expect(import_failure.correlation_id_value).to eq(correlation_id)
expect(import_failure.retry_count).to eq(retry_count)
end
end
end
Loading
Loading
@@ -35,8 +35,9 @@ describe Ci::ArchiveTracesCronWorker do
it_behaves_like 'archives trace'
 
it 'executes service' do
expect_any_instance_of(Ci::ArchiveTraceService)
.to receive(:execute).with(build, anything)
expect_next_instance_of(Ci::ArchiveTraceService) do |instance|
expect(instance).to receive(:execute).with(build, anything)
end
 
subject
end
Loading
Loading
@@ -64,7 +65,9 @@ describe Ci::ArchiveTracesCronWorker do
 
before do
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
 
it 'puts a log' do
Loading
Loading
Loading
Loading
@@ -57,9 +57,9 @@ describe Gitlab::GithubImport::ReschedulingMethods do
expect(worker)
.not_to receive(:notify_waiter)
 
expect_any_instance_of(Gitlab::GithubImport::Client)
.to receive(:rate_limit_resets_in)
.and_return(14)
expect_next_instance_of(Gitlab::GithubImport::Client) do |instance|
expect(instance).to receive(:rate_limit_resets_in).and_return(14)
end
 
expect(worker.class)
.to receive(:perform_in)
Loading
Loading
Loading
Loading
@@ -9,7 +9,9 @@ describe DeleteMergedBranchesWorker do
 
describe "#perform" 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)
end
Loading
Loading
Loading
Loading
@@ -7,7 +7,9 @@ describe ExpireBuildArtifactsWorker do
 
describe '#perform' 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
end
Loading
Loading
Loading
Loading
@@ -21,9 +21,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
it 'schedules the importing of the base data' do
client = double(:client)
 
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
.to receive(:execute)
.and_return(true)
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
expect(instance).to receive(:execute).and_return(true)
end
 
expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
.to receive(:perform_async)
Loading
Loading
@@ -37,9 +37,9 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
it 'does not schedule the importing of the base data' do
client = double(:client)
 
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
.to receive(:execute)
.and_return(false)
expect_next_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter) do |instance|
expect(instance).to receive(:execute).and_return(false)
end
 
expect(Gitlab::GithubImport::Stage::ImportBaseDataWorker)
.not_to receive(:perform_async)
Loading
Loading
Loading
Loading
@@ -7,7 +7,9 @@ describe GitlabShellWorker do
 
describe '#perform with add_key' 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')
end
end
Loading
Loading
Loading
Loading
@@ -8,7 +8,9 @@ describe GitlabUsagePingWorker do
it 'delegates to SubmitUsagePingService' do
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
end
Loading
Loading
Loading
Loading
@@ -10,7 +10,9 @@ describe HashedStorage::MigratorWorker do
 
describe '#perform' 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)
end
Loading
Loading
Loading
Loading
@@ -10,7 +10,9 @@ describe HashedStorage::RollbackerWorker do
 
describe '#perform' 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)
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,9 @@ describe ImportIssuesCsvWorker do
 
describe '#perform' 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)
 
Loading
Loading
Loading
Loading
@@ -6,7 +6,9 @@ describe NewReleaseWorker do
let(:release) { create(:release) }
 
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)
end
Loading
Loading
Loading
Loading
@@ -21,8 +21,9 @@ describe RepositoryImportWorker do
 
allow(subject).to receive(:jid).and_return(jid)
 
expect_any_instance_of(Projects::ImportService).to receive(:execute)
.and_return({ status: :ok })
expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :ok })
end
 
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(started_project.id).and_return(started_project)
Loading
Loading
@@ -36,8 +37,9 @@ describe RepositoryImportWorker do
 
context 'when the import was successful' do
it 'imports a project' do
expect_any_instance_of(Projects::ImportService).to receive(:execute)
.and_return({ status: :ok })
expect_next_instance_of(Projects::ImportService) do |instance|
expect(instance).to receive(:execute).and_return({ status: :ok })
end
 
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(project.id).and_return(project)
Loading
Loading
@@ -54,7 +56,9 @@ describe RepositoryImportWorker do
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
 
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
subject.perform(project.id)
Loading
Loading
@@ -67,7 +71,9 @@ describe RepositoryImportWorker do
 
project.update(import_type: 'gitlab_project')
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
subject.perform(project.id)
Loading
Loading
@@ -93,8 +99,9 @@ describe RepositoryImportWorker do
.to receive(:async?)
.and_return(true)
 
expect_any_instance_of(ProjectImportState)
.not_to receive(:finish)
expect_next_instance_of(ProjectImportState) do |instance|
expect(instance).not_to receive(:finish)
end
 
subject.perform(project.id)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment