diff options
Diffstat (limited to 'spec/lib/gitlab')
88 files changed, 130 insertions, 0 deletions
diff --git a/spec/lib/gitlab/alert_management/alert_params_spec.rb b/spec/lib/gitlab/alert_management/alert_params_spec.rb index 393838ab042..1fe27365c83 100644 --- a/spec/lib/gitlab/alert_management/alert_params_spec.rb +++ b/spec/lib/gitlab/alert_management/alert_params_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::AlertManagement::AlertParams do 'some' => { 'extra' => { 'payload' => 'here' } } } end + let(:payload) { default_payload } subject { described_class.from_generic_alert(project: project, payload: payload) } @@ -75,6 +76,7 @@ RSpec.describe Gitlab::AlertManagement::AlertParams do 'fingerprint' => 'b6ac4d42057c43c1' } end + let(:parsed_alert) { Gitlab::Alerting::Alert.new(project: project, payload: payload) } subject { described_class.from_prometheus_alert(project: project, parsed_alert: parsed_alert) } diff --git a/spec/lib/gitlab/application_rate_limiter_spec.rb b/spec/lib/gitlab/application_rate_limiter_spec.rb index 14a7e25a2e8..2525b1ce41e 100644 --- a/spec/lib/gitlab/application_rate_limiter_spec.rb +++ b/spec/lib/gitlab/application_rate_limiter_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::ApplicationRateLimiter, :clean_gitlab_redis_cache do } } end + let(:key) { rate_limits.keys[0] } subject { described_class } diff --git a/spec/lib/gitlab/asciidoc/include_processor_spec.rb b/spec/lib/gitlab/asciidoc/include_processor_spec.rb index 067dcefb525..5c225575965 100644 --- a/spec/lib/gitlab/asciidoc/include_processor_spec.rb +++ b/spec/lib/gitlab/asciidoc/include_processor_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Gitlab::Asciidoc::IncludeProcessor do ref: ref } end + let(:ref) { project.repository.root_ref } let(:max_includes) { 10 } diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index b28d4e8d5a5..1b669e691e7 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -473,6 +473,7 @@ module Gitlab requested_path: requested_path } end + let(:commit) { project.commit(ref) } let(:project) { create(:project, :repository) } let(:ref) { 'asciidoc' } diff --git a/spec/lib/gitlab/auth/auth_finders_spec.rb b/spec/lib/gitlab/auth/auth_finders_spec.rb index d98f8a4507d..a73ac0b34af 100644 --- a/spec/lib/gitlab/auth/auth_finders_spec.rb +++ b/spec/lib/gitlab/auth/auth_finders_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::Auth::AuthFinders do 'rack.input' => '' } end + let(:request) { ActionDispatch::Request.new(env) } def set_param(key, value) diff --git a/spec/lib/gitlab/auth/ldap/user_spec.rb b/spec/lib/gitlab/auth/ldap/user_spec.rb index 7ca2878e583..ccaed94b5c8 100644 --- a/spec/lib/gitlab/auth/ldap/user_spec.rb +++ b/spec/lib/gitlab/auth/ldap/user_spec.rb @@ -14,9 +14,11 @@ RSpec.describe Gitlab::Auth::Ldap::User do nickname: 'john' } end + let(:auth_hash) do OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info) end + let(:ldap_user_upper_case) { described_class.new(auth_hash_upper_case) } let(:info_upper_case) do { @@ -25,6 +27,7 @@ RSpec.describe Gitlab::Auth::Ldap::User do nickname: 'john' } end + let(:auth_hash_upper_case) do OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info_upper_case) end diff --git a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb index 7a60acca95b..67ffdee0c4a 100644 --- a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::Auth::OAuth::AuthHash do let(:uid_raw) do +"CN=Onur K\xC3\xBC\xC3\xA7\xC3\xBCk,OU=Test,DC=example,DC=net" end + let(:email_raw) { +"onur.k\xC3\xBC\xC3\xA7\xC3\xBCk_ABC-123@example.net" } let(:nickname_raw) { +"ok\xC3\xBC\xC3\xA7\xC3\xBCk" } let(:first_name_raw) { +'Onur' } diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index ad04fddc675..cc9e3b957e3 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Auth::OAuth::User do } } end + let(:ldap_user) { Gitlab::Auth::Ldap::Person.new(Net::LDAP::Entry.new, 'ldapmain') } describe '#persisted?' do diff --git a/spec/lib/gitlab/auth/request_authenticator_spec.rb b/spec/lib/gitlab/auth/request_authenticator_spec.rb index 32d64519e2c..ef83321cc0e 100644 --- a/spec/lib/gitlab/auth/request_authenticator_spec.rb +++ b/spec/lib/gitlab/auth/request_authenticator_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Auth::RequestAuthenticator do 'REQUEST_METHOD' => 'GET' } end + let(:request) { ActionDispatch::Request.new(env) } subject { described_class.new(request) } diff --git a/spec/lib/gitlab/auth/saml/user_spec.rb b/spec/lib/gitlab/auth/saml/user_spec.rb index 7f8346f0486..fd48492f18d 100644 --- a/spec/lib/gitlab/auth/saml/user_spec.rb +++ b/spec/lib/gitlab/auth/saml/user_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Gitlab::Auth::Saml::User do email: 'john@mail.com' } end + let(:ldap_user) { Gitlab::Auth::Ldap::Person.new(Net::LDAP::Entry.new, 'ldapmain') } describe '#save' do @@ -194,6 +195,7 @@ RSpec.describe Gitlab::Auth::Saml::User do } } end + let(:auth_hash) { OmniAuth::AuthHash.new(auth_hash_base_attributes) } let(:uid_types) { %w(uid dn email) } diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index a73c6317f31..83bba3cec04 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -631,6 +631,7 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do password: password, password_confirmation: password) end + let(:username) { 'John' } # username isn't lowercase, test this let(:password) { 'my-secret' } diff --git a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb index ec2fd3cc4e0..fad33265030 100644 --- a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb @@ -264,6 +264,7 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillSnippetRepositories, :migrat user_type: user_type, confirmed_at: 1.day.ago) end + let!(:invalid_snippet) { snippets.create(id: 4, type: 'PersonalSnippet', author_id: user.id, file_name: '.', content: content) } let!(:snippet) { snippets.create(id: 5, type: 'PersonalSnippet', author_id: other_user.id, file_name: file_name, content: content) } let(:ids) { [4, 5] } diff --git a/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb b/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb index bf793e7c537..1637589d272 100644 --- a/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb +++ b/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb @@ -264,6 +264,7 @@ RSpec.describe Gitlab::BackgroundMigration::LegacyUploadMover do let(:remote_file) do { key: "#{legacy_upload.path}" } end + let(:connection) { ::Fog::Storage.new(FileUploader.object_store_credentials) } let(:bucket) { connection.directories.create(key: 'uploads') } diff --git a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb index d53f79c61c1..d829fd5daf5 100644 --- a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb @@ -286,9 +286,11 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, s let!(:jira_service_invalid) do services.create(id: 19, title: 'invalid - title', description: 'invalid - description', type: 'JiraService', properties: 'invalid data', category: 'issue_tracker') end + let!(:jira_service_valid) do services.create(id: 20, type: 'JiraService', properties: jira_properties.to_json, category: 'issue_tracker') end + let!(:bugzilla_service_valid) do services.create(id: 11, type: 'BugzillaService', title: nil, properties: tracker_properties.to_json, category: 'issue_tracker') end diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb index b110fa484ff..052a01a8dd8 100644 --- a/spec/lib/gitlab/background_migration_spec.rb +++ b/spec/lib/gitlab/background_migration_spec.rb @@ -130,6 +130,7 @@ RSpec.describe Gitlab::BackgroundMigration do let(:retry_queue) do [double(args: ['Object', [3]], queue: described_class.queue, delete: true)] end + let(:dead_queue) do [double(args: ['Object', [4]], queue: described_class.queue, delete: true)] end diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index 08b7bafddf0..d4483bf1754 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -87,6 +87,7 @@ RSpec.describe Gitlab::BitbucketImport::Importer do values: sample_issues_statuses } end + let(:counter) { double('counter', increment: true) } subject { described_class.new(project) } @@ -109,6 +110,7 @@ RSpec.describe Gitlab::BitbucketImport::Importer do created_at: Time.now, updated_at: Time.now) end + let(:author_line) { "*Created by: someuser*\n\n" } before do diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb index f29a39e4e66..bf1f2bae7da 100644 --- a/spec/lib/gitlab/ci/ansi2html_spec.rb +++ b/spec/lib/gitlab/ci/ansi2html_spec.rb @@ -213,6 +213,7 @@ RSpec.describe Gitlab::Ci::Ansi2html do " data-timestamp=\"#{section_start_time.to_i}\" data-section=\"#{class_name(section_name)}\"" \ ' role="button"></div>' end + let(:section_end_html) do "<div class=\"section-end\" data-section=\"#{class_name(section_name)}\"></div>" end diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 9fbc14c19b9..ec137ef2ae4 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -95,6 +95,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Service do let(:config) do { name: 'postgresql:9.5', alias: 'db', command: %w(cmd run), entrypoint: %w(/bin/sh run), ports: ports } end + let(:entry) { described_class.new(config, { with_image_ports: image_ports }) } let(:image_ports) { false } diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb index 993a07568de..fdd29afe2d6 100644 --- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb @@ -92,6 +92,7 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do - bundle install --jobs $(nproc) "${FLAGS[@]}" HEREDOC end + let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' } before do diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb index b2cf36b2597..9786e050399 100644 --- a/spec/lib/gitlab/ci/config/external/processor_spec.rb +++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb @@ -128,6 +128,7 @@ RSpec.describe Gitlab::Ci::Config::External::Processor do remote_file ] end + let(:values) do { include: external_files, diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb index 1dc2e0a1822..7eefb4d7876 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb @@ -68,6 +68,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do proj.repository.add_tag(user, 'master', 'master') end end + let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( project: project, current_user: user, origin_ref: 'master') diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb index 240ede790e0..650ae41320b 100644 --- a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Gitlab::Ci::Reports::AccessibilityReportsComparer do } ] end + let(:different_error) do [ { diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 80ec67e8cd5..1c81cc83cd1 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -942,6 +942,7 @@ module Gitlab let(:variables) do { 'VAR1' => 'value1', 'VAR2' => 'value2' } end + let(:config) do { variables: variables, @@ -962,9 +963,11 @@ module Gitlab let(:global_variables) do { 'VAR1' => 'global1', 'VAR3' => 'global3', 'VAR4' => 'global4' } end + let(:job_variables) do { 'VAR1' => 'value1', 'VAR2' => 'value2' } end + let(:config) do { before_script: ['pwd'], @@ -2073,6 +2076,7 @@ module Gitlab { job: "build2" } ] end + let(:dependencies) { %w(build3) } it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'jobs:test1 dependencies the build3 should be part of needs') } diff --git a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb index 1752608f844..c59b7f004dd 100644 --- a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb +++ b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::Cleanup::RemoteUploads do create(:upload, path: 'dir/file2', store: ObjectStorage::Store::LOCAL) ] end + let(:remote_files) do [ double(key: 'dir/file1'), diff --git a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb index cc2c431fc07..afc45c86362 100644 --- a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb +++ b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::CrossProjectAccess::ClassMethods do extend Gitlab::CrossProjectAccess::ClassMethods end end + let(:dummy_proc) { lambda { false } } describe '#requires_cross_project_access' do diff --git a/spec/lib/gitlab/danger/commit_linter_spec.rb b/spec/lib/gitlab/danger/commit_linter_spec.rb index 06bec6f793d..c31522c538d 100644 --- a/spec/lib/gitlab/danger/commit_linter_spec.rb +++ b/spec/lib/gitlab/danger/commit_linter_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Gitlab::Danger::CommitLinter do let(:commit_class) do Struct.new(:message, :sha, :diff_parent) end + let(:commit_message) { 'A commit message' } let(:commit_sha) { 'abcd1234' } let(:commit) { commit_class.new(commit_message, commit_sha, diff_parent) } diff --git a/spec/lib/gitlab/danger/roulette_spec.rb b/spec/lib/gitlab/danger/roulette_spec.rb index 9517b0a8f63..b471e17e2e7 100644 --- a/spec/lib/gitlab/danger/roulette_spec.rb +++ b/spec/lib/gitlab/danger/roulette_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => backend_tz_offset_hours ) end + let(:frontend_reviewer) do Gitlab::Danger::Teammate.new( 'username' => 'frontend-reviewer', @@ -32,6 +33,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:frontend_maintainer) do Gitlab::Danger::Teammate.new( 'username' => 'frontend-maintainer', @@ -42,6 +44,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:software_engineer_in_test) do Gitlab::Danger::Teammate.new( 'username' => 'software-engineer-in-test', @@ -52,6 +55,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:engineering_productivity_reviewer) do Gitlab::Danger::Teammate.new( 'username' => 'eng-prod-reviewer', @@ -296,18 +300,21 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => person_tz_offset_hours ) end + let(:person2) do Gitlab::Danger::Teammate.new( 'username' => 'user2', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours) end + let(:author) do Gitlab::Danger::Teammate.new( 'username' => 'johndoe', 'available' => true, 'tz_offset_hours' => 0.0) end + let(:unavailable) do Gitlab::Danger::Teammate.new( 'username' => 'janedoe', diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb index 82bed5073db..12819614fab 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/lib/gitlab/danger/teammate_spec.rb @@ -20,6 +20,7 @@ RSpec.describe Gitlab::Danger::Teammate do 'tz_offset_hours' => tz_offset_hours } end + let(:capabilities) { ['reviewer backend'] } let(:projects) { { project => capabilities } } let(:role) { 'Engineer, Manage' } diff --git a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb index e488bf5ee4c..c2028f8c238 100644 --- a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb +++ b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Gitlab::Database::Count::TablesampleCountStrategy do Namespace => threshold + 1 } end + let(:threshold) { Gitlab::Database::Count::TablesampleCountStrategy::EXACT_COUNT_THRESHOLD } before do diff --git a/spec/lib/gitlab/database/custom_structure_spec.rb b/spec/lib/gitlab/database/custom_structure_spec.rb index beda9df3684..b3bdca0acdd 100644 --- a/spec/lib/gitlab/database/custom_structure_spec.rb +++ b/spec/lib/gitlab/database/custom_structure_spec.rb @@ -32,6 +32,7 @@ RSpec.describe Gitlab::Database::CustomStructure do Gitlab::Database::PartitioningMigrationHelpers::PartitionedForeignKey.create( cascade_delete: true, from_table: 'issues', from_column: 'project_id', to_table: 'projects', to_column: 'id') end + let!(:second_fk) do Gitlab::Database::PartitioningMigrationHelpers::PartitionedForeignKey.create( cascade_delete: false, from_table: 'issues', from_column: 'moved_to_id', to_table: 'issues', to_column: 'id') diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb index efa9c83b2d2..7d88c17c9b3 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::ForeignKeyHelpers let(:model) do ActiveRecord::Migration.new.extend(described_class) end + let_it_be(:connection) { ActiveRecord::Base.connection } let(:referenced_table) { :issues } let(:function_name) { '_test_partitioned_foreign_keys_function' } diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb index 995b598e7b3..86f79b213ae 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb @@ -321,6 +321,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe let(:expected_tables) do %w[000000 201912 202001 202002].map { |suffix| "#{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.#{partitioned_table}_#{suffix}" }.unshift(partitioned_table) end + let(:migration_class) { 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable' } context 'when the table is not allowed' do diff --git a/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb index 8b3a0ceb804..ea8c9e2cfd7 100644 --- a/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb +++ b/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Gitlab::Database::PostgresqlAdapter::ForceDisconnectableMixin do end end end + let(:config) { Rails.application.config_for(:database).merge(pool: 1) } let(:pool) { model.establish_connection(config) } diff --git a/spec/lib/gitlab/diff/file_collection/commit_spec.rb b/spec/lib/gitlab/diff/file_collection/commit_spec.rb index 6c109e96a53..7773604a638 100644 --- a/spec/lib/gitlab/diff/file_collection/commit_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/commit_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Diff::FileCollection::Commit do let(:collection_default_args) do { diff_options: {} } end + let(:diffable) { project.commit } let(:stub_path) { 'bar/branch-test.txt' } end diff --git a/spec/lib/gitlab/diff/file_collection/compare_spec.rb b/spec/lib/gitlab/diff/file_collection/compare_spec.rb index 168d58e584e..dda4513a3a1 100644 --- a/spec/lib/gitlab/diff/file_collection/compare_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/compare_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Gitlab::Diff::FileCollection::Compare do diff_refs: diffable.diff_refs } end + let(:diffable) { Compare.new(raw_compare, project) } let(:stub_path) { '.gitignore' } end diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb index a5e714c90fc..429e552278d 100644 --- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb @@ -42,6 +42,7 @@ RSpec.describe Gitlab::Diff::FileCollection::MergeRequestDiff do let(:collection_default_args) do { diff_options: {} } end + let(:diffable) { merge_request.merge_request_diff } let(:stub_path) { '.gitignore' } end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index 94abfcf079a..78be89c449b 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -800,6 +800,7 @@ RSpec.describe Gitlab::Diff::File do let(:project) do create(:project, :custom_repo, files: {}) end + let(:branch_name) { 'master' } context 'when empty file is created' do @@ -842,6 +843,7 @@ RSpec.describe Gitlab::Diff::File do let(:project) do create(:project, :custom_repo, files: {}) end + let(:branch_name) { 'master' } context 'when empty file is created' do diff --git a/spec/lib/gitlab/diff/position_collection_spec.rb b/spec/lib/gitlab/diff/position_collection_spec.rb index b1478c774f1..d2bb82983c0 100644 --- a/spec/lib/gitlab/diff/position_collection_spec.rb +++ b/spec/lib/gitlab/diff/position_collection_spec.rb @@ -8,9 +8,11 @@ RSpec.describe Gitlab::Diff::PositionCollection do let(:text_position) do build(:text_diff_position, :added, diff_refs: diff_refs) end + let(:folded_text_position) do build(:text_diff_position, diff_refs: diff_refs, old_line: 1, new_line: 1) end + let(:image_position) do build(:image_diff_position, diff_refs: diff_refs) end diff --git a/spec/lib/gitlab/diff/suggestion_spec.rb b/spec/lib/gitlab/diff/suggestion_spec.rb index 5a5c5555818..40779faf917 100644 --- a/spec/lib/gitlab/diff/suggestion_spec.rb +++ b/spec/lib/gitlab/diff/suggestion_spec.rb @@ -31,9 +31,11 @@ RSpec.describe Gitlab::Diff::Suggestion do new_line: 9, diff_refs: merge_request.diff_refs) end + let(:diff_file) do position.diff_file(project.repository) end + let(:text) { "# parsed suggestion content\n# with comments" } def blob_lines_data(from_line, to_line) diff --git a/spec/lib/gitlab/email/message/repository_push_spec.rb b/spec/lib/gitlab/email/message/repository_push_spec.rb index 10586527239..6b1f03e0385 100644 --- a/spec/lib/gitlab/email/message/repository_push_spec.rb +++ b/spec/lib/gitlab/email/message/repository_push_spec.rb @@ -18,10 +18,12 @@ RSpec.describe Gitlab::Email::Message::RepositoryPush do { author_id: author.id, ref: 'master', action: :push, compare: compare, send_from_committer_email: true } end + let(:raw_compare) do Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) end + let(:compare) do Compare.decorate(raw_compare, project) end diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index 5394c04c6ba..0ea974921bc 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -138,6 +138,7 @@ RSpec.describe Gitlab::EncodingHelper do let(:test_string) do "refs/heads/FixSymbolsTitleDropdown".encode("ASCII-8BIT") end + let(:expected_string) do "refs/heads/FixSymbolsTitleDropdown".encode("UTF-8") end diff --git a/spec/lib/gitlab/fogbugz_import/importer_spec.rb b/spec/lib/gitlab/fogbugz_import/importer_spec.rb index d2be3e3f6b1..eb0c4da6ce3 100644 --- a/spec/lib/gitlab/fogbugz_import/importer_spec.rb +++ b/spec/lib/gitlab/fogbugz_import/importer_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::FogbugzImport::Importer do path: 'vim', raw_data: '') end + let(:import_data) { { 'repo' => repo } } let(:credentials) do { diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index bac1b4c57f9..e1bcf4aeeb1 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -84,6 +84,7 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do parents: parents } end + let(:stale_sha) { Timecop.freeze(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago - 5.days) { create_commit } } let(:active_sha) { Timecop.freeze(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago + 5.days) { create_commit } } let(:future_sha) { Timecop.freeze(100.days.since) { create_commit } } diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 666b49f27f7..491437856d4 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Git::Commit, :seed_helper do let(:rugged_repo) do Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH)) end + let(:commit) { described_class.find(repository, SeedRepo::Commit::ID) } let(:rugged_commit) { rugged_repo.lookup(SeedRepo::Commit::ID) } diff --git a/spec/lib/gitlab/git/conflict/parser_spec.rb b/spec/lib/gitlab/git/conflict/parser_spec.rb index 67bd48256ce..02b00f711b4 100644 --- a/spec/lib/gitlab/git/conflict/parser_spec.rb +++ b/spec/lib/gitlab/git/conflict/parser_spec.rb @@ -89,12 +89,15 @@ RSpec.describe Gitlab::Git::Conflict::Parser do let(:lines) do described_class.parse(text, our_path: 'files/ruby/regex.rb', their_path: 'files/ruby/regex.rb') end + let(:old_line_numbers) do lines.select { |line| line[:type] != 'new' }.map { |line| line[:line_old] } end + let(:new_line_numbers) do lines.select { |line| line[:type] != 'old' }.map { |line| line[:line_new] } end + let(:line_indexes) { lines.map { |line| line[:line_obj_index] } } it 'sets our lines as new lines' do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 91688c31f5e..117c519e98d 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -78,6 +78,7 @@ EOT patch: raw_patch ) end + let(:diff) { described_class.new(gitaly_diff) } context 'with a small diff' do @@ -134,6 +135,7 @@ EOT to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0' ) end + let(:diff) { described_class.new(commit_delta) } it 'initializes the diff' do diff --git a/spec/lib/gitlab/git/patches/collection_spec.rb b/spec/lib/gitlab/git/patches/collection_spec.rb index eb92f4663c8..67a502242ea 100644 --- a/spec/lib/gitlab/git/patches/collection_spec.rb +++ b/spec/lib/gitlab/git/patches/collection_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::Git::Patches::Collection do let(:patch_content1) do File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch")) end + let(:patch_content2) do File.read(File.join(patches_folder, "0001-A-commit-from-a-patch.patch")) end diff --git a/spec/lib/gitlab/git/patches/commit_patches_spec.rb b/spec/lib/gitlab/git/patches/commit_patches_spec.rb index cd1e03a6de0..9ab0893eb55 100644 --- a/spec/lib/gitlab/git/patches/commit_patches_spec.rb +++ b/spec/lib/gitlab/git/patches/commit_patches_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::Git::Patches::CommitPatches do Gitlab::Git::Patches::Collection.new([content_1, content_2]) end + let(:user) { build(:user) } let(:branch_name) { 'branch-with-patches' } let(:repository) { create(:project, :repository).repository } diff --git a/spec/lib/gitlab/git/patches/patch_spec.rb b/spec/lib/gitlab/git/patches/patch_spec.rb index 629f43d3636..6588b18d0ae 100644 --- a/spec/lib/gitlab/git/patches/patch_spec.rb +++ b/spec/lib/gitlab/git/patches/patch_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::Git::Patches::Patch do let(:patch_content) do File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch")) end + let(:patch) { described_class.new(patch_content) } describe '#size' do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index e7f4573c95f..73eecd3401a 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -579,9 +579,11 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do let(:commit_with_old_name) do Gitlab::Git::Commit.find(repository, @commit_with_old_name_id) end + let(:commit_with_new_name) do Gitlab::Git::Commit.find(repository, @commit_with_new_name_id) end + let(:rename_commit) do Gitlab::Git::Commit.find(repository, @rename_commit_id) end @@ -2178,6 +2180,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do let(:new_repository) do Gitlab::Git::Repository.new('test_second_storage', TEST_REPO_PATH, '', 'group/project') end + let(:new_repository_path) { File.join(TestEnv::SECOND_STORAGE_PATH, new_repository.relative_path) } subject { new_repository.replicate(repository) } diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 45a25ccfc88..9581b017839 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -266,6 +266,7 @@ RSpec.describe Gitlab::GitalyClient::CommitService do repository: repository_message, revision: revision ) end + let(:response) do Gitaly::CommitStatsResponse.new( oid: revision, diff --git a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb index b016e8bdf5a..e90cb966917 100644 --- a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb @@ -35,6 +35,7 @@ RSpec.describe Gitlab::GitalyClient::ConflictsService do let(:files) do [{ old_path: 'some/path', new_path: 'some/path', content: '' }] end + let(:source_branch) { 'master' } let(:target_branch) { 'feature' } let(:commit_message) { 'Solving conflicts\n\nTést' } diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index 4e16f760235..b974f456914 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -20,11 +20,13 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:gitaly_commit) { build(:gitaly_commit) } let(:commit_id) { gitaly_commit.id } let(:gitaly_branch) do Gitaly::Branch.new(name: branch_name, target_commit: gitaly_commit) end + let(:response) { Gitaly::UserCreateBranchResponse.new(branch: gitaly_branch) } let(:commit) { Gitlab::Git::Commit.new(repository, gitaly_commit) } @@ -68,6 +70,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:response) { Gitaly::UserUpdateBranchResponse.new } subject { client.user_update_branch(branch_name, user, newrev, oldrev) } @@ -123,6 +126,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:response) { Gitaly::UserDeleteBranchResponse.new } subject { client.user_delete_branch(branch_name, user) } @@ -162,6 +166,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:branch_update) do Gitaly::OperationBranchUpdate.new( commit_id: source_sha, @@ -169,6 +174,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do branch_created: false ) end + let(:response) { Gitaly::UserFFBranchResponse.new(branch_update: branch_update) } before do @@ -303,6 +309,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do commit_message: commit_message ) end + let(:squash_sha) { 'f00' } let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) } @@ -375,6 +382,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do let(:patch_content) do patch_names.map { |name| File.read(File.join(patches_folder, name)) }.join("\n") end + let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) } let(:branch_name) { 'branch-with-patches' } diff --git a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb index a06f8459963..8a169acb69c 100644 --- a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::GitalyClient::WikiService do Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(raw_data: 'b')) ] end + let(:wiki_page) { subject.first } let(:wiki_page_version) { subject.last } @@ -60,6 +61,7 @@ RSpec.describe Gitlab::GitalyClient::WikiService do Gitaly::WikiGetAllPagesResponse.new(end_of_page: true) ] end + let(:wiki_page_1) { subject[0].first } let(:wiki_page_1_version) { subject[0].last } let(:wiki_page_2) { subject[1].first } diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb index 44bcfb93c51..53bf1db3438 100644 --- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb +++ b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::GitlabImport::ProjectCreator do owner: { name: "john" } }.with_indifferent_access end + let(:namespace) { create(:group) } let(:token) { "asdffg" } let(:access_params) { { gitlab_access_token: token } } diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb index f681e3c9f31..a22e80ae1c0 100644 --- a/spec/lib/gitlab/google_code_import/importer_spec.rb +++ b/spec/lib/gitlab/google_code_import/importer_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GoogleCodeImport::Importer do 'user_map' => { 'thilo...' => "@#{mapped_user.username}" } } end + let(:project) { create(:project) } subject { described_class.new(project) } diff --git a/spec/lib/gitlab/google_code_import/project_creator_spec.rb b/spec/lib/gitlab/google_code_import/project_creator_spec.rb index 4be2e16c116..cfebe57aed3 100644 --- a/spec/lib/gitlab/google_code_import/project_creator_spec.rb +++ b/spec/lib/gitlab/google_code_import/project_creator_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::GoogleCodeImport::ProjectCreator do "repositoryUrls" => ["https://vim.googlecode.com/git/"] ) end + let(:namespace) { create(:group) } before do diff --git a/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb index e5d0adcfd5f..91299de0751 100644 --- a/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb +++ b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb @@ -29,6 +29,7 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do correlation_id: 'WMefXn60429' } end + let(:time) { Time.now } let(:result) { Gitlab::Json.parse(subject) } diff --git a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb index 83873081a98..c5d7665c3b2 100644 --- a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb +++ b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb @@ -116,6 +116,7 @@ RSpec.describe Gitlab::Graphql::Authorize::AuthorizeResource do end end end + let(:error) { /#{fake_class.name} has no authorizations/ } describe '#authorized_find!' do diff --git a/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb b/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb index 68b24a60a99..1b9301cd1aa 100644 --- a/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb +++ b/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Gitlab::Graphql::FindArgumentInParent do ) ) end + let(:arg_name) { :my_arg } it 'searches parents and returns the argument' do diff --git a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb index 65698caac34..09d7e084172 100644 --- a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb @@ -185,6 +185,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel.sql('projects.last_repository_check_at IS NULL')).order(last_repository_check_at: :asc).order(id: :asc) end + let(:ascending_nodes) { [project5, project1, project3, project2, project4] } it_behaves_like 'nodes are in ascending order' @@ -210,6 +211,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel.sql('projects.last_repository_check_at IS NULL')).order(last_repository_check_at: :desc).order(id: :asc) end + let(:descending_nodes) { [project3, project1, project5, project2, project4] } it_behaves_like 'nodes are in descending order' @@ -243,6 +245,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel::Table.new(:projects)['name'].lower.asc).order(id: :asc) end + let(:ascending_nodes) { [project1, project5, project3, project2, project4] } it_behaves_like 'nodes are in ascending order' @@ -252,6 +255,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel::Table.new(:projects)['name'].lower.desc).order(id: :desc) end + let(:descending_nodes) { [project4, project2, project3, project5, project1] } it_behaves_like 'nodes are in descending order' diff --git a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb index 50f3a4776be..f5ee8eba8bc 100644 --- a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb +++ b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb @@ -56,6 +56,7 @@ RSpec.describe Gitlab::HookData::IssuableBuilder do ] } end + let(:data) { builder.build(user: user, changes: changes) } it 'populates the :changes hash' do diff --git a/spec/lib/gitlab/import_export/base/object_builder_spec.rb b/spec/lib/gitlab/import_export/base/object_builder_spec.rb index d560c8ea5a7..38c3b23db36 100644 --- a/spec/lib/gitlab/import_export/base/object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/base/object_builder_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Base::ObjectBuilder do name: 'project', path: 'project') end + let(:klass) { Milestone } let(:attributes) { { 'title' => 'Test Base::ObjectBuilder Milestone', 'project' => project } } diff --git a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb index eb6b07ce02f..949cfb5a34d 100644 --- a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb +++ b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb @@ -81,6 +81,7 @@ RSpec.describe Gitlab::ImportExport::JSON::StreamingSerializer do let(:group_options) do { include: [], only: [:name, :path, :description] } end + let(:include) do [{ group: group_options }] end diff --git a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb index 6d5604dc40f..f75494aa7c7 100644 --- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -502,6 +502,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do let(:project_tree_restorer) do described_class.new(user: user, shared: shared, project: project) end + let(:restored_project_json) { project_tree_restorer.restore } it 'does not read a symlink' do @@ -919,6 +920,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do } ] end + let(:tree_hash) { { 'project_members' => project_members } } before do diff --git a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb index 40c103eeda6..a2c5848f100 100644 --- a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb @@ -275,6 +275,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do File.join(shared.export_path, Gitlab::ImportExport.project_filename) end end + let(:shared) { project.import_export_shared } let(:params) { {} } diff --git a/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb b/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb index 9a55e21d031..6dc96217f09 100644 --- a/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb +++ b/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb @@ -10,9 +10,11 @@ RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription d let(:assignees) do [{ 'summary' => 'Laura Haley', 'url' => 'https://webdemo.pagerduty.com/users/P553OPV' }] end + let(:impacted_services) do [{ 'summary' => 'Production XDB Cluster', 'url' => 'https://webdemo.pagerduty.com/services/PN49J75' }] end + let(:incident_payload) do { 'url' => 'https://webdemo.pagerduty.com/incidents/PRORDTY', diff --git a/spec/lib/gitlab/issuable_sorter_spec.rb b/spec/lib/gitlab/issuable_sorter_spec.rb index 60f62062f04..b8d0c7b0609 100644 --- a/spec/lib/gitlab/issuable_sorter_spec.rb +++ b/spec/lib/gitlab/issuable_sorter_spec.rb @@ -52,6 +52,7 @@ RSpec.describe Gitlab::IssuableSorter do build_stubbed(:issue, iid: 1, project: project5), build_stubbed(:issue, iid: 1, project: project6)] end + let(:unsorted) do [sorted[3], sorted[1], sorted[4], sorted[2], sorted[6], sorted[5], sorted[0], sorted[7]] diff --git a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb index 4adc4e4d22a..e57a8457e7c 100644 --- a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb +++ b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb @@ -25,6 +25,7 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do let(:parent_field) do { 'key' => 'FOO-2', 'id' => '1050', 'fields' => { 'summary' => 'parent issue FOO' } } end + let(:priority_field) { { 'name' => 'Medium' } } let(:labels_field) { %w(bug dev backend frontend) } diff --git a/spec/lib/gitlab/jira_import/metadata_collector_spec.rb b/spec/lib/gitlab/jira_import/metadata_collector_spec.rb index 86863d67f25..51751c7b75f 100644 --- a/spec/lib/gitlab/jira_import/metadata_collector_spec.rb +++ b/spec/lib/gitlab/jira_import/metadata_collector_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::JiraImport::MetadataCollector do let(:parent_field) do { 'key' => 'FOO-2', 'id' => '1050', 'fields' => { 'summary' => 'parent issue FOO' } } end + let(:issue_type_field) { { 'name' => 'Task' } } let(:fix_versions_field) { [{ 'name' => '1.0' }, { 'name' => '1.1' }] } let(:priority_field) { { 'name' => 'Medium' } } @@ -30,6 +31,7 @@ RSpec.describe Gitlab::JiraImport::MetadataCollector do 'duedate' => duedate_field } end + let(:jira_issue) do double( id: '1234', diff --git a/spec/lib/gitlab/kubernetes/network_policy_spec.rb b/spec/lib/gitlab/kubernetes/network_policy_spec.rb index a7bb12d1d06..f1730e400af 100644 --- a/spec/lib/gitlab/kubernetes/network_policy_spec.rb +++ b/spec/lib/gitlab/kubernetes/network_policy_spec.rb @@ -48,6 +48,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do labels: labels ) end + let(:spec) { { podSelector: selector, policyTypes: ["Ingress"], ingress: ingress, egress: nil } } end @@ -74,6 +75,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do project: myproject POLICY end + let(:resource) do ::Kubeclient::Resource.new( metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, @@ -170,6 +172,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } ) end + let(:generated_resource) do ::Kubeclient::Resource.new( metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, diff --git a/spec/lib/gitlab/language_detection_spec.rb b/spec/lib/gitlab/language_detection_spec.rb index 04ad19a04ec..14523be8ec6 100644 --- a/spec/lib/gitlab/language_detection_spec.rb +++ b/spec/lib/gitlab/language_detection_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Gitlab::LanguageDetection do { value: 1.51, label: "Go", color: "#2a4776", highlight: "#244776" }, { value: 1.1, label: "MepmepLang", color: "#2a4776", highlight: "#244776" }] end + let(:repository_languages) do [RepositoryLanguage.new(share: 10, programming_language: ruby)] end diff --git a/spec/lib/gitlab/legacy_github_import/importer_spec.rb b/spec/lib/gitlab/legacy_github_import/importer_spec.rb index c443944678f..56d708a1e11 100644 --- a/spec/lib/gitlab/legacy_github_import/importer_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/importer_spec.rb @@ -238,6 +238,7 @@ RSpec.describe Gitlab::LegacyGithubImport::Importer do labels: [double(name: 'Label #2')] ) end + let(:closed_pull_request) do double( number: 1347, diff --git a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb index 6a51cb6f39d..a5d2e00890b 100644 --- a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::LegacyGithubImport::IssuableFormatter do let(:raw_data) do double(number: 42) end + let(:project) { double(import_type: 'github') } let(:issuable_formatter) { described_class.new(project, raw_data) } diff --git a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb index 2ac79c4f5b8..148b59dedab 100644 --- a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::LegacyGithubImport::MilestoneFormatter do closed_at: nil } end + let(:iid_attr) { :number } subject(:formatter) { described_class.new(project, raw_data) } diff --git a/spec/lib/gitlab/lograge/custom_options_spec.rb b/spec/lib/gitlab/lograge/custom_options_spec.rb index 218007c6e2a..9daedfc37e4 100644 --- a/spec/lib/gitlab/lograge/custom_options_spec.rb +++ b/spec/lib/gitlab/lograge/custom_options_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Lograge::CustomOptions do metadata: { 'meta.user' => 'jane.doe' } } end + let(:event) { ActiveSupport::Notifications::Event.new('test', 1, 2, 'transaction_id', event_payload) } subject { described_class.call(event) } diff --git a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb index 40ff9a765a6..bf40af8e62e 100644 --- a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb +++ b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do end end end + let(:storable) { storable_class.new } let(:cache_key) { "markdown_cache:#{storable.cache_key}" } diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb index a481c536f8d..730a31346d7 100644 --- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb @@ -191,6 +191,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store out_of_the_box_dashboard: true } end + let(:dashboard_path) { '.gitlab/dashboards/test.yml' } let(:project) { project_with_dashboard(dashboard_path) } diff --git a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb index e794e28a279..d5998bb2fa1 100644 --- a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb @@ -98,6 +98,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Processor do Gitlab::Metrics::Dashboard::Stages::Sorter ] end + let(:dashboard) { described_class.new(*process_params).process } it 'includes only dashboard metrics' do diff --git a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb index e63ad6e6626..2ec2571b7fe 100644 --- a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb +++ b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb @@ -58,6 +58,7 @@ RSpec.describe Gitlab::PhabricatorImport::UserFinder, :clean_gitlab_redis_cache ) ] end + let(:client) do client = instance_double(Gitlab::PhabricatorImport::Conduit::User) allow(client).to receive(:users).and_return(response) diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 75a3fe06632..6e3c60b58dc 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -430,6 +430,7 @@ RSpec.describe Gitlab::ProjectSearchResults do private_project.add_maintainer(user) user end + let(:team_reporter) do user = create(:user, username: 'private-project-reporter') private_project.add_reporter(user) diff --git a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb index 117ca798022..60449aeef7d 100644 --- a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::Prometheus::Queries::MatchedMetricQuery do [{ '__name__' => 'metric_a' }, { '__name__' => 'metric_b' }] end + let(:partially_empty_series_info) { [{ '__name__' => 'metric_a', 'environment' => '' }] } let(:empty_series_info) { [] } diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 242a0ced031..0774c2f3144 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -191,6 +191,7 @@ RSpec.describe Gitlab::PrometheusClient do } } end + let(:query_url) { prometheus_query_with_time_url(query, Time.now.utc) } around do |example| diff --git a/spec/lib/gitlab/sidekiq_cluster_spec.rb b/spec/lib/gitlab/sidekiq_cluster_spec.rb index d625a2a2185..5dd913aebb0 100644 --- a/spec/lib/gitlab/sidekiq_cluster_spec.rb +++ b/spec/lib/gitlab/sidekiq_cluster_spec.rb @@ -91,6 +91,7 @@ RSpec.describe Gitlab::SidekiqCluster do let(:options) do { env: :production, directory: 'foo/bar', max_concurrency: 20, min_concurrency: 0, worker_id: first_worker_id, timeout: 10, dryrun: false } end + let(:env) { { "ENABLE_SIDEKIQ_CLUSTER" => "1", "SIDEKIQ_WORKER_ID" => first_worker_id.to_s } } let(:args) { ['bundle', 'exec', 'sidekiq', anything, '-eproduction', '-t10', *([anything] * 5)] } diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb index 03ace9a01c7..ad106837c47 100644 --- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -41,6 +41,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do 'scheduling_latency_s' => scheduling_latency_s ) end + let(:end_payload) do start_payload.merge( 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec', @@ -51,6 +52,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do 'db_duration_s' => 0.0 ) end + let(:exception_payload) do end_payload.merge( 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec', diff --git a/spec/lib/gitlab/sidekiq_middleware_spec.rb b/spec/lib/gitlab/sidekiq_middleware_spec.rb index b4e47ac4cbb..4ee9569a0cf 100644 --- a/spec/lib/gitlab/sidekiq_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware_spec.rb @@ -63,6 +63,7 @@ RSpec.describe Gitlab::SidekiqMiddleware do Gitlab::SidekiqMiddleware::DuplicateJobs::Server ] end + let(:enabled_sidekiq_middlewares) { all_sidekiq_middlewares - disabled_sidekiq_middlewares } shared_examples "a server middleware chain" do diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index 7edfde09864..b49efd6a092 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -280,6 +280,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do '[fc00:bf8b:e62c:abcd:abcd:aaaa:aaaa:aaaa]' ] end + let(:fake_domain) { 'www.fakedomain.fake' } shared_examples 'allows local requests' do |url_blocker_attributes| diff --git a/spec/lib/gitlab/usage_data/topology_spec.rb b/spec/lib/gitlab/usage_data/topology_spec.rb index bf61ddd9d83..0cea86726dc 100644 --- a/spec/lib/gitlab/usage_data/topology_spec.rb +++ b/spec/lib/gitlab/usage_data/topology_spec.rb @@ -177,6 +177,7 @@ RSpec.describe Gitlab::UsageData::Topology do } ] end + let(:node_uname_info_response) do [ { @@ -195,6 +196,7 @@ RSpec.describe Gitlab::UsageData::Topology do ] end # The services in this response should all be mapped to localhost i.e. the same node + let(:service_memory_response) do [ { |