diff --git a/.rubocop_todo/rspec/described_class.yml b/.rubocop_todo/rspec/described_class.yml index 7f0db541ab0bd16031e2db0b712314f322b9b000..511f47549ee5141722c1a68c22adc1fb5fbc1577 100644 --- a/.rubocop_todo/rspec/described_class.yml +++ b/.rubocop_todo/rspec/described_class.yml @@ -51,70 +51,7 @@ RSpec/DescribedClass: - 'spec/graphql/graphql_triggers_spec.rb' - 'spec/graphql/types/global_id_type_spec.rb' - 'spec/initializers/google_api_client_spec.rb' - - 'spec/lib/api/entities/project_spec.rb' - - 'spec/lib/api/helpers_spec.rb' - 'spec/lib/feature_spec.rb' - - 'spec/lib/gitlab/asciidoc/html5_converter_spec.rb' - - 'spec/lib/gitlab/buffered_io_spec.rb' - - 'spec/lib/gitlab/checks/snippet_check_spec.rb' - - 'spec/lib/gitlab/ci/tags/bulk_insert_spec.rb' - 'spec/lib/gitlab/ci/variables/collection/item_spec.rb' - - 'spec/lib/gitlab/ci/variables/collection/sort_spec.rb' - - 'spec/lib/gitlab/ci/variables/collection_spec.rb' - - 'spec/lib/gitlab/ci/yaml_processor_spec.rb' - - 'spec/lib/gitlab/config/entry/composable_array_spec.rb' - - 'spec/lib/gitlab/config/entry/composable_hash_spec.rb' - - 'spec/lib/gitlab/current_settings_spec.rb' - - 'spec/lib/gitlab/database/background_migration/health_status_spec.rb' - - 'spec/lib/gitlab/database/load_balancing/host_spec.rb' - - 'spec/lib/gitlab/database/load_balancing/primary_host_spec.rb' - - 'spec/lib/gitlab/database/migrations/lock_retry_mixin_spec.rb' - - 'spec/lib/gitlab/database/reindexing_spec.rb' - - 'spec/lib/gitlab/database/similarity_score_spec.rb' - - 'spec/lib/gitlab/database_spec.rb' - - 'spec/lib/gitlab/email/handler_spec.rb' - - 'spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb' - - 'spec/lib/gitlab/encrypted_configuration_spec.rb' - - 'spec/lib/gitlab/error_tracking/logger_spec.rb' - - 'spec/lib/gitlab/git/blame_spec.rb' - - 'spec/lib/gitlab/git/blob_spec.rb' - - 'spec/lib/gitlab/git/commit_spec.rb' - - 'spec/lib/gitlab/git/compare_spec.rb' - - 'spec/lib/gitlab/git/diff_collection_spec.rb' - 'spec/lib/gitlab/git/repository_spec.rb' - 'spec/lib/gitlab/git/tree_spec.rb' - - 'spec/lib/gitlab/git_access_snippet_spec.rb' - - 'spec/lib/gitlab/gl_repository/repo_type_spec.rb' - - 'spec/lib/gitlab/import_formatter_spec.rb' - - 'spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb' - - 'spec/lib/gitlab/kubernetes/kube_client_spec.rb' - - 'spec/lib/gitlab/pagination/keyset/order_spec.rb' - - 'spec/lib/gitlab/relative_positioning/range_spec.rb' - - 'spec/lib/gitlab/runtime_spec.rb' - - 'spec/lib/gitlab/seeder_spec.rb' - - 'spec/lib/gitlab/sidekiq_middleware/size_limiter/client_spec.rb' - - 'spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb' - - 'spec/lib/gitlab/utils/measuring_spec.rb' - - 'spec/lib/gitlab/webpack/file_loader_spec.rb' - - 'spec/lib/gitlab/webpack/manifest_spec.rb' - - 'spec/lib/gitlab/x509/commit_spec.rb' - - 'spec/lib/gitlab/x509/signature_spec.rb' - - 'spec/lib/service_ping/devops_report_spec.rb' - - 'spec/lib/sidebars/panel_spec.rb' - - 'spec/serializers/context_commits_diff_entity_spec.rb' - - 'spec/services/alert_management/alerts/todo/create_service_spec.rb' - - 'spec/services/auth/dependency_proxy_authentication_service_spec.rb' - - 'spec/services/ci/register_job_service_spec.rb' - - 'spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb' - - 'spec/services/issuable/process_assignees_spec.rb' - - 'spec/services/merge_requests/update_service_spec.rb' - - 'spec/services/notification_service_spec.rb' - - 'spec/services/resource_events/synthetic_label_notes_builder_service_spec.rb' - - 'spec/services/snippets/update_service_spec.rb' - - 'spec/services/user_project_access_changed_service_spec.rb' - - 'spec/services/webauthn/authenticate_service_spec.rb' - - 'spec/services/webauthn/register_service_spec.rb' - - 'spec/support_specs/helpers/graphql_helpers_spec.rb' - - 'spec/validators/html_safety_validator_spec.rb' - - 'spec/workers/bulk_imports/entity_worker_spec.rb' - - 'spec/workers/jira_connect/retry_request_worker_spec.rb' diff --git a/spec/lib/api/entities/project_spec.rb b/spec/lib/api/entities/project_spec.rb index 3a5349bb59b495ab9f08fa6c106d4d6676e84d81..5d18b93228f1361783151023710af43ae2e0233d 100644 --- a/spec/lib/api/entities/project_spec.rb +++ b/spec/lib/api/entities/project_spec.rb @@ -8,7 +8,7 @@ let(:options) { { current_user: current_user } } let(:entity) do - ::API::Entities::Project.new(project, options) + described_class.new(project, options) end subject(:json) { entity.as_json } diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb index f8d40d6e1813d60d600f820976490e2a44a2ce23..40e802990338b0e45b000bbab01a73e33fa2a3c2 100644 --- a/spec/lib/api/helpers_spec.rb +++ b/spec/lib/api/helpers_spec.rb @@ -33,7 +33,7 @@ def app end it 'handles sticking when a user could be found' do - allow_any_instance_of(API::Helpers).to receive(:initial_current_user).and_return(user) + allow_any_instance_of(described_class).to receive(:initial_current_user).and_return(user) expect(ApplicationRecord.sticking) .to receive(:stick_or_unstick_request).with(any_args, :user, 42) @@ -44,7 +44,7 @@ def app end it 'does not handle sticking if no user could be found' do - allow_any_instance_of(API::Helpers).to receive(:initial_current_user).and_return(nil) + allow_any_instance_of(described_class).to receive(:initial_current_user).and_return(nil) expect(ApplicationRecord.sticking) .not_to receive(:stick_or_unstick_request) @@ -55,7 +55,7 @@ def app end it 'returns the user if one could be found' do - allow_any_instance_of(API::Helpers).to receive(:initial_current_user).and_return(user) + allow_any_instance_of(described_class).to receive(:initial_current_user).and_return(user) get 'user' diff --git a/spec/lib/gitlab/asciidoc/html5_converter_spec.rb b/spec/lib/gitlab/asciidoc/html5_converter_spec.rb index de1b3e2af71119f25a13ec1b0aaf4c0de6c6513e..26495ab4bc6486e5f8c5ecdedda372ae16941a9f 100644 --- a/spec/lib/gitlab/asciidoc/html5_converter_spec.rb +++ b/spec/lib/gitlab/asciidoc/html5_converter_spec.rb @@ -7,7 +7,7 @@ it 'appends user-content- prefix on ref (anchor)' do doc = Asciidoctor::Document.new('') anchor = Asciidoctor::Inline.new(doc, :anchor, '', type: :ref, id: 'cross-references') - converter = Gitlab::Asciidoc::Html5Converter.new('gitlab_html5') + converter = described_class.new('gitlab_html5') html = converter.convert_inline_anchor(anchor) expect(html).to eq('<a id="user-content-cross-references"></a>') end diff --git a/spec/lib/gitlab/buffered_io_spec.rb b/spec/lib/gitlab/buffered_io_spec.rb index c6939b819e22aadcc2fd0aca4a51c8b08af8616e..0ec377550c184833520cb271d01c88066475d681 100644 --- a/spec/lib/gitlab/buffered_io_spec.rb +++ b/spec/lib/gitlab/buffered_io_spec.rb @@ -12,7 +12,7 @@ end subject(:readuntil) do - Gitlab::BufferedIo.new(mock_io).readuntil('a', false, start_time) + described_class.new(mock_io).readuntil('a', false, start_time) end it 'does not raise a timeout error' do @@ -38,7 +38,7 @@ context 'when not passing start_time' do subject(:readuntil) do - Gitlab::BufferedIo.new(mock_io).readuntil('a', false) + described_class.new(mock_io).readuntil('a', false) end it 'raises a timeout error' do diff --git a/spec/lib/gitlab/checks/snippet_check_spec.rb b/spec/lib/gitlab/checks/snippet_check_spec.rb index 89417aaca4d164051bdb66708190f940acd4c57e..c43b65d09c554e49745574d2ae88487cadbe236c 100644 --- a/spec/lib/gitlab/checks/snippet_check_spec.rb +++ b/spec/lib/gitlab/checks/snippet_check_spec.rb @@ -13,7 +13,7 @@ let(:creation) { false } let(:deletion) { false } - subject { Gitlab::Checks::SnippetCheck.new(changes, default_branch: default_branch, root_ref: snippet.repository.root_ref, logger: logger) } + subject { described_class.new(changes, default_branch: default_branch, root_ref: snippet.repository.root_ref, logger: logger) } describe '#validate!' do it 'does not raise any error' do diff --git a/spec/lib/gitlab/ci/tags/bulk_insert_spec.rb b/spec/lib/gitlab/ci/tags/bulk_insert_spec.rb index 5ab859241c60dae7ea6dffe5627f4f4cc69fa162..b72a818c16ca23cc7da9c5078a9cede978cf2e69 100644 --- a/spec/lib/gitlab/ci/tags/bulk_insert_spec.rb +++ b/spec/lib/gitlab/ci/tags/bulk_insert_spec.rb @@ -31,7 +31,7 @@ let(:inserter) { instance_double(described_class) } it 'delegates to bulk insert class' do - expect(Gitlab::Ci::Tags::BulkInsert) + expect(described_class) .to receive(:new) .with(statuses) .and_return(inserter) diff --git a/spec/lib/gitlab/ci/variables/collection/sort_spec.rb b/spec/lib/gitlab/ci/variables/collection/sort_spec.rb index 432225c53f09ed5f147ae6e2eff7420b57657886..f798945f64f54ecec05ba38843d49e2d98c5b6f5 100644 --- a/spec/lib/gitlab/ci/variables/collection/sort_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/sort_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection::Sort do describe '#initialize with non-Collection value' do - subject { Gitlab::Ci::Variables::Collection::Sort.new([]) } + subject { described_class.new([]) } it 'raises ArgumentError' do expect { subject }.to raise_error(ArgumentError, /Collection object was expected/) @@ -167,7 +167,7 @@ let(:collection) { Gitlab::Ci::Variables::Collection.new(variables) } - subject { Gitlab::Ci::Variables::Collection::Sort.new(collection).tsort } + subject { described_class.new(collection).tsort } it 'raises TSort::Cyclic' do expect { subject }.to raise_error(TSort::Cyclic) diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb index 006f7c2ebe65c6497ed027eb9daf38370ddd0654..d21190ae297c29d6ffe80025e9fd2b02446cb612 100644 --- a/spec/lib/gitlab/ci/variables/collection_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection_spec.rb @@ -54,7 +54,7 @@ context 'when given an unrecognized type' do it 'raises error' do - expect { Gitlab::Ci::Variables::Collection.fabricate(1) }.to raise_error(ArgumentError) + expect { described_class.fabricate(1) }.to raise_error(ArgumentError) end end end @@ -179,7 +179,7 @@ end describe '#[]' do - subject { Gitlab::Ci::Variables::Collection.new(variables)[var_name] } + subject { described_class.new(variables)[var_name] } shared_examples 'an array access operator' do context 'for a non-existent variable name' do @@ -626,7 +626,7 @@ end let(:errors) { 'circular variable reference detected' } - let(:collection) { Gitlab::Ci::Variables::Collection.new(variables, errors) } + let(:collection) { described_class.new(variables, errors) } subject(:result) { collection.to_s } diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 2c020e76cb66ca50f739eb9494f61b50eaf7a441..dca65127a625332fb0bfbd05ca28943170b73a90 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -152,7 +152,7 @@ module Ci config = YAML.dump({ default: { interruptible: true }, rspec: { script: "rspec" } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute builds = config_processor.builds.select { |b| b[:stage] == "test" } expect(builds.size).to eq(1) @@ -851,7 +851,7 @@ module Ci context 'when `only` has an invalid value' do let(:config) { { rspec: { script: "rspec", stage: "test", only: only } } } - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } context 'when it is integer' do let(:only) { 1 } @@ -875,7 +875,7 @@ module Ci context 'when `except` has an invalid value' do let(:config) { { rspec: { script: "rspec", except: except } } } - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } context 'when it is integer' do let(:except) { 1 } @@ -899,7 +899,7 @@ module Ci describe "Scripts handling" do let(:config_data) { YAML.dump(config) } - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config_data).execute } + let(:config_processor) { described_class.new(config_data).execute } subject(:test_build) { config_processor.builds.find { |build| build[:name] == 'test' } } @@ -1131,7 +1131,7 @@ module Ci before_script: ["pwd"], rspec: { script: "rspec" } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build).to eq({ @@ -1165,7 +1165,7 @@ module Ci command: ["/usr/local/bin/init", "run"] }, "docker:dind"], script: "rspec" } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build).to eq({ @@ -1197,7 +1197,7 @@ module Ci before_script: ["pwd"], rspec: { script: "rspec" } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build).to eq({ @@ -1225,7 +1225,7 @@ module Ci before_script: ["pwd"], rspec: { image: "image:1.0", services: ["postgresql", "docker:dind"], script: "rspec" } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build).to eq({ @@ -1492,7 +1492,7 @@ module Ci end context 'when using `extends`' do - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config).execute } + let(:config_processor) { described_class.new(config).execute } subject { config_processor.builds.first } @@ -1612,7 +1612,7 @@ module Ci } end - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config), opts).execute } + subject { described_class.new(YAML.dump(config), opts).execute } context "when validating a ci config file with no project context" do context "when a single string is provided" do @@ -1744,7 +1744,7 @@ module Ci variables: { 'VAR1' => 1 } }) end - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config).execute } + let(:config_processor) { described_class.new(config).execute } let(:builds) { config_processor.builds } context 'when job is parallelized' do @@ -1860,7 +1860,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -1886,7 +1886,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -1913,7 +1913,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -1952,7 +1952,7 @@ module Ci } ) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -1979,7 +1979,7 @@ module Ci } ) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -2004,7 +2004,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build[:cache]).to eq( @@ -2039,7 +2039,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute rspec_build = config_processor.builds.find { |build| build[:name] == 'rspec' } expect(rspec_build).to eq({ @@ -2076,7 +2076,7 @@ module Ci } }) - config_processor = Gitlab::Ci::YamlProcessor.new(config).execute + config_processor = described_class.new(config).execute builds = config_processor.builds expect(builds.size).to eq(1) @@ -2133,7 +2133,7 @@ module Ci end describe "release" do - let(:processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + let(:processor) { described_class.new(YAML.dump(config)).execute } let(:config) do { stages: %w[build test release], @@ -2179,7 +2179,7 @@ module Ci } end - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } let(:builds) { subject.builds } @@ -2289,7 +2289,7 @@ module Ci } end - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } let(:builds) { subject.builds } @@ -2331,7 +2331,7 @@ module Ci } end - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } context 'no dependencies' do let(:dependencies) {} @@ -2404,7 +2404,7 @@ module Ci } end - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } context 'no needs' do it { is_expected.to be_valid } @@ -2678,7 +2678,7 @@ module Ci end context 'with when/rules' do - subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)).execute } + subject { described_class.new(YAML.dump(config)).execute } let(:config) do { @@ -2798,7 +2798,7 @@ module Ci end describe "Hidden jobs" do - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config).execute } + let(:config_processor) { described_class.new(config).execute } subject { config_processor.builds } @@ -2846,7 +2846,7 @@ module Ci end describe "YAML Alias/Anchor" do - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config).execute } + let(:config_processor) { described_class.new(config).execute } subject { config_processor.builds } @@ -3390,7 +3390,7 @@ module Ci end describe '#execute' do - subject { Gitlab::Ci::YamlProcessor.new(content).execute } + subject { described_class.new(content).execute } context 'when the YAML could not be parsed' do let(:content) { YAML.dump('invalid: yaml: test') } diff --git a/spec/lib/gitlab/config/entry/composable_array_spec.rb b/spec/lib/gitlab/config/entry/composable_array_spec.rb index 77766cb3b0a94f784b3cd343c135ae4fb3ff0a50..d8f00476444b58159ed1e1292945e8913a0341d7 100644 --- a/spec/lib/gitlab/config/entry/composable_array_spec.rb +++ b/spec/lib/gitlab/config/entry/composable_array_spec.rb @@ -47,13 +47,13 @@ expect(entry[0].description).to eq('node definition') expect(entry[0].key).to eq('node') expect(entry[0].metadata).to eq({}) - expect(entry[0].parent.class).to eq(Gitlab::Config::Entry::ComposableArray) + expect(entry[0].parent.class).to eq(described_class) expect(entry[0].value).to eq(DATABASE_SECRET: 'passw0rd') expect(entry[1]).to be_a(Gitlab::Config::Entry::Node) expect(entry[1].description).to eq('node definition') expect(entry[1].key).to eq('node') expect(entry[1].metadata).to eq({}) - expect(entry[1].parent.class).to eq(Gitlab::Config::Entry::ComposableArray) + expect(entry[1].parent.class).to eq(described_class) expect(entry[1].value).to eq(API_TOKEN: 'passw0rd2') end diff --git a/spec/lib/gitlab/config/entry/composable_hash_spec.rb b/spec/lib/gitlab/config/entry/composable_hash_spec.rb index 331c9efc7410210ff5c0bdf0817a5afa8e85c78f..6ce66314098bacef8d1b817b189ddca2e57310fa 100644 --- a/spec/lib/gitlab/config/entry/composable_hash_spec.rb +++ b/spec/lib/gitlab/config/entry/composable_hash_spec.rb @@ -48,19 +48,19 @@ expect(entry[:DATABASE_SECRET].description).to eq('DATABASE_SECRET node definition') expect(entry[:DATABASE_SECRET].key).to eq(:DATABASE_SECRET) expect(entry[:DATABASE_SECRET].metadata).to eq(name: :DATABASE_SECRET) - expect(entry[:DATABASE_SECRET].parent.class).to eq(Gitlab::Config::Entry::ComposableHash) + expect(entry[:DATABASE_SECRET].parent.class).to eq(described_class) expect(entry[:DATABASE_SECRET].value).to eq('passw0rd') expect(entry[:API_TOKEN]).to be_a(Gitlab::Config::Entry::Node) expect(entry[:API_TOKEN].description).to eq('API_TOKEN node definition') expect(entry[:API_TOKEN].key).to eq(:API_TOKEN) expect(entry[:API_TOKEN].metadata).to eq(name: :API_TOKEN) - expect(entry[:API_TOKEN].parent.class).to eq(Gitlab::Config::Entry::ComposableHash) + expect(entry[:API_TOKEN].parent.class).to eq(described_class) expect(entry[:API_TOKEN].value).to eq('passw0rd2') expect(entry[:ACCEPT_PASSWORD]).to be_a(Gitlab::Config::Entry::Node) expect(entry[:ACCEPT_PASSWORD].description).to eq('ACCEPT_PASSWORD node definition') expect(entry[:ACCEPT_PASSWORD].key).to eq(:ACCEPT_PASSWORD) expect(entry[:ACCEPT_PASSWORD].metadata).to eq(name: :ACCEPT_PASSWORD) - expect(entry[:ACCEPT_PASSWORD].parent.class).to eq(Gitlab::Config::Entry::ComposableHash) + expect(entry[:ACCEPT_PASSWORD].parent.class).to eq(described_class) expect(entry[:ACCEPT_PASSWORD].value).to eq(false) end diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb index fda3b07eb823594717c8af8608d8960780f8446e..0e93a85764f840f4dfaaecb21b80d6ffc23a2aa9 100644 --- a/spec/lib/gitlab/current_settings_spec.rb +++ b/spec/lib/gitlab/current_settings_spec.rb @@ -276,7 +276,7 @@ def settings_from_defaults describe '#current_application_settings?', :use_clean_rails_memory_store_caching do before do - allow(Gitlab::CurrentSettings).to receive(:current_application_settings?).and_call_original + allow(described_class).to receive(:current_application_settings?).and_call_original end it 'returns true when settings exist' do diff --git a/spec/lib/gitlab/database/load_balancing/host_spec.rb b/spec/lib/gitlab/database/load_balancing/host_spec.rb index caae06ce43aa0dafea5443c5e8f87cc34aa88785..5ef6d9173c426d6ee38a22e4672d293df1cb925f 100644 --- a/spec/lib/gitlab/database/load_balancing/host_spec.rb +++ b/spec/lib/gitlab/database/load_balancing/host_spec.rb @@ -9,7 +9,7 @@ end let(:host) do - Gitlab::Database::LoadBalancing::Host.new('localhost', load_balancer) + described_class.new('localhost', load_balancer) end before do diff --git a/spec/lib/gitlab/database/load_balancing/primary_host_spec.rb b/spec/lib/gitlab/database/load_balancing/primary_host_spec.rb index 02c9499bedbc92451770ae83630c3460d10c208e..53605d14c1726d81b14c4c7d0b27430eceb6578c 100644 --- a/spec/lib/gitlab/database/load_balancing/primary_host_spec.rb +++ b/spec/lib/gitlab/database/load_balancing/primary_host_spec.rb @@ -9,7 +9,7 @@ ) end - let(:host) { Gitlab::Database::LoadBalancing::PrimaryHost.new(load_balancer) } + let(:host) { described_class.new(load_balancer) } describe '#connection' do it 'returns a connection from the pool' do diff --git a/spec/lib/gitlab/database/migrations/lock_retry_mixin_spec.rb b/spec/lib/gitlab/database/migrations/lock_retry_mixin_spec.rb index 6092d985ce87f8b6e62187edb70c8fcee3039c75..dcc088c2e2136d719d9a2710c989477d05a23898 100644 --- a/spec/lib/gitlab/database/migrations/lock_retry_mixin_spec.rb +++ b/spec/lib/gitlab/database/migrations/lock_retry_mixin_spec.rb @@ -71,7 +71,7 @@ def ddl_transaction(migration, &block) def use_transaction?(migration) receiver.use_transaction?(migration) end - end.prepend(Gitlab::Database::Migrations::LockRetryMixin::ActiveRecordMigratorLockRetries) + end.prepend(described_class) end subject { class_def.new(receiver) } diff --git a/spec/lib/gitlab/database/reindexing_spec.rb b/spec/lib/gitlab/database/reindexing_spec.rb index 4d0e58b0937a51ad04cbf6605cecb8cce32e4219..851fc7ea3cd431a8e799fb0d686e71c6907fb79b 100644 --- a/spec/lib/gitlab/database/reindexing_spec.rb +++ b/spec/lib/gitlab/database/reindexing_spec.rb @@ -99,14 +99,14 @@ end before do - allow(Gitlab::Database::Reindexing).to receive(:cleanup_leftovers!) - allow(Gitlab::Database::Reindexing).to receive(:perform_from_queue).and_return(0) - allow(Gitlab::Database::Reindexing).to receive(:perform_with_heuristic).and_return(0) + allow(described_class).to receive(:cleanup_leftovers!) + allow(described_class).to receive(:perform_from_queue).and_return(0) + allow(described_class).to receive(:perform_with_heuristic).and_return(0) end it 'cleans up leftovers, before consuming the queue' do - expect(Gitlab::Database::Reindexing).to receive(:cleanup_leftovers!).ordered - expect(Gitlab::Database::Reindexing).to receive(:perform_from_queue).ordered + expect(described_class).to receive(:cleanup_leftovers!).ordered + expect(described_class).to receive(:perform_from_queue).ordered subject end @@ -120,8 +120,8 @@ let(:limit) { 1 } it 'does not perform reindexing with heuristic' do - expect(Gitlab::Database::Reindexing).to receive(:perform_from_queue).and_return(limit) - expect(Gitlab::Database::Reindexing).not_to receive(:perform_with_heuristic) + expect(described_class).to receive(:perform_from_queue).and_return(limit) + expect(described_class).not_to receive(:perform_with_heuristic) subject end @@ -131,8 +131,8 @@ let(:limit) { 2 } it 'continues if the queue did not have enough records' do - expect(Gitlab::Database::Reindexing).to receive(:perform_from_queue).ordered.and_return(1) - expect(Gitlab::Database::Reindexing).to receive(:perform_with_heuristic).with(maximum_records: 1).ordered + expect(described_class).to receive(:perform_from_queue).ordered.and_return(1) + expect(described_class).to receive(:perform_with_heuristic).with(maximum_records: 1).ordered subject end diff --git a/spec/lib/gitlab/database/similarity_score_spec.rb b/spec/lib/gitlab/database/similarity_score_spec.rb index cfee70ed20878622f8ed69788434b0093ee881d1..58ea5a5864429c09241f3a5b2cafa05c26cb0241 100644 --- a/spec/lib/gitlab/database/similarity_score_spec.rb +++ b/spec/lib/gitlab/database/similarity_score_spec.rb @@ -25,7 +25,7 @@ end let(:order_expression) do - Gitlab::Database::SimilarityScore.build_expression(search: search, rules: [{ column: Arel.sql('path') }]).to_sql + described_class.build_expression(search: search, rules: [{ column: Arel.sql('path') }]).to_sql end subject { query_result.take(3).map { |row| row['path'] } } @@ -43,7 +43,7 @@ let(:search) { 'text' } let(:order_expression) do - Gitlab::Database::SimilarityScore.build_expression(search: search, rules: []).to_sql + described_class.build_expression(search: search, rules: []).to_sql end it 'orders by a constant 0 value' do @@ -78,7 +78,7 @@ describe 'score multiplier' do let(:order_expression) do - Gitlab::Database::SimilarityScore.build_expression(search: search, rules: + described_class.build_expression(search: search, rules: [ { column: Arel.sql('path'), multiplier: 1 }, { column: Arel.sql('name'), multiplier: 0.8 } @@ -94,13 +94,13 @@ describe 'annotation' do it 'annotates the generated SQL expression' do - expression = Gitlab::Database::SimilarityScore.build_expression(search: 'test', rules: + expression = described_class.build_expression(search: 'test', rules: [ { column: Arel.sql('path'), multiplier: 1 }, { column: Arel.sql('name'), multiplier: 0.8 } ]) - expect(Gitlab::Database::SimilarityScore).to be_order_by_similarity(expression) + expect(described_class).to be_order_by_similarity(expression) end end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 789ae348dc12e242d60e8ef3413edd1bcd494fca..d51319d462b5407c05022c5e2ee31abb4f8653ce 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -215,7 +215,7 @@ expect(Kernel) .to receive(:warn) .with(/You are using PostgreSQL/) - .exactly(Gitlab::Database.database_base_models.length) + .exactly(described_class.database_base_models.length) .times subject @@ -432,21 +432,21 @@ def with_replica_pool_for(base_model) describe '.database_base_models_with_gitlab_shared' do before do - Gitlab::Database.instance_variable_set(:@database_base_models_with_gitlab_shared, nil) + described_class.instance_variable_set(:@database_base_models_with_gitlab_shared, nil) end it 'memoizes the models' do - expect { Gitlab::Database.database_base_models_with_gitlab_shared }.to change { Gitlab::Database.instance_variable_get(:@database_base_models_with_gitlab_shared) }.from(nil) + expect { described_class.database_base_models_with_gitlab_shared }.to change { Gitlab::Database.instance_variable_get(:@database_base_models_with_gitlab_shared) }.from(nil) end end describe '.database_base_models_using_load_balancing' do before do - Gitlab::Database.instance_variable_set(:@database_base_models_using_load_balancing, nil) + described_class.instance_variable_set(:@database_base_models_using_load_balancing, nil) end it 'memoizes the models' do - expect { Gitlab::Database.database_base_models_using_load_balancing }.to change { Gitlab::Database.instance_variable_get(:@database_base_models_using_load_balancing) }.from(nil) + expect { described_class.database_base_models_using_load_balancing }.to change { Gitlab::Database.instance_variable_get(:@database_base_models_using_load_balancing) }.from(nil) end end diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb index d38b7d9c85c8d481332f9c6000c4b91bb262d17b..d3a4d77c58eccd86a4a7d5944690075ecb2cf462 100644 --- a/spec/lib/gitlab/email/handler_spec.rb +++ b/spec/lib/gitlab/email/handler_spec.rb @@ -75,7 +75,7 @@ def handler_for(fixture, mail_key) described_class.for(email, address).class end - expect(matched_handlers.uniq).to match_array(Gitlab::Email::Handler.handlers) + expect(matched_handlers.uniq).to match_array(described_class.handlers) end it 'can pick exactly one handler for each address' do diff --git a/spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb b/spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb index 7dd4ee7e25de3f67e3faff9be5c4e58c061c2a22..2632be980260b8ce62e83d620f252cef11e9b913 100644 --- a/spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb +++ b/spec/lib/gitlab/email/hook/smime_signature_interceptor_spec.rb @@ -36,7 +36,7 @@ end before do - allow(Gitlab::Email::Hook::SmimeSignatureInterceptor).to receive(:certificate).and_return(certificate) + allow(described_class).to receive(:certificate).and_return(certificate) Mail.register_interceptor(described_class) mail.deliver_now diff --git a/spec/lib/gitlab/encrypted_configuration_spec.rb b/spec/lib/gitlab/encrypted_configuration_spec.rb index eadc2cf71a78d67bf6133a7df203f0034a11ec61..95e6d99f41c5781b3ef6a0adaed3aecf4de7b2d6 100644 --- a/spec/lib/gitlab/encrypted_configuration_spec.rb +++ b/spec/lib/gitlab/encrypted_configuration_spec.rb @@ -56,7 +56,7 @@ describe '#write' do it 'encrypts the file using the provided key' do - encryptor = ActiveSupport::MessageEncryptor.new(Gitlab::EncryptedConfiguration.generate_key(credentials_key), cipher: 'aes-256-gcm') + encryptor = ActiveSupport::MessageEncryptor.new(described_class.generate_key(credentials_key), cipher: 'aes-256-gcm') config = described_class.new(content_path: credentials_config_path, base_key: credentials_key) config.write('sample-content') @@ -122,7 +122,7 @@ def encryptor(key) original_key_encryptor = encryptor(credential_key_original) # can read with the initial key latest_key_encryptor = encryptor(credential_key_latest) # can read with the new key both_key_encryptor = encryptor(credential_key_latest) # can read with either key - both_key_encryptor.rotate(Gitlab::EncryptedConfiguration.generate_key(credential_key_original)) + both_key_encryptor.rotate(described_class.generate_key(credential_key_original)) expect(original_key_encryptor.decrypt_and_verify(File.read(config_path_original))).to eq('sample-content1') expect(both_key_encryptor.decrypt_and_verify(File.read(config_path_original))).to eq('sample-content1') diff --git a/spec/lib/gitlab/error_tracking/logger_spec.rb b/spec/lib/gitlab/error_tracking/logger_spec.rb index 1b722fc7896a603b8b8461cfbfff2f7c7c73eefc..e32a3c10cecfae79eeb0a1a0e7d4b7fa68d09bcb 100644 --- a/spec/lib/gitlab/error_tracking/logger_spec.rb +++ b/spec/lib/gitlab/error_tracking/logger_spec.rb @@ -13,7 +13,7 @@ expect(log_formatter).to receive(:generate_log).with(exception, payload).and_return(log_entry) end - expect(Gitlab::ErrorTracking::Logger).to receive(:error).with(log_entry) + expect(described_class).to receive(:error).with(log_entry) described_class.capture_exception(exception, **payload) end diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index 45d88f57c094527b2040947568410505a52a0f00..676ea2663d2cd712394671ea70e3cbf764f702dd 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -9,7 +9,7 @@ let(:path) { 'CONTRIBUTING.md' } let(:range) { nil } - subject(:blame) { Gitlab::Git::Blame.new(repository, sha, path, range: range) } + subject(:blame) { described_class.new(repository, sha, path, range: range) } let(:result) do [].tap do |data| diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index d35d288050ab88c5d460f27227965fcbb722703a..5bb4b84835da068a0fb7a0169f76c773e8e23e4f 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -7,7 +7,7 @@ let_it_be(:repository) { project.repository.raw } describe 'initialize' do - let(:blob) { Gitlab::Git::Blob.new(name: 'test') } + let(:blob) { described_class.new(name: 'test') } it 'handles nil data' do expect(described_class).not_to receive(:gitlab_blob_size) @@ -20,14 +20,14 @@ it 'records blob size' do expect(described_class).to receive(:gitlab_blob_size).and_call_original - Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd') + described_class.new(name: 'test', size: 4, data: 'abcd') end context 'when untruncated' do it 'attempts to record gitlab_blob_truncated_false' do expect(described_class).to receive(:gitlab_blob_truncated_false).and_call_original - Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd') + described_class.new(name: 'test', size: 4, data: 'abcd') end end @@ -35,32 +35,32 @@ it 'attempts to record gitlab_blob_truncated_true' do expect(described_class).to receive(:gitlab_blob_truncated_true).and_call_original - Gitlab::Git::Blob.new(name: 'test', size: 40, data: 'abcd') + described_class.new(name: 'test', size: 40, data: 'abcd') end end end shared_examples '.find' do context 'nil path' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], nil) } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], nil) } it { expect(blob).to eq(nil) } end context 'utf-8 branch' do - let(:blob) { Gitlab::Git::Blob.find(repository, 'Ääh-test-utf-8', "files/ruby/popen.rb") } + let(:blob) { described_class.find(repository, 'Ääh-test-utf-8', "files/ruby/popen.rb") } it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) } end context 'blank path' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], '') } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], '') } it { expect(blob).to eq(nil) } end context 'file in subdir' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "files/ruby/popen.rb") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "files/ruby/popen.rb") } it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) } it { expect(blob.name).to eq(SeedRepo::RubyBlob::NAME) } @@ -72,7 +72,7 @@ end context 'file in root' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], ".gitignore") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], ".gitignore") } it { expect(blob.id).to eq("dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82") } it { expect(blob.name).to eq(".gitignore") } @@ -85,7 +85,7 @@ end context 'file in root with leading slash' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "/.gitignore") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "/.gitignore") } it { expect(blob.id).to eq("dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82") } it { expect(blob.name).to eq(".gitignore") } @@ -97,13 +97,13 @@ end context 'non-exist file' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "missing.rb") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "missing.rb") } it { expect(blob).to be_nil } end context 'six submodule' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], 'six') } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], 'six') } it { expect(blob.id).to eq('409f37c4f05865e4fb208c771485f211a22c4c2d') } it { expect(blob.data).to eq('') } @@ -119,7 +119,7 @@ end context 'large file' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], 'files/images/6049019_460s.jpg') } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], 'files/images/6049019_460s.jpg') } let(:blob_size) { 111803 } let(:stub_limit) { 1000 } @@ -141,7 +141,7 @@ end it 'marks the blob as binary' do - expect(Gitlab::Git::Blob).to receive(:new) + expect(described_class).to receive(:new) .with(hash_including(binary: true)) .and_call_original @@ -167,8 +167,8 @@ end describe '.raw' do - let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } - let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) } + let(:raw_blob) { described_class.raw(repository, SeedRepo::RubyBlob::ID) } + let(:bad_blob) { described_class.raw(repository, SeedRepo::BigCommit::ID) } it { expect(raw_blob.id).to eq(SeedRepo::RubyBlob::ID) } it { expect(raw_blob.data[0..10]).to eq("require \'fi") } @@ -305,7 +305,7 @@ describe '.batch_lfs_pointers' do let(:non_lfs_blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, 'master', 'README.md' @@ -313,7 +313,7 @@ end let(:lfs_blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, TestEnv::BRANCH_SHA['master'], 'files/lfs/lfs_object.iso' @@ -324,7 +324,7 @@ blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id]) expect(blobs.count).to eq(1) - expect(blobs).to all( be_a(Gitlab::Git::Blob) ) + expect(blobs).to all( be_a(described_class) ) expect(blobs).to be_an(Array) end @@ -332,7 +332,7 @@ blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id].lazy) expect(blobs.count).to eq(1) - expect(blobs).to all( be_a(Gitlab::Git::Blob) ) + expect(blobs).to all( be_a(described_class) ) end it 'handles empty list of IDs gracefully' do @@ -361,7 +361,7 @@ describe 'encoding', :aggregate_failures do context 'file with russian text' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/russian.rb") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/russian.rb") } it 'has the correct blob attributes' do expect(blob.name).to eq("russian.rb") @@ -375,7 +375,7 @@ end context 'file with Japanese text' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/テスト.txt") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/テスト.txt") } it 'has the correct blob attributes' do expect(blob.name).to eq("テスト.txt") @@ -387,7 +387,7 @@ end context 'file with ISO-8859 text' do - let(:blob) { Gitlab::Git::Blob.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/iso8859.txt") } + let(:blob) { described_class.find(repository, TestEnv::BRANCH_SHA['master'], "encoding/iso8859.txt") } it 'has the correct blob attributes' do expect(blob.name).to eq("iso8859.txt") @@ -402,7 +402,7 @@ describe 'mode' do context 'file regular' do let(:blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, TestEnv::BRANCH_SHA['master'], 'files/ruby/regex.rb' @@ -417,7 +417,7 @@ context 'file binary' do let(:blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, TestEnv::BRANCH_SHA['with-executables'], 'files/executables/ls' @@ -432,7 +432,7 @@ context 'file symlink to regular' do let(:blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, '88ce9520c07b7067f589b7f83a30b6250883115c', 'symlink' @@ -449,7 +449,7 @@ describe 'lfs_pointers' do context 'file a valid lfs pointer' do let(:blob) do - Gitlab::Git::Blob.find( + described_class.find( repository, TestEnv::BRANCH_SHA['png-lfs'], 'files/images/emoji.png' @@ -469,7 +469,7 @@ describe '#load_all_data!' do let(:full_data) { 'abcd' } - let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abc') } + let(:blob) { described_class.new(name: 'test', size: 4, data: 'abc') } subject { blob.load_all_data!(repository) } @@ -483,7 +483,7 @@ end context 'with a fully loaded blob' do - let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: full_data) } + let(:blob) { described_class.new(name: 'test', size: 4, data: full_data) } it "doesn't perform any loading" do expect(repository.gitaly_blob_client).not_to receive(:get_blob) @@ -497,7 +497,7 @@ describe '#truncated?' do context 'when blob.size is nil' do - let(:nil_size_blob) { Gitlab::Git::Blob.new(name: 'test', data: 'abcd') } + let(:nil_size_blob) { described_class.new(name: 'test', data: 'abcd') } it 'returns false' do expect(nil_size_blob.truncated?).to be_falsey @@ -505,7 +505,7 @@ end context 'when blob.data is missing' do - let(:nil_data_blob) { Gitlab::Git::Blob.new(name: 'test', size: 4) } + let(:nil_data_blob) { described_class.new(name: 'test', size: 4) } it 'returns false' do expect(nil_data_blob.truncated?).to be_falsey @@ -513,7 +513,7 @@ end context 'when the blob is truncated' do - let(:truncated_blob) { Gitlab::Git::Blob.new(name: 'test', size: 40, data: 'abcd') } + let(:truncated_blob) { described_class.new(name: 'test', size: 40, data: 'abcd') } it 'returns true' do expect(truncated_blob.truncated?).to be_truthy @@ -521,7 +521,7 @@ end context 'when the blob is untruncated' do - let(:untruncated_blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd') } + let(:untruncated_blob) { described_class.new(name: 'test', size: 4, data: 'abcd') } it 'returns false' do expect(untruncated_blob.truncated?).to be_falsey @@ -547,7 +547,7 @@ context 'when the encoding cannot be detected' do it 'successfully splits the data' do data = "test\nblob" - blob = Gitlab::Git::Blob.new(name: 'test', size: data.bytesize, data: data) + blob = described_class.new(name: 'test', size: data.bytesize, data: data) expect(blob).to receive(:ruby_encoding) { nil } expect(blob.lines).to eq(data.split("\n")) diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index db2536b76334ad6c35eeae49af785679c681f3f2..dd9f77f0211dcbbf1a8834395a9499887660848a 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -420,7 +420,7 @@ def create_commit_with_large_message commits = described_class.batch_by_oid(repository, oids) expect(commits.count).to eq(2) - expect(commits).to all( be_a(Gitlab::Git::Commit) ) + expect(commits).to all( be_a(described_class) ) expect(commits.first.sha).to eq(SeedRepo::Commit::ID) expect(commits.second.sha).to eq(SeedRepo::FirstCommit::ID) end diff --git a/spec/lib/gitlab/git/compare_spec.rb b/spec/lib/gitlab/git/compare_spec.rb index e8c683cf8aa500739b218cd5e8395771fae271b4..81b5aa9465634e2a65f6b24f93262ea4a785511e 100644 --- a/spec/lib/gitlab/git/compare_spec.rb +++ b/spec/lib/gitlab/git/compare_spec.rb @@ -5,8 +5,8 @@ RSpec.describe Gitlab::Git::Compare do let_it_be(:repository) { create(:project, :repository).repository.raw } - let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) } - let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) } + let(:compare) { described_class.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) } + let(:compare_straight) { described_class.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) } describe '#commits' do subject do @@ -21,25 +21,25 @@ it { is_expected.not_to include(SeedRepo::BigCommit::PARENT_ID) } context 'non-existing base ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, 'no-such-branch', SeedRepo::Commit::ID) } + let(:compare) { described_class.new(repository, 'no-such-branch', SeedRepo::Commit::ID) } it { is_expected.to be_empty } end context 'non-existing head ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, '1234567890') } + let(:compare) { described_class.new(repository, SeedRepo::BigCommit::ID, '1234567890') } it { is_expected.to be_empty } end context 'base ref is equal to head ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) } + let(:compare) { described_class.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) } it { is_expected.to be_empty } end context 'providing nil as base ref or head ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, nil, nil) } + let(:compare) { described_class.new(repository, nil, nil) } it { is_expected.to be_empty } end @@ -58,13 +58,13 @@ it { is_expected.not_to include('LICENSE') } context 'non-existing base ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, 'no-such-branch', SeedRepo::Commit::ID) } + let(:compare) { described_class.new(repository, 'no-such-branch', SeedRepo::Commit::ID) } it { is_expected.to be_empty } end context 'non-existing head ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, '1234567890') } + let(:compare) { described_class.new(repository, SeedRepo::BigCommit::ID, '1234567890') } it { is_expected.to be_empty } end @@ -78,7 +78,7 @@ it { is_expected.to eq(false) } context 'base ref is equal to head ref' do - let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) } + let(:compare) { described_class.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) } it { is_expected.to eq(true) } end diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb index 5fa0447091c7e72625b013b37f385eaaf25df9a7..72ddd0759ecb9f2f085f70c12a59f58b6bc4d725 100644 --- a/spec/lib/gitlab/git/diff_collection_spec.rb +++ b/spec/lib/gitlab/git/diff_collection_spec.rb @@ -45,7 +45,7 @@ def each end subject do - Gitlab::Git::DiffCollection.new( + described_class.new( iterator, max_files: max_files, max_lines: max_lines, @@ -495,7 +495,7 @@ def each end describe 'empty collection' do - subject { Gitlab::Git::DiffCollection.new([]) } + subject { described_class.new([]) } it_behaves_like 'overflow stuff' @@ -533,7 +533,7 @@ def each describe '#each' do context 'when diff are too large' do let(:collection) do - Gitlab::Git::DiffCollection.new([{ diff: 'a' * 204800 }]) + described_class.new([{ diff: 'a' * 204800 }]) end it 'yields Diff instances even when they are too large' do @@ -612,7 +612,7 @@ def each let(:iterator) { [fake_diff(1, 1)] * 4 } before do - allow(Gitlab::Git::DiffCollection) + allow(described_class) .to receive(:default_limits) .and_return({ max_files: 2, max_lines: max_lines }) end @@ -641,7 +641,7 @@ def each end before do - allow(Gitlab::Git::DiffCollection) + allow(described_class) .to receive(:default_limits) .and_return({ max_files: max_files, max_lines: 80 }) end @@ -672,7 +672,7 @@ def each before do allow(Gitlab::CurrentSettings).to receive(:diff_max_patch_bytes).and_return(1.megabyte) - allow(Gitlab::Git::DiffCollection) + allow(described_class) .to receive(:default_limits) .and_return({ max_files: 4, max_lines: 3000 }) end @@ -713,7 +713,7 @@ def each context 'when offset_index is given' do subject do - Gitlab::Git::DiffCollection.new( + described_class.new( iterator, max_files: max_files, max_lines: max_lines, @@ -760,7 +760,7 @@ def diff(raw) end before do - allow(Gitlab::Git::DiffCollection) + allow(described_class) .to receive(:default_limits) .and_return({ max_files: max_files, max_lines: 80 }) end diff --git a/spec/lib/gitlab/git_access_snippet_spec.rb b/spec/lib/gitlab/git_access_snippet_spec.rb index 0d069d36e48af99b23245e524d91521bdbd5072c..becf97bb24efcb14669018a244356ddf3d780386 100644 --- a/spec/lib/gitlab/git_access_snippet_spec.rb +++ b/spec/lib/gitlab/git_access_snippet_spec.rb @@ -24,7 +24,7 @@ let(:push_access_check) { access.check('git-receive-pack', changes) } let(:pull_access_check) { access.check('git-upload-pack', changes) } - subject(:access) { Gitlab::GitAccessSnippet.new(actor, snippet, protocol, authentication_abilities: authentication_abilities) } + subject(:access) { described_class.new(actor, snippet, protocol, authentication_abilities: authentication_abilities) } describe 'when actor is a DeployKey' do let(:actor) { build(:deploy_key) } diff --git a/spec/lib/gitlab/gl_repository/repo_type_spec.rb b/spec/lib/gitlab/gl_repository/repo_type_spec.rb index 4345df1b018053ac7ce301e9b813298bc0e84392..4ff8137dbd437756dcb4b347ecd1cc0971ab841e 100644 --- a/spec/lib/gitlab/gl_repository/repo_type_spec.rb +++ b/spec/lib/gitlab/gl_repository/repo_type_spec.rb @@ -20,7 +20,7 @@ let(:expected_identifier) { "project-#{expected_id}" } let(:expected_suffix) { '' } let(:expected_container) { project } - let(:expected_repository) { ::Repository.new(project.full_path, project, shard: project.repository_storage, disk_path: project.disk_path, repo_type: Gitlab::GlRepository::PROJECT) } + let(:expected_repository) { ::Repository.new(project.full_path, project, shard: project.repository_storage, disk_path: project.disk_path, repo_type: described_class) } end it 'knows its type' do @@ -51,7 +51,7 @@ let(:expected_identifier) { "wiki-#{expected_id}" } let(:expected_suffix) { '.wiki' } let(:expected_container) { wiki } - let(:expected_repository) { ::Repository.new(wiki.full_path, wiki, shard: wiki.repository_storage, disk_path: wiki.disk_path, repo_type: Gitlab::GlRepository::WIKI) } + let(:expected_repository) { ::Repository.new(wiki.full_path, wiki, shard: wiki.repository_storage, disk_path: wiki.disk_path, repo_type: described_class) } end it 'knows its type' do @@ -80,7 +80,7 @@ let(:expected_id) { personal_snippet.id } let(:expected_identifier) { "snippet-#{expected_id}" } let(:expected_suffix) { '' } - let(:expected_repository) { ::Repository.new(personal_snippet.full_path, personal_snippet, shard: personal_snippet.repository_storage, disk_path: personal_snippet.disk_path, repo_type: Gitlab::GlRepository::SNIPPET) } + let(:expected_repository) { ::Repository.new(personal_snippet.full_path, personal_snippet, shard: personal_snippet.repository_storage, disk_path: personal_snippet.disk_path, repo_type: described_class) } let(:expected_container) { personal_snippet } end @@ -109,7 +109,7 @@ let(:expected_id) { project_snippet.id } let(:expected_identifier) { "snippet-#{expected_id}" } let(:expected_suffix) { '' } - let(:expected_repository) { ::Repository.new(project_snippet.full_path, project_snippet, shard: project_snippet.repository_storage, disk_path: project_snippet.disk_path, repo_type: Gitlab::GlRepository::SNIPPET) } + let(:expected_repository) { ::Repository.new(project_snippet.full_path, project_snippet, shard: project_snippet.repository_storage, disk_path: project_snippet.disk_path, repo_type: described_class) } let(:expected_container) { project_snippet } end diff --git a/spec/lib/gitlab/import_formatter_spec.rb b/spec/lib/gitlab/import_formatter_spec.rb index 0feff61725b788bee18ced1b4419bf531d08178a..6687c4fc224b1a9e71bed761cd57963f6f5a3720 100644 --- a/spec/lib/gitlab/import_formatter_spec.rb +++ b/spec/lib/gitlab/import_formatter_spec.rb @@ -3,7 +3,7 @@ require 'fast_spec_helper' RSpec.describe Gitlab::ImportFormatter do - let(:formatter) { Gitlab::ImportFormatter.new } + let(:formatter) { described_class.new } describe '#comment' do it 'creates the correct string' do diff --git a/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb b/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb index cb4fdeed1a12e04495597f8e88246fa43f4073d7..a4b5847e480e34215a31e024bcf4c24bc26e2e24 100644 --- a/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb +++ b/spec/lib/gitlab/inactive_projects_deletion_warning_tracker_spec.rb @@ -7,68 +7,68 @@ describe '.notified_projects', :clean_gitlab_redis_shared_state do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it 'returns the list of projects for which deletion warning email has been sent' do expected_hash = { "project:1" => Date.current.to_s } - expect(Gitlab::InactiveProjectsDeletionWarningTracker.notified_projects).to eq(expected_hash) + expect(described_class.notified_projects).to eq(expected_hash) end end describe '.reset_all' do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it 'deletes all the projects for which deletion warning email was sent' do - Gitlab::InactiveProjectsDeletionWarningTracker.reset_all + described_class.reset_all - expect(Gitlab::InactiveProjectsDeletionWarningTracker.notified_projects).to eq({}) + expect(described_class.notified_projects).to eq({}) end end describe '#notified?' do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it 'returns true if the project has already been notified' do - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).notified?).to eq(true) + expect(described_class.new(project_id).notified?).to eq(true) end it 'returns false if the project has not been notified' do - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(2).notified?).to eq(false) + expect(described_class.new(2).notified?).to eq(false) end end describe '#mark_notified' do it 'marks the project as being notified' do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).notified?).to eq(true) + expect(described_class.new(project_id).notified?).to eq(true) end end describe '#notification_date', :clean_gitlab_redis_shared_state do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it 'returns the date if a deletion warning email has been sent for a given project' do - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).notification_date).to eq(Date.current.to_s) + expect(described_class.new(project_id).notification_date).to eq(Date.current.to_s) end it 'returns nil if a deletion warning email has not been sent for a given project' do - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(2).notification_date).to eq(nil) + expect(described_class.new(2).notification_date).to eq(nil) end end describe '#scheduled_deletion_date', :clean_gitlab_redis_shared_state do shared_examples 'returns the expected deletion date' do it do - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).scheduled_deletion_date) + expect(described_class.new(project_id).scheduled_deletion_date) .to eq(1.month.from_now.to_date.to_s) end end @@ -84,7 +84,7 @@ context 'with a stored deletion email date' do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it_behaves_like 'returns the expected deletion date' @@ -93,13 +93,13 @@ describe '#reset' do before do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).mark_notified + described_class.new(project_id).mark_notified end it 'resets the project as not being notified' do - Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).reset + described_class.new(project_id).reset - expect(Gitlab::InactiveProjectsDeletionWarningTracker.new(project_id).notified?).to eq(false) + expect(described_class.new(project_id).notified?).to eq(false) end end end diff --git a/spec/lib/gitlab/kubernetes/kube_client_spec.rb b/spec/lib/gitlab/kubernetes/kube_client_spec.rb index 2ead188dc93725f80c737dceb95dbfcaf560579d..d0b89afccdca8984837d98fdd4c11cec310f1818 100644 --- a/spec/lib/gitlab/kubernetes/kube_client_spec.rb +++ b/spec/lib/gitlab/kubernetes/kube_client_spec.rb @@ -145,7 +145,7 @@ def method_call(client, method_name) defaults = Gitlab::Kubernetes::KubeClient::DEFAULT_KUBECLIENT_OPTIONS expect(client.kubeclient_options[:timeouts]).to eq(defaults[:timeouts]) - client = Gitlab::Kubernetes::KubeClient.new(api_url, timeouts: { read: 7 }) + client = described_class.new(api_url, timeouts: { read: 7 }) expect(client.kubeclient_options[:timeouts][:read]).to eq(7) expect(client.kubeclient_options[:timeouts][:open]).to eq(defaults[:timeouts][:open]) end diff --git a/spec/lib/gitlab/pagination/keyset/order_spec.rb b/spec/lib/gitlab/pagination/keyset/order_spec.rb index e99846ad424c74ce466e18a3e3f4a3f8947cbe41..dda68f6e5ae4da2eab95040ec1cf5945cee1728e 100644 --- a/spec/lib/gitlab/pagination/keyset/order_spec.rb +++ b/spec/lib/gitlab/pagination/keyset/order_spec.rb @@ -148,7 +148,7 @@ def cursor_attributes_for_node(node) end let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'id', @@ -193,7 +193,7 @@ def cursor_attributes_for_node(node) end let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'year', @@ -260,7 +260,7 @@ def cursor_attributes_for_node(node) end let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'year', @@ -327,7 +327,7 @@ def cursor_attributes_for_node(node) end let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'year', @@ -394,7 +394,7 @@ def cursor_attributes_for_node(node) end let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'year', @@ -452,7 +452,7 @@ def cursor_attributes_for_node(node) context 'when ordering by the named function LOWER' do let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'title', @@ -494,7 +494,7 @@ def cursor_attributes_for_node(node) context 'when the passed cursor values do not match with the order definition' do let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'year', @@ -564,7 +564,7 @@ def cursor_attributes_for_node(node) context 'when string attribute name is given' do let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'id', @@ -580,7 +580,7 @@ def cursor_attributes_for_node(node) context 'when symbol attribute name is given' do let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: :id, @@ -606,7 +606,7 @@ def cursor_attributes_for_node(node) context 'when there are additional_projections' do let(:order) do - order = Gitlab::Pagination::Keyset::Order.build( + order = described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'created_at_field', @@ -687,7 +687,7 @@ def cursor_attributes_for_node(node) it 'builds UNION query' do cursor_attributes = { created_at: five_months_ago, id: user_2.id } - order = Gitlab::Pagination::Keyset::Order.extract_keyset_order_object(keyset_aware_scope) + order = described_class.extract_keyset_order_object(keyset_aware_scope) query = order.apply_cursor_conditions(scope, cursor_attributes, use_union_optimization: true).to_sql expect(query).to include('UNION ALL') @@ -698,7 +698,7 @@ def cursor_attributes_for_node(node) describe '#attribute_names' do let(:expected_attribute_names) { %w(id name) } let(:order) do - Gitlab::Pagination::Keyset::Order.build( + described_class.build( [ Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( attribute_name: 'id', diff --git a/spec/lib/gitlab/relative_positioning/range_spec.rb b/spec/lib/gitlab/relative_positioning/range_spec.rb index da1f0166d5d919984001cfb384f7a24d6585249d..cb3e1504a7aa2a987de65bdd746c974e2a2d57ba 100644 --- a/spec/lib/gitlab/relative_positioning/range_spec.rb +++ b/spec/lib/gitlab/relative_positioning/range_spec.rb @@ -27,19 +27,19 @@ it 'constructs a closed range when both termini are provided' do range = Gitlab::RelativePositioning.range(item_a, item_b) - expect(range).to be_a_kind_of(Gitlab::RelativePositioning::Range) + expect(range).to be_a_kind_of(described_class) expect(range).to be_a_kind_of(Gitlab::RelativePositioning::ClosedRange) end it 'constructs a starting-from range when only the LHS is provided' do range = Gitlab::RelativePositioning.range(item_a, nil) - expect(range).to be_a_kind_of(Gitlab::RelativePositioning::Range) + expect(range).to be_a_kind_of(described_class) expect(range).to be_a_kind_of(Gitlab::RelativePositioning::StartingFrom) end it 'constructs an ending-at range when only the RHS is provided' do range = Gitlab::RelativePositioning.range(nil, item_b) - expect(range).to be_a_kind_of(Gitlab::RelativePositioning::Range) + expect(range).to be_a_kind_of(described_class) expect(range).to be_a_kind_of(Gitlab::RelativePositioning::EndingAt) end end diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb index fa0fad6552068f05ff5d51194f47204f738f9789..01cfa91bb596e5ad146ae361ffd6503f72d7033a 100644 --- a/spec/lib/gitlab/runtime_spec.rb +++ b/spec/lib/gitlab/runtime_spec.rb @@ -95,7 +95,7 @@ it_behaves_like "valid runtime", :puma, 3 + Gitlab::ActionCable::Config.worker_pool_size it 'identifies as an application runtime' do - expect(Gitlab::Runtime.application?).to be true + expect(described_class.application?).to be true end context "when ActionCable worker pool size is configured" do @@ -133,7 +133,7 @@ it_behaves_like "valid runtime", :sidekiq, 5 it 'identifies as an application runtime' do - expect(Gitlab::Runtime.application?).to be true + expect(described_class.application?).to be true end end @@ -145,7 +145,7 @@ it_behaves_like "valid runtime", :console, 1 it 'does not identify as an application runtime' do - expect(Gitlab::Runtime.application?).to be false + expect(described_class.application?).to be false end end @@ -157,7 +157,7 @@ it_behaves_like "valid runtime", :test_suite, 1 it 'does not identify as an application runtime' do - expect(Gitlab::Runtime.application?).to be false + expect(described_class.application?).to be false end end @@ -177,7 +177,7 @@ it_behaves_like "valid runtime", :rails_runner, 1 it 'does not identify as an application runtime' do - expect(Gitlab::Runtime.application?).to be false + expect(described_class.application?).to be false end end end diff --git a/spec/lib/gitlab/seeder_spec.rb b/spec/lib/gitlab/seeder_spec.rb index a94ae2bca7a663a8568b5383a3fb99cc4d1edc92..e5453d338a02c5597f58b4025344b6ecfd2c07f6 100644 --- a/spec/lib/gitlab/seeder_spec.rb +++ b/spec/lib/gitlab/seeder_spec.rb @@ -7,7 +7,7 @@ subject { described_class } it 'has not_mass_generated scope' do - expect { Namespace.not_mass_generated }.to raise_error(NoMethodError) + expect { described_class.not_mass_generated }.to raise_error(NoMethodError) Gitlab::Seeder.quiet do expect { Namespace.not_mass_generated }.not_to raise_error diff --git a/spec/lib/gitlab/sidekiq_middleware/size_limiter/client_spec.rb b/spec/lib/gitlab/sidekiq_middleware/size_limiter/client_spec.rb index df8e47d60f0323efecce80616db461a272a65189..e1ee12e309f865dad1fba8cc0ac019cfe1c7d89a 100644 --- a/spec/lib/gitlab/sidekiq_middleware/size_limiter/client_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/size_limiter/client_spec.rb @@ -51,7 +51,7 @@ def perform(*args); end context 'when the validator validates the job suscessfully' do before do # Do nothing - allow(Gitlab::SidekiqMiddleware::SizeLimiter::Client).to receive(:validate!) + allow(described_class).to receive(:validate!) end it 'raises an exception when scheduling job with #perform_at' do diff --git a/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb b/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb index 83b155b41b1176d3239dca8583690c0a0b18fc47..a137a97a978e47fd882a64f65019a690cff0f2bf 100644 --- a/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb +++ b/spec/lib/gitlab/usage/metrics/aggregates/sources/redis_hll_spec.rb @@ -40,7 +40,7 @@ .and_return(5) end - expect(Gitlab::Usage::Metrics::Aggregates::Sources::RedisHll).to receive(:calculate_metrics_union) + expect(described_class).to receive(:calculate_metrics_union) .with(metric_names: event_names, start_date: start_date, end_date: end_date, recorded_at: recorded_at) .and_return(2) @@ -48,7 +48,7 @@ end it 'raises error if union is < 0' do - allow(Gitlab::Usage::Metrics::Aggregates::Sources::RedisHll).to receive(:calculate_metrics_union).and_raise(Gitlab::Usage::Metrics::Aggregates::Sources::UnionNotAvailable) + allow(described_class).to receive(:calculate_metrics_union).and_raise(Gitlab::Usage::Metrics::Aggregates::Sources::UnionNotAvailable) expect { calculate_metrics_intersections }.to raise_error(Gitlab::Usage::Metrics::Aggregates::Sources::UnionNotAvailable) end diff --git a/spec/lib/gitlab/utils/measuring_spec.rb b/spec/lib/gitlab/utils/measuring_spec.rb index 4d2791f771f6be72ef72f96b637a85d490e3b90f..da5ef7e08a7eed99e97953d3e517b2d78d7c416a 100644 --- a/spec/lib/gitlab/utils/measuring_spec.rb +++ b/spec/lib/gitlab/utils/measuring_spec.rb @@ -8,7 +8,7 @@ let(:result) { "result" } before do - allow(ActiveSupport::Logger).to receive(:logger_outputs_to?).with(Gitlab::Utils::Measuring.logger, $stdout).and_return(false) + allow(ActiveSupport::Logger).to receive(:logger_outputs_to?).with(described_class.logger, $stdout).and_return(false) end let(:measurement) { described_class.new(base_log_data) } diff --git a/spec/lib/gitlab/webpack/file_loader_spec.rb b/spec/lib/gitlab/webpack/file_loader_spec.rb index c2e9cd8124d8e92bfa1e5081a24b35cf11bc6b03..16bf380fd13a6bcd742be574826030f24a10e33e 100644 --- a/spec/lib/gitlab/webpack/file_loader_spec.rb +++ b/spec/lib/gitlab/webpack/file_loader_spec.rb @@ -32,15 +32,15 @@ end it "returns content when responds successfully" do - expect(Gitlab::Webpack::FileLoader.load(file_path)).to eq(file_contents) + expect(described_class.load(file_path)).to eq(file_contents) end it "raises error when 404" do - expect { Gitlab::Webpack::FileLoader.load("not_found") }.to raise_error("HTTP error 404") + expect { described_class.load("not_found") }.to raise_error("HTTP error 404") end it "raises error when errors out" do - expect { Gitlab::Webpack::FileLoader.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::DevServerLoadError) + expect { described_class.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::DevServerLoadError) end end @@ -53,7 +53,7 @@ end it "raises error if catches SSLError" do - expect { Gitlab::Webpack::FileLoader.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::DevServerSSLError) + expect { described_class.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::DevServerSSLError) end end @@ -66,11 +66,11 @@ describe ".load" do it "returns file content from file path" do - expect(Gitlab::Webpack::FileLoader.load(file_path)).to be(file_contents) + expect(described_class.load(file_path)).to be(file_contents) end it "throws error if file cannot be read" do - expect { Gitlab::Webpack::FileLoader.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::StaticLoadError) + expect { described_class.load(error_file_path) }.to raise_error(Gitlab::Webpack::FileLoader::StaticLoadError) end end end diff --git a/spec/lib/gitlab/webpack/manifest_spec.rb b/spec/lib/gitlab/webpack/manifest_spec.rb index 24a362583795194b25f39f4cf44a05dd8b5aed82..cbf3e4d29514bce92e964373efd4d4d0bb130a0f 100644 --- a/spec/lib/gitlab/webpack/manifest_spec.rb +++ b/spec/lib/gitlab/webpack/manifest_spec.rb @@ -17,24 +17,24 @@ end around do |example| - Gitlab::Webpack::Manifest.clear_manifest! + described_class.clear_manifest! example.run - Gitlab::Webpack::Manifest.clear_manifest! + described_class.clear_manifest! end shared_examples_for "a valid manifest" do it "returns single entry asset paths from the manifest" do - expect(Gitlab::Webpack::Manifest.asset_paths("entry2")).to eq(["/public_path/entry2.js"]) + expect(described_class.asset_paths("entry2")).to eq(["/public_path/entry2.js"]) end it "returns multiple entry asset paths from the manifest" do - expect(Gitlab::Webpack::Manifest.asset_paths("entry1")).to eq(["/public_path/entry1.js", "/public_path/entry1-a.js"]) + expect(described_class.asset_paths("entry1")).to eq(["/public_path/entry1.js", "/public_path/entry1-a.js"]) end it "errors on a missing entry point" do - expect { Gitlab::Webpack::Manifest.asset_paths("herp") }.to raise_error(Gitlab::Webpack::Manifest::AssetMissingError) + expect { described_class.asset_paths("herp") }.to raise_error(Gitlab::Webpack::Manifest::AssetMissingError) end end @@ -60,7 +60,7 @@ allow(Gitlab.config.webpack).to receive(:manifest_filename).and_return('broken.json') stub_request(:get, "http://hostname:2000/public_path/broken.json").to_raise(SocketError) - expect { Gitlab::Webpack::Manifest.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::ManifestLoadError) + expect { described_class.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::ManifestLoadError) end describe "webpack errors" do @@ -73,7 +73,7 @@ ]).to_json stub_request(:get, "http://hostname:2000/public_path/my_manifest.json").to_return(body: error_manifest, status: 200) - expect { Gitlab::Webpack::Manifest.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::WebpackError) + expect { described_class.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::WebpackError) end end @@ -82,14 +82,14 @@ error_manifest = Gitlab::Json.parse(manifest).merge("errors" => ["something went wrong"]).to_json stub_request(:get, "http://hostname:2000/public_path/my_manifest.json").to_return(body: error_manifest, status: 200) - expect { Gitlab::Webpack::Manifest.asset_paths("entry1") }.not_to raise_error + expect { described_class.asset_paths("entry1") }.not_to raise_error end end it "does not error if errors is present but empty" do error_manifest = Gitlab::Json.parse(manifest).merge("errors" => []).to_json stub_request(:get, "http://hostname:2000/public_path/my_manifest.json").to_return(body: error_manifest, status: 200) - expect { Gitlab::Webpack::Manifest.asset_paths("entry1") }.not_to raise_error + expect { described_class.asset_paths("entry1") }.not_to raise_error end end end @@ -107,7 +107,7 @@ it "errors if we can't find the manifest" do allow(Gitlab.config.webpack).to receive(:manifest_filename).and_return('broken.json') stub_file_read(::Rails.root.join("manifest_output/broken.json"), error: Errno::ENOENT) - expect { Gitlab::Webpack::Manifest.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::ManifestLoadError) + expect { described_class.asset_paths("entry1") }.to raise_error(Gitlab::Webpack::Manifest::ManifestLoadError) end end end diff --git a/spec/lib/gitlab/x509/commit_spec.rb b/spec/lib/gitlab/x509/commit_spec.rb index c7d56e49fab0d8e7495b002710334a43a1b94e98..412fa6e5a7fee28653b75ee805b21d5e73218073 100644 --- a/spec/lib/gitlab/x509/commit_spec.rb +++ b/spec/lib/gitlab/x509/commit_spec.rb @@ -6,7 +6,7 @@ let(:user) { create(:user, email: X509Helpers::User1.certificate_email) } let(:project) { create(:project, :repository, path: X509Helpers::User1.path, creator: user) } let(:commit) { project.commit_by(oid: commit_sha ) } - let(:signature) { Gitlab::X509::Commit.new(commit).signature } + let(:signature) { described_class.new(commit).signature } let(:store) { OpenSSL::X509::Store.new } let(:certificate) { OpenSSL::X509::Certificate.new(X509Helpers::User1.trust_cert) } diff --git a/spec/lib/gitlab/x509/signature_spec.rb b/spec/lib/gitlab/x509/signature_spec.rb index eb8c0bd0aff8a9dde5ea6621ead4ada0024ffed5..d119a4e2b9d34413ff8fec57f9a4acf80520c7f0 100644 --- a/spec/lib/gitlab/x509/signature_spec.rb +++ b/spec/lib/gitlab/x509/signature_spec.rb @@ -197,9 +197,9 @@ context 'certificate_crl' do describe 'valid crlDistributionPoints' do before do - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension).and_call_original + allow_any_instance_of(described_class).to receive(:get_certificate_extension).and_call_original - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension) + allow_any_instance_of(described_class).to receive(:get_certificate_extension) .with('crlDistributionPoints') .and_return("\nFull Name:\n URI:http://ch.siemens.com/pki?ZZZZZZA2.crl\n URI:ldap://cl.siemens.net/CN=ZZZZZZA2,L=PKI?certificateRevocationList\n URI:ldap://cl.siemens.com/CN=ZZZZZZA2,o=Trustcenter?certificateRevocationList\n") end @@ -218,9 +218,9 @@ describe 'valid crlDistributionPoints providing multiple http URIs' do before do - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension).and_call_original + allow_any_instance_of(described_class).to receive(:get_certificate_extension).and_call_original - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension) + allow_any_instance_of(described_class).to receive(:get_certificate_extension) .with('crlDistributionPoints') .and_return("\nFull Name:\n URI:http://cdp1.pca.dfn.de/dfn-ca-global-g2/pub/crl/cacrl.crl\n\nFull Name:\n URI:http://cdp2.pca.dfn.de/dfn-ca-global-g2/pub/crl/cacrl.crl\n") end @@ -241,9 +241,9 @@ context 'email' do describe 'subjectAltName with email, othername' do before do - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension).and_call_original + allow_any_instance_of(described_class).to receive(:get_certificate_extension).and_call_original - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension) + allow_any_instance_of(described_class).to receive(:get_certificate_extension) .with('subjectAltName') .and_return("email:gitlab@example.com, othername:<unsupported>") end @@ -262,9 +262,9 @@ describe 'subjectAltName with othername, email' do before do - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension).and_call_original + allow_any_instance_of(described_class).to receive(:get_certificate_extension).and_call_original - allow_any_instance_of(Gitlab::X509::Signature).to receive(:get_certificate_extension) + allow_any_instance_of(described_class).to receive(:get_certificate_extension) .with('subjectAltName') .and_return("othername:<unsupported>, email:gitlab@example.com") end diff --git a/spec/lib/service_ping/devops_report_spec.rb b/spec/lib/service_ping/devops_report_spec.rb index 793f30660979d3f80c64f6aae3674601a79d3b87..bbd663904030449f2bb1df7f9e68502d19c50ef1 100644 --- a/spec/lib/service_ping/devops_report_spec.rb +++ b/spec/lib/service_ping/devops_report_spec.rb @@ -4,7 +4,7 @@ RSpec.describe ServicePing::DevopsReport do let_it_be(:data) { { "conv_index": {} }.to_json } - let_it_be(:subject) { ServicePing::DevopsReport.new(Gitlab::Json.parse(data)) } + let_it_be(:subject) { described_class.new(Gitlab::Json.parse(data)) } let_it_be(:devops_report) { DevOpsReport::Metric.new } describe '#execute' do diff --git a/spec/lib/sidebars/panel_spec.rb b/spec/lib/sidebars/panel_spec.rb index 2c1b9c73595bfe7e36f12417a5d109a12cd97d6c..857cb1139b5b62d6b2b3d2c66c88ca582b2fee6a 100644 --- a/spec/lib/sidebars/panel_spec.rb +++ b/spec/lib/sidebars/panel_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Sidebars::Panel, feature_category: :navigation do let(:context) { Sidebars::Context.new(current_user: nil, container: nil) } - let(:panel) { Sidebars::Panel.new(context) } + let(:panel) { described_class.new(context) } let(:menu1) { Sidebars::Menu.new(context) } let(:menu2) { Sidebars::Menu.new(context) } let(:menu3) { Sidebars::Menu.new(context) } diff --git a/spec/serializers/context_commits_diff_entity_spec.rb b/spec/serializers/context_commits_diff_entity_spec.rb index e8f38527f5bf659d9d43949b747309580feb4a9d..9d74fbc9160bd48752551c8f630150779a292ccc 100644 --- a/spec/serializers/context_commits_diff_entity_spec.rb +++ b/spec/serializers/context_commits_diff_entity_spec.rb @@ -8,7 +8,7 @@ let_it_be(:mrcc2) { create(:merge_request_context_commit, merge_request: merge_request, sha: "ae73cb07c9eeaf35924a10f713b364d32b2dd34f") } context 'as json' do - subject { ContextCommitsDiffEntity.represent(merge_request.context_commits_diff).as_json } + subject { described_class.represent(merge_request.context_commits_diff).as_json } it 'exposes commits_count' do expect(subject[:commits_count]).to eq(2) diff --git a/spec/services/alert_management/alerts/todo/create_service_spec.rb b/spec/services/alert_management/alerts/todo/create_service_spec.rb index fd81c0893ed4bb7327607a7e0686154c144c26c3..c883466cf25068a87e22bf479c2a88a85a0bfaac 100644 --- a/spec/services/alert_management/alerts/todo/create_service_spec.rb +++ b/spec/services/alert_management/alerts/todo/create_service_spec.rb @@ -9,7 +9,7 @@ let(:current_user) { user } describe '#execute' do - subject(:result) { AlertManagement::Alerts::Todo::CreateService.new(alert, current_user).execute } + subject(:result) { described_class.new(alert, current_user).execute } shared_examples 'permissions error' do it 'returns an error', :aggregate_failures do diff --git a/spec/services/auth/dependency_proxy_authentication_service_spec.rb b/spec/services/auth/dependency_proxy_authentication_service_spec.rb index 8f92fbe272c52d630bebbc148f0479088887fc78..3ef9c8fc96e31afff84e3dbfe9cf433cacb6f9d1 100644 --- a/spec/services/auth/dependency_proxy_authentication_service_spec.rb +++ b/spec/services/auth/dependency_proxy_authentication_service_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Auth::DependencyProxyAuthenticationService, feature_category: :dependency_proxy do let_it_be(:user) { create(:user) } - let(:service) { Auth::DependencyProxyAuthenticationService.new(nil, user) } + let(:service) { described_class.new(nil, user) } before do stub_config(dependency_proxy: { enabled: true }) diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 6fb61bb3ec5dc007a5fa2f6ef63a9448b4a5621f..61fec82c688fc7b6891191ac9c3bdd8a2d9a1319 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -417,8 +417,8 @@ module Ci context 'when first build is stalled' do before do - allow_any_instance_of(Ci::RegisterJobService).to receive(:assign_runner!).and_call_original - allow_any_instance_of(Ci::RegisterJobService).to receive(:assign_runner!) + allow_any_instance_of(described_class).to receive(:assign_runner!).and_call_original + allow_any_instance_of(described_class).to receive(:assign_runner!) .with(pending_job, anything).and_raise(ActiveRecord::StaleObjectError) end diff --git a/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb b/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb index 9b1994af1bb4b0c1ae6d046352b7df1d88b30edc..528921a80ee77f7783621bbadabcb98c444561f1 100644 --- a/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb +++ b/spec/services/incident_management/issuable_escalation_statuses/after_update_service_spec.rb @@ -9,7 +9,7 @@ let_it_be(:issue, reload: true) { escalation_status.issue } let_it_be(:project) { issue.project } - let(:service) { IncidentManagement::IssuableEscalationStatuses::AfterUpdateService.new(issue, current_user) } + let(:service) { described_class.new(issue, current_user) } subject(:result) do issue.update!(incident_management_issuable_escalation_status_attributes: update_params) diff --git a/spec/services/issuable/process_assignees_spec.rb b/spec/services/issuable/process_assignees_spec.rb index 2c8d4c5e11d8900280bd978b156fa52263f03387..2751267c08b21a5eca14a00f5132e0fcd675578b 100644 --- a/spec/services/issuable/process_assignees_spec.rb +++ b/spec/services/issuable/process_assignees_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Issuable::ProcessAssignees, feature_category: :team_planning do describe '#execute' do it 'returns assignee_ids when add_assignee_ids and remove_assignee_ids are not specified' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: nil, remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 9), @@ -16,7 +16,7 @@ end it 'combines other ids when assignee_ids is nil' do - process = Issuable::ProcessAssignees.new(assignee_ids: nil, + process = described_class.new(assignee_ids: nil, add_assignee_ids: nil, remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 11), @@ -27,7 +27,7 @@ end it 'combines other ids when both add_assignee_ids and remove_assignee_ids are not empty' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: %w(4 7 11), existing_assignee_ids: %w(1 3 11), @@ -38,7 +38,7 @@ end it 'combines other ids when remove_assignee_ids is not empty' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: nil, remove_assignee_ids: %w(4 7 11), existing_assignee_ids: %w(1 3 11), @@ -49,7 +49,7 @@ end it 'combines other ids when add_assignee_ids is not empty' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: nil, existing_assignee_ids: %w(1 3 11), @@ -60,7 +60,7 @@ end it 'combines ids when existing_assignee_ids and extra_assignee_ids are omitted' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: %w(2 4 6), remove_assignee_ids: %w(4 7 11)) result = process.execute @@ -69,7 +69,7 @@ end it 'handles mixed string and integer arrays' do - process = Issuable::ProcessAssignees.new(assignee_ids: %w(5 7 9), + process = described_class.new(assignee_ids: %w(5 7 9), add_assignee_ids: [2, 4, 6], remove_assignee_ids: %w(4 7 11), existing_assignee_ids: [1, 3, 11], diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index 52999b5a1eab2543c96f639435c6b7afc8eeb373..09e13ffb91ffaac21a870747290fae21d779a2a7 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -108,7 +108,7 @@ def update_merge_request(opts) expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter) .to receive(:track_description_edit_action).once.with(user: user) - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request2) end it 'tracks Draft marking' do @@ -117,7 +117,7 @@ def update_merge_request(opts) opts[:title] = "Draft: #{opts[:title]}" - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request2) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request2) end it 'tracks Draft un-marking' do @@ -126,7 +126,7 @@ def update_merge_request(opts) opts[:title] = "Non-draft/wip title string" - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(draft_merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(draft_merge_request) end context 'when MR is locked' do @@ -137,7 +137,7 @@ def update_merge_request(opts) opts[:discussion_locked] = true - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end @@ -148,7 +148,7 @@ def update_merge_request(opts) opts[:discussion_locked] = false - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end end @@ -163,7 +163,7 @@ def update_merge_request(opts) opts[:discussion_locked] = false - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end @@ -174,7 +174,7 @@ def update_merge_request(opts) opts[:discussion_locked] = true - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end end @@ -193,7 +193,7 @@ def update_merge_request(opts) spent_at: Date.parse('2021-02-24') } - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end it 'tracks milestone change' do @@ -202,7 +202,7 @@ def update_merge_request(opts) opts[:milestone_id] = milestone.id - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end it 'track labels change' do @@ -211,7 +211,7 @@ def update_merge_request(opts) opts[:label_ids] = [label2.id] - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end context 'reviewers' do @@ -222,7 +222,7 @@ def update_merge_request(opts) opts[:reviewers] = [user2] - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end @@ -233,7 +233,7 @@ def update_merge_request(opts) opts[:reviewers] = merge_request.reviewers - MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) + described_class.new(project: project, current_user: user, params: opts).execute(merge_request) end end end @@ -449,7 +449,7 @@ def update_merge_request(opts) let(:milestone) { create(:milestone, project: project) } let(:req_opts) { { source_branch: 'feature', target_branch: 'master' } } - subject { MergeRequests::UpdateService.new(project: project, current_user: user, params: opts).execute(merge_request) } + subject { described_class.new(project: project, current_user: user, params: opts).execute(merge_request) } context 'when mentionable attributes change' do let(:opts) { { description: "Description with #{user.to_reference}" }.merge(req_opts) } diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 99f3134f06f5ec9046282d5d0c100c073ee4d2f5..1d1dd045a09ce30a063a6026c7ef70300b637406 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -532,7 +532,7 @@ allow(::Gitlab::Email::IncomingEmail).to receive(:supports_wildcard?) { true } end - let(:subject) { NotificationService.new } + let(:subject) { described_class.new } let(:mailer) { double(deliver_later: true) } let(:issue) { create(:issue, author: User.support_bot) } let(:project) { issue.project } @@ -3889,7 +3889,7 @@ def create_pipeline(user, status) let(:note) { create(:note, noteable: issue, project: project) } let(:member) { create(:user) } - subject { NotificationService.new } + subject { described_class.new } before do project.add_maintainer(member) diff --git a/spec/services/resource_events/synthetic_label_notes_builder_service_spec.rb b/spec/services/resource_events/synthetic_label_notes_builder_service_spec.rb index 3396abaff9e2d0f956abf0bdcc80e575c3900d8a..7c1c5884fd208e145d039e9a971e92697ba21d99 100644 --- a/spec/services/resource_events/synthetic_label_notes_builder_service_spec.rb +++ b/spec/services/resource_events/synthetic_label_notes_builder_service_spec.rb @@ -13,7 +13,7 @@ let_it_be(:event3) { create(:resource_label_event, issue: issue) } it 'returns the expected synthetic notes' do - notes = ResourceEvents::SyntheticLabelNotesBuilderService.new(issue, user).execute + notes = described_class.new(issue, user).execute expect(notes.size).to eq(3) end diff --git a/spec/services/snippets/update_service_spec.rb b/spec/services/snippets/update_service_spec.rb index b428897ce27a96d4731020bd66c84364862311f2..f36560480e30d93a8994864ac91bb6d81bf266c1 100644 --- a/spec/services/snippets/update_service_spec.rb +++ b/spec/services/snippets/update_service_spec.rb @@ -22,7 +22,7 @@ let(:options) { base_opts.merge(extra_opts) } let(:updater) { user } - let(:service) { Snippets::UpdateService.new(project: project, current_user: updater, params: options, perform_spam_check: true) } + let(:service) { described_class.new(project: project, current_user: updater, params: options, perform_spam_check: true) } subject { service.execute(snippet) } diff --git a/spec/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb index 563af8e7e9e71e33519056ae569f8b5f4a8ffe29..a50bd3ee2f1fe6c0925004080c797577bfaa2a53 100644 --- a/spec/services/user_project_access_changed_service_spec.rb +++ b/spec/services/user_project_access_changed_service_spec.rb @@ -61,7 +61,7 @@ end context 'with load balancing enabled' do - let(:service) { UserProjectAccessChangedService.new([1, 2]) } + let(:service) { described_class.new([1, 2]) } before do expect(AuthorizedProjectsWorker).to receive(:bulk_perform_async) @@ -81,7 +81,7 @@ service.execute end - service = UserProjectAccessChangedService.new([1, 2, 3, 4, 5]) + service = described_class.new([1, 2, 3, 4, 5]) allow(AuthorizedProjectsWorker).to receive(:bulk_perform_async) .with([[1], [2], [3], [4], [5]]) diff --git a/spec/services/webauthn/authenticate_service_spec.rb b/spec/services/webauthn/authenticate_service_spec.rb index ca940dff0ebc543ade615e1040aef39b82e98b35..99b8c7b0b368c52a3b2b40065dad62a7cc0adf71 100644 --- a/spec/services/webauthn/authenticate_service_spec.rb +++ b/spec/services/webauthn/authenticate_service_spec.rb @@ -28,7 +28,7 @@ get_result = client.get(challenge: challenge) get_result['clientExtensionResults'] = {} - service = Webauthn::AuthenticateService.new(user, get_result.to_json, challenge) + service = described_class.new(user, get_result.to_json, challenge) expect(service.execute).to eq true end @@ -41,7 +41,7 @@ get_result = other_client.get(challenge: challenge) get_result['clientExtensionResults'] = {} - service = Webauthn::AuthenticateService.new(user, get_result.to_json, challenge) + service = described_class.new(user, get_result.to_json, challenge) expect(service.execute).to eq false end @@ -49,7 +49,7 @@ context 'when device response includes invalid json' do it 'returns false' do - service = Webauthn::AuthenticateService.new(user, 'invalid JSON', '') + service = described_class.new(user, 'invalid JSON', '') expect(service.execute).to eq false end end diff --git a/spec/services/webauthn/register_service_spec.rb b/spec/services/webauthn/register_service_spec.rb index 2286d261e94a7c3c8da18c1cf8cc6dda8debc905..734e8444b5d4d7b97280e95c4966ed1d0df01476 100644 --- a/spec/services/webauthn/register_service_spec.rb +++ b/spec/services/webauthn/register_service_spec.rb @@ -16,7 +16,7 @@ webauthn_credential = WebAuthn::Credential.from_create(create_result) params = { device_response: create_result.to_json, name: 'abc' } - service = Webauthn::RegisterService.new(user, params, challenge) + service = described_class.new(user, params, challenge) registration = service.execute expect(registration.credential_xid).to eq(Base64.strict_encode64(webauthn_credential.raw_id)) @@ -27,7 +27,7 @@ create_result = client.create(challenge: Base64.strict_encode64(SecureRandom.random_bytes(16))) # rubocop:disable Rails/SaveBang params = { device_response: create_result.to_json, name: 'abc' } - service = Webauthn::RegisterService.new(user, params, challenge) + service = described_class.new(user, params, challenge) registration = service.execute expect(registration.errors.size).to eq(1) diff --git a/spec/support_specs/helpers/graphql_helpers_spec.rb b/spec/support_specs/helpers/graphql_helpers_spec.rb index 12a6e561257011a4a0fc87685da7241708e3a07c..5d567bb7a1336cc50b71a6a4900391a419982e59 100644 --- a/spec/support_specs/helpers/graphql_helpers_spec.rb +++ b/spec/support_specs/helpers/graphql_helpers_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe GraphqlHelpers do - include GraphqlHelpers + include described_class # Normalize irrelevant whitespace to make comparison easier def norm(query) diff --git a/spec/validators/html_safety_validator_spec.rb b/spec/validators/html_safety_validator_spec.rb index 4d9425235e38c2317b5c1713c58804d3a6259455..b33d1dcab6c6e4373e26b257152206d48b2f55dc 100644 --- a/spec/validators/html_safety_validator_spec.rb +++ b/spec/validators/html_safety_validator_spec.rb @@ -13,7 +13,7 @@ def validate(value) it 'adds an error when a script is included in the name' do validate('My group <script>evil_script</script>') - expect(group.errors[:name]).to eq([HtmlSafetyValidator.error_message]) + expect(group.errors[:name]).to eq([described_class.error_message]) end it 'does not add an error when an ampersand is included in the name' do diff --git a/spec/workers/bulk_imports/entity_worker_spec.rb b/spec/workers/bulk_imports/entity_worker_spec.rb index dada4ef63b3a5c58e1bda81a72baeeef4e2c1a2e..8238721df01cdf3dfeb8223f0cbf2bec471ff841 100644 --- a/spec/workers/bulk_imports/entity_worker_spec.rb +++ b/spec/workers/bulk_imports/entity_worker_spec.rb @@ -17,7 +17,7 @@ let(:job_args) { entity.id } it 'updates pipeline trackers to enqueued state when selected' do - worker = BulkImports::EntityWorker.new + worker = described_class.new next_tracker = worker.send(:next_pipeline_trackers_for, entity.id).first diff --git a/spec/workers/jira_connect/retry_request_worker_spec.rb b/spec/workers/jira_connect/retry_request_worker_spec.rb index e96a050da13303a72ce5e89799d444e2ee056714..5453711f24ea7f43c00aa912466fa9a5c5c544d8 100644 --- a/spec/workers/jira_connect/retry_request_worker_spec.rb +++ b/spec/workers/jira_connect/retry_request_worker_spec.rb @@ -11,7 +11,7 @@ subject(:perform) { described_class.new.perform(event_url, jwt, attempts) } it 'sends the request, with the appropriate headers' do - expect(JiraConnect::RetryRequestWorker).not_to receive(:perform_in) + expect(described_class).not_to receive(:perform_in) stub_request(:post, event_url) @@ -26,7 +26,7 @@ end it 'arranges to retry the request' do - expect(JiraConnect::RetryRequestWorker).to receive(:perform_in).with(1.hour, event_url, jwt, attempts - 1) + expect(described_class).to receive(:perform_in).with(1.hour, event_url, jwt, attempts - 1) perform end @@ -35,7 +35,7 @@ let(:attempts) { 0 } it 'does not retry' do - expect(JiraConnect::RetryRequestWorker).not_to receive(:perform_in) + expect(described_class).not_to receive(:perform_in) perform end