diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-02-22 16:50:15 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-02-23 09:33:05 -0600 |
commit | 1fe7501b49f896b74102c4b970310aa9ae34da85 (patch) | |
tree | ce271afb0fbaaa14291c1dc9009cd7815ee25463 /spec/services | |
parent | bdbc7d967a0c3d95d5e4ea19a2a5be41268d3540 (diff) | |
download | gitlab-ce-1fe7501b49f896b74102c4b970310aa9ae34da85.tar.gz |
Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
Diffstat (limited to 'spec/services')
29 files changed, 218 insertions, 218 deletions
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index b818dfdd50c..65544c57431 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -284,14 +284,14 @@ describe Ci::ProcessPipelineService, :services do pipeline.builds.running_or_pending.each(&:success) - expect(builds.pluck(:name)) - .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') + expect(builds.pluck(:name)). + to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') pipeline.builds.find_by(name: 'test:1').success pipeline.builds.find_by(name: 'test:2').drop - expect(builds.pluck(:name)) - .to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') + expect(builds.pluck(:name)). + to contain_exactly('build:1', 'build:2', 'test:1', 'test:2') Ci::Build.retry(pipeline.builds.find_by(name: 'test:2'), user).success diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index d03f7505eac..6499c7ad63e 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -61,8 +61,8 @@ describe Ci::RetryBuildService, :services do end it 'resolves todos for old build that failed' do - expect(MergeRequests::AddTodoWhenBuildFailsService) - .to receive_message_chain(:new, :close) + expect(MergeRequests::AddTodoWhenBuildFailsService). + to receive_message_chain(:new, :close) service.execute(build) end @@ -82,8 +82,8 @@ describe Ci::RetryBuildService, :services do context 'when user does not have ability to execute build' do it 'raises an error' do - expect { service.execute(build) } - .to raise_error Gitlab::Access::AccessDeniedError + expect { service.execute(build) }. + to raise_error Gitlab::Access::AccessDeniedError end end end @@ -109,8 +109,8 @@ describe Ci::RetryBuildService, :services do context 'when user does not have ability to execute build' do it 'raises an error' do - expect { service.reprocess(build) } - .to raise_error Gitlab::Access::AccessDeniedError + expect { service.reprocess(build) }. + to raise_error Gitlab::Access::AccessDeniedError end end end diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb index c0af8b8450a..84915b5f1aa 100644 --- a/spec/services/ci/retry_pipeline_service_spec.rb +++ b/spec/services/ci/retry_pipeline_service_spec.rb @@ -134,8 +134,8 @@ describe Ci::RetryPipelineService, '#execute', :services do end it 'closes all todos about failed jobs for pipeline' do - expect(MergeRequests::AddTodoWhenBuildFailsService) - .to receive_message_chain(:new, :close_all) + expect(MergeRequests::AddTodoWhenBuildFailsService). + to receive_message_chain(:new, :close_all) service.execute(pipeline) end @@ -149,8 +149,8 @@ describe Ci::RetryPipelineService, '#execute', :services do context 'when user is not allowed to retry pipeline' do it 'raises an error' do - expect { service.execute(pipeline) } - .to raise_error Gitlab::Access::AccessDeniedError + expect { service.execute(pipeline) }. + to raise_error Gitlab::Access::AccessDeniedError end end diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb index 560f83d94f7..23e0856fecd 100644 --- a/spec/services/ci/stop_environments_service_spec.rb +++ b/spec/services/ci/stop_environments_service_spec.rb @@ -44,8 +44,8 @@ describe Ci::StopEnvironmentsService, services: true do context 'when environment is not stopped' do before do - allow_any_instance_of(Environment) - .to receive(:state).and_return(:stopped) + allow_any_instance_of(Environment). + to receive(:state).and_return(:stopped) end it 'does not stop environment' do @@ -83,22 +83,22 @@ describe Ci::StopEnvironmentsService, services: true do context 'when environment does not exist' do it 'does not raise error' do - expect { service.execute('master') } - .not_to raise_error + expect { service.execute('master') }. + not_to raise_error end end end def expect_environment_stopped_on(branch) - expect_any_instance_of(Environment) - .to receive(:stop!) + expect_any_instance_of(Environment). + to receive(:stop!) service.execute(branch) end def expect_environment_not_stopped_on(branch) - expect_any_instance_of(Environment) - .not_to receive(:stop!) + expect_any_instance_of(Environment). + not_to receive(:stop!) service.execute(branch) end diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb index f01a388b895..14092d9dcca 100644 --- a/spec/services/ci/update_build_queue_service_spec.rb +++ b/spec/services/ci/update_build_queue_service_spec.rb @@ -12,15 +12,15 @@ describe Ci::UpdateBuildQueueService, :services do before { build.project.runners << runner } it 'ticks runner queue value' do - expect { subject.execute(build) } - .to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) }. + to change { runner.ensure_runner_queue_value } end end context 'when there are no runners that can pick build' do it 'does not tick runner queue value' do - expect { subject.execute(build) } - .not_to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) }. + not_to change { runner.ensure_runner_queue_value } end end end @@ -30,8 +30,8 @@ describe Ci::UpdateBuildQueueService, :services do context 'when there are runner that can pick build' do it 'ticks runner queue value' do - expect { subject.execute(build) } - .to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) }. + to change { runner.ensure_runner_queue_value } end end @@ -39,8 +39,8 @@ describe Ci::UpdateBuildQueueService, :services do before { build.tag_list = [:docker] } it 'does not tick runner queue value' do - expect { subject.execute(build) } - .not_to change { runner.ensure_runner_queue_value } + expect { subject.execute(build) }. + not_to change { runner.ensure_runner_queue_value } end end end diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb index 3e0a0e95870..35e6e139238 100644 --- a/spec/services/files/update_service_spec.rb +++ b/spec/services/files/update_service_spec.rb @@ -32,8 +32,8 @@ describe Files::UpdateService do let(:last_commit_sha) { "foo" } it "returns a hash with the correct error message and a :error status " do - expect { subject.execute } - .to raise_error(Files::UpdateService::FileChangedError, + expect { subject.execute }. + to raise_error(Files::UpdateService::FileChangedError, "You are attempting to update a file that has changed since you started editing it.") end end diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index d4fc4611bed..2a0f00ce937 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -145,8 +145,8 @@ describe GitPushService, services: true do context "Updates merge requests" do it "when pushing a new branch for the first time" do - expect(UpdateMergeRequestsWorker).to receive(:perform_async) - .with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') + expect(UpdateMergeRequestsWorker).to receive(:perform_async). + with(project.id, user.id, @blankrev, 'newrev', 'refs/heads/master') execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master' ) end end @@ -263,8 +263,8 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -321,8 +321,8 @@ describe GitPushService, services: true do committed_date: commit_time ) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(commit) allow(project.repository).to receive(:commits_between).and_return([commit]) end @@ -357,11 +357,11 @@ describe GitPushService, services: true do author_email: commit_author.email ) - allow(project.repository).to receive(:commits_between) - .and_return([closing_commit]) + allow(project.repository).to receive(:commits_between). + and_return([closing_commit]) - allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit) - .and_return(closing_commit) + allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit). + and_return(closing_commit) project.team << [commit_author, :master] end @@ -383,8 +383,8 @@ describe GitPushService, services: true do end it "doesn't close issues when external issue tracker is in use" do - allow_any_instance_of(Project).to receive(:default_issues_tracker?) - .and_return(false) + allow_any_instance_of(Project).to receive(:default_issues_tracker?). + and_return(false) external_issue_tracker = double(title: 'My Tracker', issue_path: issue.iid, reference_pattern: project.issue_reference_pattern) allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(external_issue_tracker) @@ -577,13 +577,13 @@ describe GitPushService, services: true do commit = double(:commit) diff = double(:diff, new_path: 'README.md') - expect(commit).to receive(:raw_diffs).with(deltas_only: true) - .and_return([diff]) + expect(commit).to receive(:raw_diffs).with(deltas_only: true). + and_return([diff]) service.push_commits = [commit] - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, %i(readme), %i(commit_count repository_size)) + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, %i(readme), %i(commit_count repository_size)) service.update_caches end @@ -595,9 +595,9 @@ describe GitPushService, services: true do end it 'does not flush any conditional caches' do - expect(ProjectCacheWorker).to receive(:perform_async) - .with(project.id, [], %i(commit_count repository_size)) - .and_call_original + expect(ProjectCacheWorker).to receive(:perform_async). + with(project.id, [], %i(commit_count repository_size)). + and_call_original service.update_caches end @@ -614,8 +614,8 @@ describe GitPushService, services: true do end it 'only schedules a limited number of commits' do - allow(service).to receive(:push_commits) - .and_return(Array.new(1000, double(:commit, to_hash: {}))) + allow(service).to receive(:push_commits). + and_return(Array.new(1000, double(:commit, to_hash: {}))) expect(ProcessCommitWorker).to receive(:perform_async).exactly(100).times diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index 0475f38fe5e..87da8581e68 100644 --- a/spec/services/issuable/bulk_update_service_spec.rb +++ b/spec/services/issuable/bulk_update_service_spec.rb @@ -5,8 +5,8 @@ describe Issuable::BulkUpdateService, services: true do let(:project) { create(:empty_project, namespace: user.namespace) } def bulk_update(issues, extra_params = {}) - bulk_update_params = extra_params - .reverse_merge(issuable_ids: Array(issues).map(&:id).join(',')) + bulk_update_params = extra_params. + reverse_merge(issuable_ids: Array(issues).map(&:id).join(',')) Issuable::BulkUpdateService.new(project, user, bulk_update_params).execute('issue') end @@ -65,22 +65,22 @@ describe Issuable::BulkUpdateService, services: true do assignee = create(:user) project.team << [assignee, :developer] - expect { bulk_update(issue, assignee_id: assignee.id) } - .to change { issue.reload.assignee }.from(user).to(assignee) + expect { bulk_update(issue, assignee_id: assignee.id) }. + to change { issue.reload.assignee }.from(user).to(assignee) end end context "when the new assignee ID is #{IssuableFinder::NONE}" do it "unassigns the issues" do - expect { bulk_update(issue, assignee_id: IssuableFinder::NONE) } - .to change { issue.reload.assignee }.to(nil) + expect { bulk_update(issue, assignee_id: IssuableFinder::NONE) }. + to change { issue.reload.assignee }.to(nil) end end context 'when the new assignee ID is not present' do it 'does not unassign' do - expect { bulk_update(issue, assignee_id: nil) } - .not_to change { issue.reload.assignee } + expect { bulk_update(issue, assignee_id: nil) }. + not_to change { issue.reload.assignee } end end end @@ -97,8 +97,8 @@ describe Issuable::BulkUpdateService, services: true do end it 'updates the issue milestone' do - expect { bulk_update(issue, milestone_id: milestone.id) } - .to change { issue.reload.milestone }.from(nil).to(milestone) + expect { bulk_update(issue, milestone_id: milestone.id) }. + to change { issue.reload.milestone }.from(nil).to(milestone) end end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 8f5bd4566ec..7a54373963e 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -18,26 +18,26 @@ describe Issues::CloseService, services: true do let(:service) { described_class.new(project, user) } it 'checks if the user is authorized to update the issue' do - expect(service).to receive(:can?).with(user, :update_issue, issue) - .and_call_original + expect(service).to receive(:can?).with(user, :update_issue, issue). + and_call_original service.execute(issue) end it 'does not close the issue when the user is not authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue) - .and_return(false) + allow(service).to receive(:can?).with(user, :update_issue, issue). + and_return(false) expect(service).not_to receive(:close_issue) expect(service.execute(issue)).to eq(issue) end it 'closes the issue when the user is authorized to do so' do - allow(service).to receive(:can?).with(user, :update_issue, issue) - .and_return(true) + allow(service).to receive(:can?).with(user, :update_issue, issue). + and_return(true) - expect(service).to receive(:close_issue) - .with(issue, commit: nil, notifications: true, system_note: true) + expect(service).to receive(:close_issue). + with(issue, commit: nil, notifications: true, system_note: true) service.execute(issue) end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index db196ed5751..59c0fa50994 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -188,8 +188,8 @@ describe Issues::MoveService, services: true do let(:new_note) { new_issue.notes.first } it 'rewrites references using a cross reference to old project' do - expect(new_note.note) - .to eq "Note with reference to merge request #{old_project.to_reference(new_project)}!1" + expect(new_note.note). + to eq "Note with reference to merge request #{old_project.to_reference(new_project)}!1" end end @@ -201,8 +201,8 @@ describe Issues::MoveService, services: true do it 'rewrites uploads in description' do expect(new_issue.description).not_to eq description - expect(new_issue.description) - .to match(/Text and #{FileUploader::MARKDOWN_PATTERN}/) + expect(new_issue.description). + to match(/Text and #{FileUploader::MARKDOWN_PATTERN}/) expect(new_issue.description).not_to include uploader.secret end end @@ -216,8 +216,8 @@ describe Issues::MoveService, services: true do let(:description) { "Some description #{another_issue.to_reference}" } it 'rewrites referenced issues creating cross project reference' do - expect(new_issue.description) - .to eq "Some description #{another_issue.to_reference(new_project)}" + expect(new_issue.description). + to eq "Some description #{another_issue.to_reference(new_project)}" end end @@ -226,8 +226,8 @@ describe Issues::MoveService, services: true do let(:description) { "Some description #{user.to_reference}" } it "doesn't throw any errors for issues containing user references" do - expect(new_issue.description) - .to eq "Some description #{user.to_reference}" + expect(new_issue.description). + to eq "Some description #{user.to_reference}" end end end @@ -236,8 +236,8 @@ describe Issues::MoveService, services: true do let(:new_project) { old_project } it 'raises error' do - expect { move_service.execute(old_issue, new_project) } - .to raise_error(StandardError, /Cannot move issue/) + expect { move_service.execute(old_issue, new_project) }. + to raise_error(StandardError, /Cannot move issue/) end end end diff --git a/spec/services/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb index 500afdfb916..4b90ad19640 100644 --- a/spec/services/labels/promote_service_spec.rb +++ b/spec/services/labels/promote_service_spec.rb @@ -66,9 +66,9 @@ describe Labels::PromoteService, services: true do end it 'recreates the label as a group label' do - expect { service.execute(project_label_1_1) } - .to change(project_1.labels, :count).by(-1) - .and change(group_1.labels, :count).by(1) + expect { service.execute(project_label_1_1) }. + to change(project_1.labels, :count).by(-1). + and change(group_1.labels, :count).by(1) expect(new_label).not_to be_nil end diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb index e6160e0ad42..574df6e0f42 100644 --- a/spec/services/members/destroy_service_spec.rb +++ b/spec/services/members/destroy_service_spec.rb @@ -104,8 +104,8 @@ describe Members::DestroyService, services: true do let(:params) { { id: project.members.find_by!(user_id: user.id).id } } it 'destroys the member' do - expect { described_class.new(project, user, params).execute } - .to change { project.members.count }.by(-1) + expect { described_class.new(project, user, params).execute }. + to change { project.members.count }.by(-1) end end end diff --git a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb index d80fb8a1af1..881458c190f 100644 --- a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb +++ b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb @@ -29,9 +29,9 @@ describe MergeRequests::AddTodoWhenBuildFailsService do end before do - allow_any_instance_of(MergeRequest) - .to receive(:head_pipeline) - .and_return(pipeline) + allow_any_instance_of(MergeRequest). + to receive(:head_pipeline). + and_return(pipeline) allow(service).to receive(:todo_service).and_return(todo_service) end @@ -113,9 +113,9 @@ describe MergeRequests::AddTodoWhenBuildFailsService do it 'resolves todos about failed builds for pipeline' do service.close_all(pipeline) - expect(todo_service) - .to have_received(:merge_request_build_retried) - .with(merge_request) + expect(todo_service). + to have_received(:merge_request_build_retried). + with(merge_request) end end @@ -125,8 +125,8 @@ describe MergeRequests::AddTodoWhenBuildFailsService do it 'does not resolve any todos about failed builds' do service.close_all(pipeline) - expect(todo_service) - .not_to have_received(:merge_request_build_retried) + expect(todo_service). + not_to have_received(:merge_request_build_retried) end end end diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index abc266b3aa7..d55a7657c0e 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -30,8 +30,8 @@ describe MergeRequests::CloseService, services: true do it { expect(@merge_request).to be_closed } it 'executes hooks with close action' do - expect(service).to have_received(:execute_hooks) - .with(@merge_request, 'close') + expect(service).to have_received(:execute_hooks). + with(@merge_request, 'close') end it 'sends email to user2 about assign of new merge_request' do diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 1dcb4f6b3ee..d96f819e66a 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -139,9 +139,9 @@ describe MergeRequests::MergeService, services: true do end it 'removes the source branch' do - expect(DeleteBranchService).to receive(:new) - .with(merge_request.source_project, merge_request.author) - .and_call_original + expect(DeleteBranchService).to receive(:new). + with(merge_request.source_project, merge_request.author). + and_call_original service.execute(merge_request) end end diff --git a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb index f92978a33a3..65c08ce15f7 100644 --- a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb +++ b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb @@ -27,9 +27,9 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do context 'first time enabling' do before do - allow(merge_request) - .to receive(:head_pipeline) - .and_return(pipeline) + allow(merge_request). + to receive(:head_pipeline). + and_return(pipeline) service.execute(merge_request) end @@ -52,11 +52,11 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch) } before do - allow(mr_merge_if_green_enabled).to receive(:head_pipeline) - .and_return(pipeline) + allow(mr_merge_if_green_enabled).to receive(:head_pipeline). + and_return(pipeline) - allow(mr_merge_if_green_enabled).to receive(:mergeable?) - .and_return(true) + allow(mr_merge_if_green_enabled).to receive(:mergeable?). + and_return(true) allow(pipeline).to receive(:success?).and_return(true) end @@ -152,9 +152,9 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do before do # This behavior of MergeRequest: we instantiate a new object # - allow_any_instance_of(MergeRequest) - .to receive(:head_pipeline) - .and_wrap_original do + allow_any_instance_of(MergeRequest). + to receive(:head_pipeline). + and_wrap_original do Ci::Pipeline.find(pipeline.id) end end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index af951588fc6..983dac6efdb 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -56,8 +56,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks) - .with(@merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks). + with(@merge_request, 'update', @oldrev) end it { expect(@merge_request.notes).not_to be_empty } @@ -115,8 +115,8 @@ describe MergeRequests::RefreshService, services: true do end it 'executes hooks with update action' do - expect(refresh_service).to have_received(:execute_hooks) - .with(@fork_merge_request, 'update', @oldrev) + expect(refresh_service).to have_received(:execute_hooks). + with(@fork_merge_request, 'update', @oldrev) end it { expect(@merge_request.notes).to be_empty } @@ -191,8 +191,8 @@ describe MergeRequests::RefreshService, services: true do let(:refresh_service) { service.new(@fork_project, @user) } it 'refreshes the merge request' do - expect(refresh_service).to receive(:execute_hooks) - .with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) + expect(refresh_service).to receive(:execute_hooks). + with(@fork_merge_request, 'update', Gitlab::Git::BLANK_SHA) allow_any_instance_of(Repository).to receive(:merge_base).and_return(@oldrev) refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, 'refs/heads/master') diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index 3fda94a8bc5..a99d4eac9bd 100644 --- a/spec/services/merge_requests/reopen_service_spec.rb +++ b/spec/services/merge_requests/reopen_service_spec.rb @@ -29,8 +29,8 @@ describe MergeRequests::ReopenService, services: true do it { expect(merge_request).to be_reopened } it 'executes hooks with reopen action' do - expect(service).to have_received(:execute_hooks) - .with(merge_request, 'reopen') + expect(service).to have_received(:execute_hooks). + with(merge_request, 'reopen') end it 'sends email to user2 about reopen of merge_request' do diff --git a/spec/services/merge_requests/resolve_service_spec.rb b/spec/services/merge_requests/resolve_service_spec.rb index b7f475597b4..57b1c088ce4 100644 --- a/spec/services/merge_requests/resolve_service_spec.rb +++ b/spec/services/merge_requests/resolve_service_spec.rb @@ -58,8 +58,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)) - .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + expect(merge_request.source_branch_head.parents.map(&:id)). + to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 824be604a34828eb682305f0d963056cfac87b2d)) end end @@ -84,8 +84,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request_from_fork.source_branch_head.parents.map(&:id)) - .to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', + expect(merge_request_from_fork.source_branch_head.parents.map(&:id)). + to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', target_head]) end end @@ -124,8 +124,8 @@ describe MergeRequests::ResolveService do end it 'creates a commit with the correct parents' do - expect(merge_request.source_branch_head.parents.map(&:id)) - .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 + expect(merge_request.source_branch_head.parents.map(&:id)). + to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06 824be604a34828eb682305f0d963056cfac87b2d)) end @@ -158,8 +158,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingResolution error' do - expect { service.execute(merge_request) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(merge_request) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -184,8 +184,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingResolution error' do - expect { service.execute(merge_request) } - .to raise_error(Gitlab::Conflict::File::MissingResolution) + expect { service.execute(merge_request) }. + to raise_error(Gitlab::Conflict::File::MissingResolution) end end @@ -206,8 +206,8 @@ describe MergeRequests::ResolveService do let(:service) { MergeRequests::ResolveService.new(project, user, invalid_params) } it 'raises a MissingFiles error' do - expect { service.execute(merge_request) } - .to raise_error(MergeRequests::ResolveService::MissingFiles) + expect { service.execute(merge_request) }. + to raise_error(MergeRequests::ResolveService::MissingFiles) end end end diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index b67874ed4c3..7d73c0ea5d0 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -68,8 +68,8 @@ describe MergeRequests::UpdateService, services: true do it { expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') } it 'executes hooks with update action' do - expect(service).to have_received(:execute_hooks) - .with(@merge_request, 'update') + expect(service).to have_received(:execute_hooks). + with(@merge_request, 'update') end it 'sends email to user2 about assign of new merge request and email to user3 about merge request unassignment' do @@ -171,8 +171,8 @@ describe MergeRequests::UpdateService, services: true do ref: merge_request.source_branch, sha: merge_request.diff_head_sha) - expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user) - .and_return(service_mock) + expect(MergeRequests::MergeWhenPipelineSucceedsService).to receive(:new).with(project, user). + and_return(service_mock) expect(service_mock).to receive(:execute).with(merge_request) end diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb index 471ba78714b..57a5aa5cedc 100644 --- a/spec/services/projects/housekeeping_service_spec.rb +++ b/spec/services/projects/housekeeping_service_spec.rb @@ -66,14 +66,14 @@ describe Projects::HousekeepingService do allow(subject).to receive(:lease_key).and_return(:the_lease_key) # At push 200 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid) - .exactly(1).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :gc, :the_lease_key, :the_uuid). + exactly(1).times # At push 50, 100, 150 - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid) - .exactly(3).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :full_repack, :the_lease_key, :the_uuid). + exactly(3).times # At push 10, 20, ... (except those above) - expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid) - .exactly(16).times + expect(GitGarbageCollectWorker).to receive(:perform_async).with(project.id, :incremental_repack, :the_lease_key, :the_uuid). + exactly(16).times 201.times do subject.increment! diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index 297837537a3..ab6e8f537ba 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -73,18 +73,18 @@ describe Projects::ImportService, services: true do end it 'flushes various caches' do - expect_any_instance_of(Gitlab::Shell).to receive(:import_repository) - .with(project.repository_storage_path, project.path_with_namespace, project.import_url) - .and_return(true) + expect_any_instance_of(Gitlab::Shell).to receive(:import_repository). + with(project.repository_storage_path, project.path_with_namespace, project.import_url). + and_return(true) - expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute) - .and_return(true) + expect_any_instance_of(Gitlab::GithubImport::Importer).to receive(:execute). + and_return(true) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_emptiness_caches). + and_call_original - expect_any_instance_of(Repository).to receive(:expire_exists_cache) - .and_call_original + expect_any_instance_of(Repository).to receive(:expire_exists_cache). + and_call_original subject.execute end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index b6b7f94061e..5c6fbea8d0e 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -7,10 +7,10 @@ describe Projects::TransferService, services: true do context 'namespace -> namespace' do before do - allow_any_instance_of(Gitlab::UploadsTransfer) - .to receive(:move_project).and_return(true) - allow_any_instance_of(Gitlab::PagesTransfer) - .to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::UploadsTransfer). + to receive(:move_project).and_return(true) + allow_any_instance_of(Gitlab::PagesTransfer). + to receive(:move_project).and_return(true) group.add_owner(user) @result = transfer_project(project, user, group) end @@ -102,9 +102,9 @@ describe Projects::TransferService, services: true do end it 'only schedules a single job for every user' do - expect(UserProjectAccessChangedService).to receive(:new) - .with([owner.id, group_member.id]) - .and_call_original + expect(UserProjectAccessChangedService).to receive(:new). + with([owner.id, group_member.id]). + and_call_original transfer_project(project, owner, group) end diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb index d34652bd7ac..23f5555d3e0 100644 --- a/spec/services/projects/unlink_fork_service_spec.rb +++ b/spec/services/projects/unlink_fork_service_spec.rb @@ -12,9 +12,9 @@ describe Projects::UnlinkForkService, services: true do let(:mr_close_service) { MergeRequests::CloseService.new(fork_project, user) } before do - allow(MergeRequests::CloseService).to receive(:new) - .with(fork_project, user) - .and_return(mr_close_service) + allow(MergeRequests::CloseService).to receive(:new). + with(fork_project, user). + and_return(mr_close_service) end it 'close all pending merge requests' do diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index dfa5175b7d8..eca5a418f2a 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -253,8 +253,8 @@ describe SystemNoteService, services: true do it_behaves_like 'a system note' it 'sets the note text' do - expect(subject.note) - .to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" + expect(subject.note). + to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**" end end end @@ -388,8 +388,8 @@ describe SystemNoteService, services: true do context 'when mentioner is not a MergeRequest' do it 'is falsey' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_falsey end end @@ -399,14 +399,14 @@ describe SystemNoteService, services: true do it 'is truthy when noteable is in commits' do expect(mentioner).to receive(:commits).and_return([noteable]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_truthy end it 'is falsey when noteable is not in commits' do expect(mentioner).to receive(:commits).and_return([]) - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_falsey + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_falsey end end @@ -414,8 +414,8 @@ describe SystemNoteService, services: true do let(:noteable) { ExternalIssue.new('EXT-1234', project) } it 'is truthy' do mentioner = noteable.dup - expect(described_class.cross_reference_disallowed?(noteable, mentioner)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(noteable, mentioner)). + to be_truthy end end @@ -425,13 +425,13 @@ describe SystemNoteService, services: true do it 'is truthy when issue is closed' do issue.close - expect(described_class.cross_reference_disallowed?(issue, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_truthy end it 'is falsey when issue is open' do - expect(described_class.cross_reference_disallowed?(issue, project.commit)) - .to be_falsy + expect(described_class.cross_reference_disallowed?(issue, project.commit)). + to be_falsy end end @@ -441,20 +441,20 @@ describe SystemNoteService, services: true do it 'is truthy when merge request is closed' do allow(merge_request).to receive(:closed?).and_return(:true) - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy end it 'is truthy when merge request is merged' do allow(merge_request).to receive(:closed?).and_return(:true) - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_truthy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_truthy end it 'is falsey when merge request is open' do - expect(described_class.cross_reference_disallowed?(merge_request, project.commit)) - .to be_falsy + expect(described_class.cross_reference_disallowed?(merge_request, project.commit)). + to be_falsy end end end @@ -470,13 +470,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)) - .to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)). + to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit1)) - .to be_falsey + expect(described_class.cross_reference_exists?(noteable, commit1)). + to be_falsey end context 'legacy capitalized cross reference' do @@ -487,8 +487,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(noteable, commit0)) - .to be_truthy + expect(described_class.cross_reference_exists?(noteable, commit0)). + to be_truthy end end end @@ -500,13 +500,13 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)) - .to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)). + to be_truthy end it 'is falsey when not already mentioned' do - expect(described_class.cross_reference_exists?(commit1, commit0)) - .to be_falsey + expect(described_class.cross_reference_exists?(commit1, commit0)). + to be_falsey end context 'legacy capitalized cross reference' do @@ -517,8 +517,8 @@ describe SystemNoteService, services: true do end it 'is truthy when already mentioned' do - expect(described_class.cross_reference_exists?(commit0, commit1)) - .to be_truthy + expect(described_class.cross_reference_exists?(commit0, commit1)). + to be_truthy end end end @@ -533,8 +533,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)) - .to be true + expect(described_class.cross_reference_exists?(noteable, commit2)). + to be true end context 'legacy capitalized cross reference' do @@ -544,8 +544,8 @@ describe SystemNoteService, services: true do end it 'is true when a fork mentions an external issue' do - expect(described_class.cross_reference_exists?(noteable, commit2)) - .to be true + expect(described_class.cross_reference_exists?(noteable, commit2)). + to be true end end end @@ -771,8 +771,8 @@ describe SystemNoteService, services: true do it 'creates a new note in the discussion' do # we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded. - expect { SystemNoteService.discussion_continued_in_issue(discussion, project, user, issue) } - .to change { reloaded_merge_request.discussions.first.notes.size }.by(1) + expect { SystemNoteService.discussion_continued_in_issue(discussion, project, user, issue) }. + to change { reloaded_merge_request.discussions.first.notes.size }.by(1) end it 'mentions the created issue in the system note' do diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb index 4bb8a0ec290..5478b8c9ec0 100644 --- a/spec/services/tags/create_service_spec.rb +++ b/spec/services/tags/create_service_spec.rb @@ -26,9 +26,9 @@ describe Tags::CreateService, services: true do context 'when tag already exists' do it 'returns an error' do - expect(repository).to receive(:add_tag) - .with(user, 'v1.1.0', 'master', 'Foo') - .and_raise(Rugged::TagError) + expect(repository).to receive(:add_tag). + with(user, 'v1.1.0', 'master', 'Foo'). + and_raise(Rugged::TagError) response = service.execute('v1.1.0', 'master', 'Foo') @@ -39,9 +39,9 @@ describe Tags::CreateService, services: true do context 'when pre-receive hook fails' do it 'returns an error' do - expect(repository).to receive(:add_tag) - .with(user, 'v1.1.0', 'master', 'Foo') - .and_raise(GitHooksService::PreReceiveError, 'something went wrong') + expect(repository).to receive(:add_tag). + with(user, 'v1.1.0', 'master', 'Foo'). + and_raise(GitHooksService::PreReceiveError, 'something went wrong') response = service.execute('v1.1.0', 'master', 'Foo') diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 9f24cc0f3f2..6dfcb702510 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -768,15 +768,15 @@ describe TodoService, services: true do create(:todo, :mentioned, user: john_doe, target: issue, project: project) todos = TodosFinder.new(john_doe, {}).execute - expect { TodoService.new.mark_todos_as_done(todos, john_doe) } - .to change { john_doe.todos.done.count }.from(0).to(1) + expect { TodoService.new.mark_todos_as_done(todos, john_doe) }. + to change { john_doe.todos.done.count }.from(0).to(1) end it 'marks an array of todos as done' do todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect { TodoService.new.mark_todos_as_done([todo], john_doe) } - .to change { todo.reload.state }.from('pending').to('done') + expect { TodoService.new.mark_todos_as_done([todo], john_doe) }. + to change { todo.reload.state }.from('pending').to('done') end it 'returns the number of updated todos' do # Needed on API diff --git a/spec/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb index 14a5e40350a..b4efe7de431 100644 --- a/spec/services/user_project_access_changed_service_spec.rb +++ b/spec/services/user_project_access_changed_service_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe UserProjectAccessChangedService do describe '#execute' do it 'schedules the user IDs' do - expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait) - .with([[1], [2]]) + expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait). + with([[1], [2]]) described_class.new([1, 2]).execute end diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb index 0a527c7c5d1..690fe979492 100644 --- a/spec/services/users/refresh_authorized_projects_service_spec.rb +++ b/spec/services/users/refresh_authorized_projects_service_spec.rb @@ -6,17 +6,17 @@ describe Users::RefreshAuthorizedProjectsService do let(:service) { described_class.new(user) } def create_authorization(project, user, access_level = Gitlab::Access::MASTER) - ProjectAuthorization - .create!(project: project, user: user, access_level: access_level) + ProjectAuthorization. + create!(project: project, user: user, access_level: access_level) end describe '#execute', :redis do it 'refreshes the authorizations using a lease' do - expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain) - .and_return('foo') + expect_any_instance_of(Gitlab::ExclusiveLease).to receive(:try_obtain). + and_return('foo') - expect(Gitlab::ExclusiveLease).to receive(:cancel) - .with(an_instance_of(String), 'foo') + expect(Gitlab::ExclusiveLease).to receive(:cancel). + with(an_instance_of(String), 'foo') expect(service).to receive(:execute_without_lease) @@ -33,8 +33,8 @@ describe Users::RefreshAuthorizedProjectsService do project2 = create(:empty_project) to_remove = create_authorization(project2, user) - expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations). + with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end @@ -42,8 +42,8 @@ describe Users::RefreshAuthorizedProjectsService do it 'sets the access level of a project to the highest available level' do to_remove = create_authorization(project, user, Gitlab::Access::DEVELOPER) - expect(service).to receive(:update_authorizations) - .with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) + expect(service).to receive(:update_authorizations). + with([to_remove.project_id], [[user.id, project.id, Gitlab::Access::MASTER]]) service.execute_without_lease end |