diff options
Diffstat (limited to 'spec/services')
12 files changed, 36 insertions, 21 deletions
diff --git a/spec/services/branches/delete_merged_service_spec.rb b/spec/services/branches/delete_merged_service_spec.rb index 962af8110f7..5c87f156ec7 100644 --- a/spec/services/branches/delete_merged_service_spec.rb +++ b/spec/services/branches/delete_merged_service_spec.rb @@ -9,7 +9,7 @@ describe Branches::DeleteMergedService do let(:project) { create(:project, :repository) } - context '#execute' do + describe '#execute' do it 'deletes a branch that was merged' do service.execute @@ -74,7 +74,7 @@ describe Branches::DeleteMergedService do end end - context '#async_execute' do + describe '#async_execute' do it 'calls DeleteMergedBranchesWorker async' do expect(DeleteMergedBranchesWorker).to receive(:perform_async) diff --git a/spec/services/ci/ensure_stage_service_spec.rb b/spec/services/ci/ensure_stage_service_spec.rb index de07a1ae238..8a270d77bae 100644 --- a/spec/services/ci/ensure_stage_service_spec.rb +++ b/spec/services/ci/ensure_stage_service_spec.rb @@ -44,7 +44,7 @@ describe Ci::EnsureStageService, '#execute' do it 'retries up to two times' do job.assign_attributes(stage_id: nil) - expect(service).to receive(:find_stage).exactly(2).times + expect(service).to receive(:find_stage).twice expect { service.execute(job) } .to raise_error(Ci::EnsureStageService::EnsureStageError) diff --git a/spec/services/clusters/cleanup/app_service_spec.rb b/spec/services/clusters/cleanup/app_service_spec.rb index cc27f409086..14bfca02fee 100644 --- a/spec/services/clusters/cleanup/app_service_spec.rb +++ b/spec/services/clusters/cleanup/app_service_spec.rb @@ -85,7 +85,7 @@ describe Clusters::Cleanup::AppService do it 'logs application uninstalls and next execution' do expect(logger).to receive(:info) - .with(log_meta.merge(event: :uninstalling_app, application: kind_of(String))).exactly(2).times + .with(log_meta.merge(event: :uninstalling_app, application: kind_of(String))).twice expect(logger).to receive(:info) .with(log_meta.merge(event: :scheduling_execution, next_execution: 1)) diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index c64b93a2532..8b4f45010ed 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -12,6 +12,7 @@ describe Git::BranchPushService, services: true do let(:newrev) { sample_commit.id } let(:branch) { 'master' } let(:ref) { "refs/heads/#{branch}" } + let(:push_options) { nil } before do project.add_maintainer(user) @@ -19,7 +20,7 @@ describe Git::BranchPushService, services: true do describe 'Push branches' do subject do - execute_service(project, user, oldrev: oldrev, newrev: newrev, ref: ref) + execute_service(project, user, oldrev: oldrev, newrev: newrev, ref: ref, push_options: push_options) end context 'new branch' do @@ -113,6 +114,20 @@ describe Git::BranchPushService, services: true do expect { subject }.not_to change { Ci::Pipeline.count } end + + context 'with push options' do + let(:push_options) { ['mr.create'] } + + it 'sanitizes push options' do + allow(Gitlab::Runtime).to receive(:sidekiq?).and_return(true) + expect(Sidekiq.logger).to receive(:warn) do |args| + pipeline_params = args[:pipeline_params] + expect(pipeline_params.keys).to match_array(%i(before after ref variables_attributes checkout_sha)) + end + + expect { subject }.not_to change { Ci::Pipeline.count } + end + end end end @@ -637,8 +652,8 @@ describe Git::BranchPushService, services: true do end end - def execute_service(project, user, change) - service = described_class.new(project, user, change: change) + def execute_service(project, user, change, push_options = {}) + service = described_class.new(project, user, change: change, push_options: push_options) service.execute service end diff --git a/spec/services/labels/available_labels_service_spec.rb b/spec/services/labels/available_labels_service_spec.rb index 4d5c87ecc53..ce120344f16 100644 --- a/spec/services/labels/available_labels_service_spec.rb +++ b/spec/services/labels/available_labels_service_spec.rb @@ -12,7 +12,7 @@ describe Labels::AvailableLabelsService do let(:other_group_label) { create(:group_label) } let(:labels) { [project_label, other_project_label, group_label, other_group_label] } - context '#find_or_create_by_titles' do + describe '#find_or_create_by_titles' do let(:label_titles) { labels.map(&:title).push('non existing title') } context 'when parent is a project' do @@ -64,7 +64,7 @@ describe Labels::AvailableLabelsService do end end - context '#filter_labels_ids_in_param' do + describe '#filter_labels_ids_in_param' do let(:label_ids) { labels.map(&:id).push(99999) } context 'when parent is a project' do diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 1f1ccff2ba8..e7d0e91bced 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -2264,7 +2264,7 @@ describe NotificationService, :mailer do end it 'filters out guests when new note is created' do - expect(SentNotification).to receive(:record).with(merge_request, any_args).exactly(1).times + expect(SentNotification).to receive(:record).with(merge_request, any_args).once notification.new_note(note) diff --git a/spec/services/projects/batch_open_issues_count_service_spec.rb b/spec/services/projects/batch_open_issues_count_service_spec.rb index e978334d68b..8cb0ce03fba 100644 --- a/spec/services/projects/batch_open_issues_count_service_spec.rb +++ b/spec/services/projects/batch_open_issues_count_service_spec.rb @@ -8,7 +8,7 @@ describe Projects::BatchOpenIssuesCountService do let(:subject) { described_class.new([project_1, project_2]) } - context '#refresh_cache', :use_clean_rails_memory_store_caching do + describe '#refresh_cache', :use_clean_rails_memory_store_caching do before do create(:issue, project: project_1) create(:issue, project: project_1, confidential: true) diff --git a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb index b0827f6a2ee..7c7e188a12d 100644 --- a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb +++ b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb @@ -14,7 +14,7 @@ describe Projects::HashedStorage::MigrateAttachmentsService do let(:old_disk_path) { File.join(base_path(legacy_storage), upload.path) } let(:new_disk_path) { File.join(base_path(hashed_storage), upload.path) } - context '#execute' do + describe '#execute' do context 'when succeeds' do it 'moves attachments to hashed storage layout' do expect(File.file?(old_disk_path)).to be_truthy @@ -102,13 +102,13 @@ describe Projects::HashedStorage::MigrateAttachmentsService do end end - context '#old_disk_path' do + describe '#old_disk_path' do it 'returns old disk_path for project' do expect(service.old_disk_path).to eq(project.full_path) end end - context '#new_disk_path' do + describe '#new_disk_path' do it 'returns new disk_path for project' do service.execute @@ -116,7 +116,7 @@ describe Projects::HashedStorage::MigrateAttachmentsService do end end - context '#target_path_discardable?' do + describe '#target_path_discardable?' do it 'returns true when it include only items on the discardable list' do hashed_attachments_path = File.join(base_path(hashed_storage)) Projects::HashedStorage::MigrateAttachmentsService::DISCARDABLE_PATHS.each do |path_fragment| diff --git a/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb b/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb index 98b343371df..54695e6e48f 100644 --- a/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb +++ b/spec/services/projects/hashed_storage/rollback_attachments_service_spec.rb @@ -14,7 +14,7 @@ describe Projects::HashedStorage::RollbackAttachmentsService do let(:old_disk_path) { File.join(base_path(hashed_storage), upload.path) } let(:new_disk_path) { File.join(base_path(legacy_storage), upload.path) } - context '#execute' do + describe '#execute' do context 'when succeeds' do it 'moves attachments to legacy storage layout' do expect(File.file?(old_disk_path)).to be_truthy @@ -86,13 +86,13 @@ describe Projects::HashedStorage::RollbackAttachmentsService do end end - context '#old_disk_path' do + describe '#old_disk_path' do it 'returns old disk_path for project' do expect(service.old_disk_path).to eq(project.disk_path) end end - context '#new_disk_path' do + describe '#new_disk_path' do it 'returns new disk_path for project' do service.execute diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index 60804a8dba6..98a27a71c26 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -75,7 +75,7 @@ describe Projects::HousekeepingService do # At push 200 expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid) - .exactly(1).times + .once # At push 50, 100, 150 expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid) .exactly(3).times diff --git a/spec/services/projects/open_issues_count_service_spec.rb b/spec/services/projects/open_issues_count_service_spec.rb index 04f1353c499..c1d49befeb9 100644 --- a/spec/services/projects/open_issues_count_service_spec.rb +++ b/spec/services/projects/open_issues_count_service_spec.rb @@ -57,7 +57,7 @@ describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_caching end end - context '#refresh_cache' do + describe '#refresh_cache' do before do create(:issue, :opened, project: project) create(:issue, :opened, project: project) diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 81012eba06d..7db94d4a4ac 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1884,7 +1884,7 @@ describe QuickActions::InterpretService do end end - context "#commands_executed_count" do + describe "#commands_executed_count" do it 'counts commands executed' do content = "/close and \n/assign me and \n/title new title" |