diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-25 19:09:00 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-27 14:31:53 +0200 |
commit | cddc5cacfb833fbd188d2f5982381f66dd3eee3b (patch) | |
tree | de3e7bda37c8b7f0eb5586695d6d871484dc44e2 /spec/services | |
parent | ddccd24c1388dadc057ac3c4c0a49f3fea847292 (diff) | |
download | gitlab-ce-cddc5cacfb833fbd188d2f5982381f66dd3eee3b.tar.gz |
Use described_class when possible
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/services')
27 files changed, 105 insertions, 105 deletions
diff --git a/spec/services/create_release_service_spec.rb b/spec/services/create_release_service_spec.rb index e4d1c1a8f9d..ac0a0458f56 100644 --- a/spec/services/create_release_service_spec.rb +++ b/spec/services/create_release_service_spec.rb @@ -5,7 +5,7 @@ describe CreateReleaseService do let(:user) { create(:user) } let(:tag_name) { project.repository.tag_names.first } let(:description) { 'Awesome release!' } - let(:service) { CreateReleaseService.new(project, user) } + let(:service) { described_class.new(project, user) } it 'creates a new release' do result = service.execute(tag_name, description) diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb index 561b9d14a0f..00104ae1fd9 100644 --- a/spec/services/event_create_service_spec.rb +++ b/spec/services/event_create_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe EventCreateService do include UserActivitiesHelpers - let(:service) { EventCreateService.new } + let(:service) { described_class.new } describe 'Issues' do describe '#open_issue' do diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb index f1242df7e93..3ce01a995b4 100644 --- a/spec/services/git_hooks_service_spec.rb +++ b/spec/services/git_hooks_service_spec.rb @@ -5,7 +5,7 @@ describe GitHooksService do let(:user) { create(:user) } let(:project) { create(:project, :repository) } - let(:service) { GitHooksService.new } + let(:service) { described_class.new } before do @blankrev = Gitlab::Git::BLANK_SHA diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb index d2baeb7b746..f877c145390 100644 --- a/spec/services/git_tag_push_service_spec.rb +++ b/spec/services/git_tag_push_service_spec.rb @@ -5,7 +5,7 @@ describe GitTagPushService do let(:user) { create(:user) } let(:project) { create(:project, :repository) } - let(:service) { GitTagPushService.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } + let(:service) { described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } let(:oldrev) { Gitlab::Git::BLANK_SHA } let(:newrev) { "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" } # gitlab-test: git rev-parse refs/tags/v1.1.0 @@ -184,7 +184,7 @@ describe GitTagPushService do describe "Webhooks" do context "execute webhooks" do - let(:service) { GitTagPushService.new(project, user, oldrev: 'oldrev', newrev: 'newrev', ref: 'refs/tags/v1.0.0') } + let(:service) { described_class.new(project, user, oldrev: 'oldrev', newrev: 'newrev', ref: 'refs/tags/v1.0.0') } it "when pushing tags" do expect(project).to receive(:execute_hooks) diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb index b3ceb5428cd..3e7aa8c835c 100644 --- a/spec/services/groups/destroy_service_spec.rb +++ b/spec/services/groups/destroy_service_spec.rb @@ -100,7 +100,7 @@ describe Groups::DestroyService do # Kick off the initial group destroy in a new thread, so that # it doesn't share this spec's database transaction. - Thread.new { Groups::DestroyService.new(group, user).async_execute }.join(5) + Thread.new { described_class.new(group, user).async_execute }.join(5) group_record = run_with_new_database_connection do |conn| conn.execute("SELECT * FROM namespaces WHERE id = #{group.id}").first diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 17d4a072e3d..eec2096fa34 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -488,7 +488,7 @@ describe Issues::UpdateService do context 'updating mentions' do let(:mentionable) { issue } - include_examples 'updating mentions', Issues::UpdateService + include_examples 'updating mentions', described_class end context 'duplicate issue' do diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/create_service_spec.rb index 0fa7b5199fe..ecb88653001 100644 --- a/spec/services/labels/create_service_spec.rb +++ b/spec/services/labels/create_service_spec.rb @@ -17,7 +17,7 @@ describe Labels::CreateService do context 'in a project' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(project: project) + label = described_class.new(params_with(hex_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -26,7 +26,7 @@ describe Labels::CreateService do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(project: project) + label = described_class.new(params_with(named_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -35,7 +35,7 @@ describe Labels::CreateService do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(project: project) + label = described_class.new(params_with(upcase_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -44,7 +44,7 @@ describe Labels::CreateService do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(project: project) + label = described_class.new(params_with(spaced_color)).execute(project: project) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -53,7 +53,7 @@ describe Labels::CreateService do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(project: project) + label = described_class.new(params_with(unknown_color)).execute(project: project) expect(label).not_to be_persisted end @@ -61,7 +61,7 @@ describe Labels::CreateService do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(project: project) + label = described_class.new(params_with(no_color)).execute(project: project) expect(label).not_to be_persisted end @@ -71,7 +71,7 @@ describe Labels::CreateService do context 'in a group' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(group: group) + label = described_class.new(params_with(hex_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -80,7 +80,7 @@ describe Labels::CreateService do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(group: group) + label = described_class.new(params_with(named_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -89,7 +89,7 @@ describe Labels::CreateService do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(group: group) + label = described_class.new(params_with(upcase_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -98,7 +98,7 @@ describe Labels::CreateService do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(group: group) + label = described_class.new(params_with(spaced_color)).execute(group: group) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -107,7 +107,7 @@ describe Labels::CreateService do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(group: group) + label = described_class.new(params_with(unknown_color)).execute(group: group) expect(label).not_to be_persisted end @@ -115,7 +115,7 @@ describe Labels::CreateService do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(group: group) + label = described_class.new(params_with(no_color)).execute(group: group) expect(label).not_to be_persisted end @@ -125,7 +125,7 @@ describe Labels::CreateService do context 'in admin area' do context 'with color in hex-code' do it 'creates a label' do - label = Labels::CreateService.new(params_with(hex_color)).execute(template: true) + label = described_class.new(params_with(hex_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -134,7 +134,7 @@ describe Labels::CreateService do context 'with color in allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(named_color)).execute(template: true) + label = described_class.new(params_with(named_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -143,7 +143,7 @@ describe Labels::CreateService do context 'with color in up-case allowed name' do it 'creates a label' do - label = Labels::CreateService.new(params_with(upcase_color)).execute(template: true) + label = described_class.new(params_with(upcase_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -152,7 +152,7 @@ describe Labels::CreateService do context 'with color surrounded by spaces' do it 'creates a label' do - label = Labels::CreateService.new(params_with(spaced_color)).execute(template: true) + label = described_class.new(params_with(spaced_color)).execute(template: true) expect(label).to be_persisted expect(label.color).to eq expected_saved_color @@ -161,7 +161,7 @@ describe Labels::CreateService do context 'with unknown color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(unknown_color)).execute(template: true) + label = described_class.new(params_with(unknown_color)).execute(template: true) expect(label).not_to be_persisted end @@ -169,7 +169,7 @@ describe Labels::CreateService do context 'with no color' do it 'doesn\'t create a label' do - label = Labels::CreateService.new(params_with(no_color)).execute(template: true) + label = described_class.new(params_with(no_color)).execute(template: true) expect(label).not_to be_persisted end diff --git a/spec/services/labels/update_service_spec.rb b/spec/services/labels/update_service_spec.rb index 83ea11f62a6..bb95fe20fbf 100644 --- a/spec/services/labels/update_service_spec.rb +++ b/spec/services/labels/update_service_spec.rb @@ -20,7 +20,7 @@ describe Labels::UpdateService do context 'with color in hex-code' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(hex_color)).execute(@label) + label = described_class.new(params_with(hex_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -29,7 +29,7 @@ describe Labels::UpdateService do context 'with color in allowed name' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(named_color)).execute(@label) + label = described_class.new(params_with(named_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -38,7 +38,7 @@ describe Labels::UpdateService do context 'with color in up-case allowed name' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(upcase_color)).execute(@label) + label = described_class.new(params_with(upcase_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -47,7 +47,7 @@ describe Labels::UpdateService do context 'with color surrounded by spaces' do it 'updates the label' do - label = Labels::UpdateService.new(params_with(spaced_color)).execute(@label) + label = described_class.new(params_with(spaced_color)).execute(@label) expect(label).to be_valid expect(label.reload.color).to eq expected_saved_color @@ -56,7 +56,7 @@ describe Labels::UpdateService do context 'with unknown color' do it 'doesn\'t update the label' do - label = Labels::UpdateService.new(params_with(unknown_color)).execute(@label) + label = described_class.new(params_with(unknown_color)).execute(@label) expect(label).not_to be_valid end @@ -64,7 +64,7 @@ describe Labels::UpdateService do context 'with no color' do it 'doesn\'t update the label' do - label = Labels::UpdateService.new(params_with(no_color)).execute(@label) + label = described_class.new(params_with(no_color)).execute(@label) expect(label).not_to be_valid end diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index 0dcb636dd35..ea192e51f89 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -19,7 +19,7 @@ describe MergeRequests::BuildService do let(:commits) { nil } let(:service) do - MergeRequests::BuildService.new(project, user, + described_class.new(project, user, description: description, source_branch: source_branch, target_branch: target_branch, diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index a8f24b744c2..e593bfeeaf7 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -13,7 +13,7 @@ describe MergeRequests::MergeService do describe '#execute' do context 'valid params' do - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } before do allow(service).to receive(:execute_hooks) @@ -112,7 +112,7 @@ describe MergeRequests::MergeService do context 'closes related todos' do let(:merge_request) { create(:merge_request, assignee: user, author: user) } let(:project) { merge_request.project } - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } let!(:todo) do create(:todo, :assigned, project: project, @@ -136,7 +136,7 @@ describe MergeRequests::MergeService do context 'source branch removal' do context 'when the source branch is protected' do let(:service) do - MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + described_class.new(project, user, should_remove_source_branch: '1') end before do @@ -151,7 +151,7 @@ describe MergeRequests::MergeService do context 'when the source branch is the default branch' do let(:service) do - MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + described_class.new(project, user, should_remove_source_branch: '1') end before do @@ -169,7 +169,7 @@ describe MergeRequests::MergeService do let(:service) do merge_request.merge_params['force_remove_source_branch'] = '1' merge_request.save! - MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') + described_class.new(project, user, commit_message: 'Awesome message') end it 'removes the source branch using the author user' do @@ -182,7 +182,7 @@ describe MergeRequests::MergeService do context 'when MR merger set the source branch to be removed' do let(:service) do - MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message', should_remove_source_branch: '1') + described_class.new(project, user, commit_message: 'Awesome message', should_remove_source_branch: '1') end it 'removes the source branch using the current user' do @@ -196,7 +196,7 @@ describe MergeRequests::MergeService do end context "error handling" do - let(:service) { MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') } + let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } before do allow(Rails.logger).to receive(:error) diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 6c703dded36..2af2485eeed 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe MergeRequests::RefreshService do let(:project) { create(:project, :repository) } let(:user) { create(:user) } - let(:service) { MergeRequests::RefreshService } + let(:service) { described_class } describe '#execute' do before do diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index dddb526e58e..dd3ac9c4ac6 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -55,7 +55,7 @@ describe MergeRequests::UpdateService do } end - let(:service) { MergeRequests::UpdateService.new(project, user, opts) } + let(:service) { described_class.new(project, user, opts) } before do allow(service).to receive(:execute_hooks) @@ -145,7 +145,7 @@ describe MergeRequests::UpdateService do } end - let(:service) { MergeRequests::UpdateService.new(project, user, opts) } + let(:service) { described_class.new(project, user, opts) } context 'without pipeline' do before do @@ -205,7 +205,7 @@ describe MergeRequests::UpdateService do context 'with a non-authorised user' do let(:visitor) { create(:user) } - let(:service) { MergeRequests::UpdateService.new(project, visitor, opts) } + let(:service) { described_class.new(project, visitor, opts) } before do merge_request.update_attribute(:merge_error, 'Error') @@ -348,7 +348,7 @@ describe MergeRequests::UpdateService do opts = { label_ids: [label.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_email(subscriber) @@ -364,7 +364,7 @@ describe MergeRequests::UpdateService do opts = { label_ids: [label.id, label2.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_not_email(subscriber) @@ -375,7 +375,7 @@ describe MergeRequests::UpdateService do opts = { label_ids: [label2.id] } perform_enqueued_jobs do - @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + @merge_request = described_class.new(project, user, opts).execute(merge_request) end should_not_email(subscriber) @@ -386,7 +386,7 @@ describe MergeRequests::UpdateService do context 'updating mentions' do let(:mentionable) { merge_request } - include_examples 'updating mentions', MergeRequests::UpdateService + include_examples 'updating mentions', described_class end context 'when MergeRequest has tasks' do diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb index 0838131a18a..fa0686d8061 100644 --- a/spec/services/milestones/close_service_spec.rb +++ b/spec/services/milestones/close_service_spec.rb @@ -11,7 +11,7 @@ describe Milestones::CloseService do describe '#execute' do before do - Milestones::CloseService.new(project, user, {}).execute(milestone) + described_class.new(project, user, {}).execute(milestone) end it { expect(milestone).to be_valid } diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb index 0c2c41929d7..c6fe8e65912 100644 --- a/spec/services/milestones/create_service_spec.rb +++ b/spec/services/milestones/create_service_spec.rb @@ -14,7 +14,7 @@ describe Milestones::CreateService do description: 'Patch release to fix security issue' } - @milestone = Milestones::CreateService.new(project, user, opts).execute + @milestone = described_class.new(project, user, opts).execute end it { expect(@milestone).to be_valid } diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb index 9044771939d..bf9320e5fce 100644 --- a/spec/services/notes/post_process_service_spec.rb +++ b/spec/services/notes/post_process_service_spec.rb @@ -21,7 +21,7 @@ describe Notes::PostProcessService do expect(project).to receive(:execute_hooks) expect(project).to receive(:execute_services) - Notes::PostProcessService.new(@note).execute + described_class.new(@note).execute end end end diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 30fbe363fed..c98eb87b94e 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe NotificationService do include EmailHelpers - let(:notification) { NotificationService.new } + let(:notification) { described_class.new } let(:assignee) { create(:user) } around(:each) do |example| diff --git a/spec/services/pages_service_spec.rb b/spec/services/pages_service_spec.rb index 7b9c92c0ce7..f8db6900a0a 100644 --- a/spec/services/pages_service_spec.rb +++ b/spec/services/pages_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe PagesService do let(:build) { create(:ci_build) } let(:data) { Gitlab::DataBuilder::Build.build(build) } - let(:service) { PagesService.new(data) } + let(:service) { described_class.new(data) } before do allow(Gitlab.config.pages).to receive(:enabled).and_return(true) diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 6851c96a6d6..85b05ef6d05 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -81,7 +81,7 @@ describe Projects::DestroyService do before do new_user = create(:user) project.team.add_user(new_user, Gitlab::Access::DEVELOPER) - allow_any_instance_of(Projects::DestroyService).to receive(:flush_caches).and_raise(::Redis::CannotConnectError) + allow_any_instance_of(described_class).to receive(:flush_caches).and_raise(::Redis::CannotConnectError) end it 'keeps project team intact upon an error' do @@ -114,7 +114,7 @@ describe Projects::DestroyService do context 'errors' do context 'when `remove_legacy_registry_tags` fails' do before do - expect_any_instance_of(Projects::DestroyService) + expect_any_instance_of(described_class) .to receive(:remove_legacy_registry_tags).and_return(false) end @@ -123,7 +123,7 @@ describe Projects::DestroyService do context 'when `remove_repository` fails' do before do - expect_any_instance_of(Projects::DestroyService) + expect_any_instance_of(described_class) .to receive(:remove_repository).and_return(false) end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 53668c07285..ae32e85b2a7 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -37,7 +37,7 @@ describe Projects::TransferService do end it 'executes system hooks' do - expect_any_instance_of(Projects::TransferService).to receive(:execute_system_hooks) + expect_any_instance_of(described_class).to receive(:execute_system_hooks) transfer_project(project, user, group) end @@ -80,7 +80,7 @@ describe Projects::TransferService do end it "doesn't run system hooks" do - expect_any_instance_of(Projects::TransferService).not_to receive(:execute_system_hooks) + expect_any_instance_of(described_class).not_to receive(:execute_system_hooks) attempt_project_transfer end diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb index cd5b443b043..2ae8d5f7c54 100644 --- a/spec/services/projects/unlink_fork_service_spec.rb +++ b/spec/services/projects/unlink_fork_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::UnlinkForkService do - subject { Projects::UnlinkForkService.new(fork_project, user) } + subject { described_class.new(fork_project, user) } let(:fork_link) { create(:forked_project_link) } let(:fork_project) { fork_link.forked_to_project } diff --git a/spec/services/repair_ldap_blocked_user_service_spec.rb b/spec/services/repair_ldap_blocked_user_service_spec.rb index 57a6162206c..bf79cfe74b7 100644 --- a/spec/services/repair_ldap_blocked_user_service_spec.rb +++ b/spec/services/repair_ldap_blocked_user_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe RepairLdapBlockedUserService do let(:user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } let(:identity) { user.ldap_identity } - subject(:service) { RepairLdapBlockedUserService.new(user) } + subject(:service) { described_class.new(user) } describe '#execute' do it 'changes to normal block after destroying last ldap identity' do diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb index c376cdeb725..de921573b1a 100644 --- a/spec/services/search/global_service_spec.rb +++ b/spec/services/search/global_service_spec.rb @@ -16,7 +16,7 @@ describe Search::GlobalService do describe '#execute' do context 'unauthenticated' do it 'returns public projects only' do - results = Search::GlobalService.new(nil, search: "searchable").execute + results = described_class.new(nil, search: "searchable").execute expect(results.objects('projects')).to match_array [public_project] end @@ -24,19 +24,19 @@ describe Search::GlobalService do context 'authenticated' do it 'returns public, internal and private projects' do - results = Search::GlobalService.new(user, search: "searchable").execute + results = described_class.new(user, search: "searchable").execute expect(results.objects('projects')).to match_array [public_project, found_project, internal_project] end it 'returns only public & internal projects' do - results = Search::GlobalService.new(internal_user, search: "searchable").execute + results = described_class.new(internal_user, search: "searchable").execute expect(results.objects('projects')).to match_array [internal_project, public_project] end it 'namespace name is searchable' do - results = Search::GlobalService.new(user, search: found_project.namespace.path).execute + results = described_class.new(user, search: found_project.namespace.path).execute expect(results.objects('projects')).to match_array [found_project] end diff --git a/spec/services/search/group_service_spec.rb b/spec/services/search/group_service_spec.rb index 3315d74658e..cb3f02d2883 100644 --- a/spec/services/search/group_service_spec.rb +++ b/spec/services/search/group_service_spec.rb @@ -17,7 +17,7 @@ describe Search::GroupService do let!(:project2) { create(:empty_project, :internal, namespace: nested_group, name: "Inner #{term} 2") } let!(:project3) { create(:empty_project, :internal, namespace: nested_group.parent, name: "Outer #{term}") } - let(:results) { Search::GroupService.new(user, search_group, search: term).execute } + let(:results) { described_class.new(user, search_group, search: term).execute } subject { results.objects('projects') } context 'in parent group' do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index a6ec324fe8f..a6ef7561bc8 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -22,7 +22,7 @@ describe SearchService do describe '#project' do context 'when the project is accessible' do it 'returns the project' do - project = SearchService.new(user, project_id: accessible_project.id).project + project = described_class.new(user, project_id: accessible_project.id).project expect(project).to eq accessible_project end @@ -31,7 +31,7 @@ describe SearchService do search_project = create :empty_project search_project.add_guest(user) - project = SearchService.new(user, project_id: search_project.id).project + project = described_class.new(user, project_id: search_project.id).project expect(project).to eq search_project end @@ -39,7 +39,7 @@ describe SearchService do context 'when the project is not accessible' do it 'returns nil' do - project = SearchService.new(user, project_id: inaccessible_project.id).project + project = described_class.new(user, project_id: inaccessible_project.id).project expect(project).to be_nil end @@ -47,7 +47,7 @@ describe SearchService do context 'when there is no project_id' do it 'returns nil' do - project = SearchService.new(user).project + project = described_class.new(user).project expect(project).to be_nil end @@ -57,7 +57,7 @@ describe SearchService do describe '#group' do context 'when the group is accessible' do it 'returns the group' do - group = SearchService.new(user, group_id: accessible_group.id).group + group = described_class.new(user, group_id: accessible_group.id).group expect(group).to eq accessible_group end @@ -65,7 +65,7 @@ describe SearchService do context 'when the group is not accessible' do it 'returns nil' do - group = SearchService.new(user, group_id: inaccessible_group.id).group + group = described_class.new(user, group_id: inaccessible_group.id).group expect(group).to be_nil end @@ -73,7 +73,7 @@ describe SearchService do context 'when there is no group_id' do it 'returns nil' do - group = SearchService.new(user).group + group = described_class.new(user).group expect(group).to be_nil end @@ -83,7 +83,7 @@ describe SearchService do describe '#show_snippets?' do context 'when :snippets is \'true\'' do it 'returns true' do - show_snippets = SearchService.new(user, snippets: 'true').show_snippets? + show_snippets = described_class.new(user, snippets: 'true').show_snippets? expect(show_snippets).to be_truthy end @@ -91,7 +91,7 @@ describe SearchService do context 'when :snippets is not \'true\'' do it 'returns false' do - show_snippets = SearchService.new(user, snippets: 'tru').show_snippets? + show_snippets = described_class.new(user, snippets: 'tru').show_snippets? expect(show_snippets).to be_falsey end @@ -99,7 +99,7 @@ describe SearchService do context 'when :snippets is missing' do it 'returns false' do - show_snippets = SearchService.new(user).show_snippets? + show_snippets = described_class.new(user).show_snippets? expect(show_snippets).to be_falsey end @@ -110,7 +110,7 @@ describe SearchService do context 'with accessible project_id' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, project_id: accessible_project.id, scope: 'notes').scope + scope = described_class.new(user, project_id: accessible_project.id, scope: 'notes').scope expect(scope).to eq 'notes' end @@ -118,7 +118,7 @@ describe SearchService do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, project_id: accessible_project.id, scope: 'projects').scope + scope = described_class.new(user, project_id: accessible_project.id, scope: 'projects').scope expect(scope).to eq 'blobs' end @@ -126,7 +126,7 @@ describe SearchService do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user, project_id: accessible_project.id).scope + scope = described_class.new(user, project_id: accessible_project.id).scope expect(scope).to eq 'blobs' end @@ -136,7 +136,7 @@ describe SearchService do context 'with \'true\' snippets' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, snippets: 'true', scope: 'snippet_titles').scope + scope = described_class.new(user, snippets: 'true', scope: 'snippet_titles').scope expect(scope).to eq 'snippet_titles' end @@ -144,7 +144,7 @@ describe SearchService do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, snippets: 'true', scope: 'projects').scope + scope = described_class.new(user, snippets: 'true', scope: 'projects').scope expect(scope).to eq 'snippet_blobs' end @@ -152,7 +152,7 @@ describe SearchService do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user, snippets: 'true').scope + scope = described_class.new(user, snippets: 'true').scope expect(scope).to eq 'snippet_blobs' end @@ -162,7 +162,7 @@ describe SearchService do context 'with no project_id, no snippets' do context 'and allowed scope' do it 'returns the specified scope' do - scope = SearchService.new(user, scope: 'issues').scope + scope = described_class.new(user, scope: 'issues').scope expect(scope).to eq 'issues' end @@ -170,7 +170,7 @@ describe SearchService do context 'and disallowed scope' do it 'returns the default scope' do - scope = SearchService.new(user, scope: 'blobs').scope + scope = described_class.new(user, scope: 'blobs').scope expect(scope).to eq 'projects' end @@ -178,7 +178,7 @@ describe SearchService do context 'and no scope' do it 'returns the default scope' do - scope = SearchService.new(user).scope + scope = described_class.new(user).scope expect(scope).to eq 'projects' end @@ -189,7 +189,7 @@ describe SearchService do describe '#search_results' do context 'with accessible project_id' do it 'returns an instance of Gitlab::ProjectSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, project_id: accessible_project.id, scope: 'notes', @@ -201,7 +201,7 @@ describe SearchService do context 'with accessible project_id and \'true\' snippets' do it 'returns an instance of Gitlab::ProjectSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, project_id: accessible_project.id, snippets: 'true', @@ -214,7 +214,7 @@ describe SearchService do context 'with \'true\' snippets' do it 'returns an instance of Gitlab::SnippetSearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, snippets: 'true', search: snippet.content).search_results @@ -225,7 +225,7 @@ describe SearchService do context 'with no project_id and no snippets' do it 'returns an instance of Gitlab::SearchResults' do - search_results = SearchService.new( + search_results = described_class.new( user, search: public_project.name).search_results @@ -237,7 +237,7 @@ describe SearchService do describe '#search_objects' do context 'with accessible project_id' do it 'returns objects in the project' do - search_objects = SearchService.new( + search_objects = described_class.new( user, project_id: accessible_project.id, scope: 'notes', @@ -249,7 +249,7 @@ describe SearchService do context 'with accessible project_id and \'true\' snippets' do it 'returns objects in the project' do - search_objects = SearchService.new( + search_objects = described_class.new( user, project_id: accessible_project.id, snippets: 'true', @@ -262,7 +262,7 @@ describe SearchService do context 'with \'true\' snippets' do it 'returns objects in snippets' do - search_objects = SearchService.new( + search_objects = described_class.new( user, snippets: 'true', search: snippet.content).search_objects @@ -273,7 +273,7 @@ describe SearchService do context 'with accessible group_id' do it 'returns objects in the group' do - search_objects = SearchService.new( + search_objects = described_class.new( user, group_id: accessible_group.id, search: group_project.name).search_objects @@ -284,7 +284,7 @@ describe SearchService do context 'with no project_id, group_id or snippets' do it 'returns objects in global' do - search_objects = SearchService.new( + search_objects = described_class.new( user, search: public_project.name).search_objects diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 8cbffc8ec61..230e40de9e0 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -873,21 +873,21 @@ describe TodoService 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) } + expect { described_class.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) } + expect { described_class.new.mark_todos_as_done([todo], john_doe) } .to change { todo.reload.state }.from('pending').to('done') end it 'returns the ids of updated todos' do # Needed on API todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - expect(TodoService.new.mark_todos_as_done([todo], john_doe)).to eq([todo.id]) + expect(described_class.new.mark_todos_as_done([todo], john_doe)).to eq([todo.id]) end context 'when some of the todos are done already' do @@ -895,23 +895,23 @@ describe TodoService do let!(:second_todo) { create(:todo, :mentioned, user: john_doe, target: another_issue, project: project) } it 'returns the ids of those still pending' do - TodoService.new.mark_pending_todos_as_done(issue, john_doe) + described_class.new.mark_pending_todos_as_done(issue, john_doe) - expect(TodoService.new.mark_todos_as_done(Todo.all, john_doe)).to eq([second_todo.id]) + expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([second_todo.id]) end it 'returns an empty array if all are done' do - TodoService.new.mark_pending_todos_as_done(issue, john_doe) - TodoService.new.mark_pending_todos_as_done(another_issue, john_doe) + described_class.new.mark_pending_todos_as_done(issue, john_doe) + described_class.new.mark_pending_todos_as_done(another_issue, john_doe) - expect(TodoService.new.mark_todos_as_done(Todo.all, john_doe)).to eq([]) + expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([]) end end it 'caches the number of todos of a user', :use_clean_rails_memory_store_caching do create(:todo, :mentioned, user: john_doe, target: issue, project: project) todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) - TodoService.new.mark_todos_as_done([todo], john_doe) + described_class.new.mark_todos_as_done([todo], john_doe) expect_any_instance_of(TodosFinder).not_to receive(:execute) diff --git a/spec/services/update_release_service_spec.rb b/spec/services/update_release_service_spec.rb index fecd50e6ca0..dc2d0e2d47a 100644 --- a/spec/services/update_release_service_spec.rb +++ b/spec/services/update_release_service_spec.rb @@ -6,7 +6,7 @@ describe UpdateReleaseService do let(:tag_name) { project.repository.tag_names.first } let(:description) { 'Awesome release!' } let(:new_description) { 'The best release!' } - let(:service) { UpdateReleaseService.new(project, user) } + let(:service) { described_class.new(project, user) } context 'with an existing release' do let(:create_service) { CreateReleaseService.new(project, user) } diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index 8d91050b924..a5de86a0835 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -12,7 +12,7 @@ describe WebHookService do let(:data) do { before: 'oldrev', after: 'newrev', ref: 'ref' } end - let(:service_instance) { WebHookService.new(project_hook, data, 'push_hooks') } + let(:service_instance) { described_class.new(project_hook, data, 'push_hooks') } describe '#execute' do before(:each) do @@ -114,7 +114,7 @@ describe WebHookService do context 'should not log ServiceHooks' do let(:service_hook) { create(:service_hook) } - let(:service_instance) { WebHookService.new(service_hook, data, 'service_hook') } + let(:service_instance) { described_class.new(service_hook, data, 'service_hook') } before do WebMock.stub_request(:post, service_hook.url).to_return(status: 200, body: 'Success') @@ -131,7 +131,7 @@ describe WebHookService do it 'enqueue WebHookWorker' do expect(Sidekiq::Client).to receive(:enqueue).with(WebHookWorker, project_hook.id, data, 'push_hooks') - WebHookService.new(project_hook, data, 'push_hooks').async_execute + described_class.new(project_hook, data, 'push_hooks').async_execute end end end |