diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 00:13:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-08 00:13:36 +0300 |
commit | c19944d9970b788d8523cee6ee05217a8afd7646 (patch) | |
tree | e2d15e8c0d541b9b2fe26b9b82f23661df120f94 /spec/lib | |
parent | 3ff3d897d6529aabb21aa6aed54eb430a9cf0fe2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
4 files changed, 53 insertions, 2 deletions
diff --git a/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb b/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb index 957be21f5eb..017548b6fb5 100644 --- a/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb +++ b/spec/lib/generators/batched_background_migration/batched_background_migration_generator_spec.rb @@ -25,6 +25,7 @@ RSpec.describe BatchedBackgroundMigration::BatchedBackgroundMigrationGenerator, let(:expected_migration_spec_file) { load_expected_file('queue_my_batched_migration_spec.txt') } let(:expected_migration_job_file) { load_expected_file('my_batched_migration.txt') } let(:expected_migration_job_spec_file) { load_expected_file('my_batched_migration_spec_matcher.txt') } + let(:expected_migration_dictionary) { load_expected_file('my_batched_migration_dictionary.txt') } it 'generates expected files' do run_generator %w[my_batched_migration --table_name=projects --column_name=id --feature_category=database] @@ -45,6 +46,10 @@ RSpec.describe BatchedBackgroundMigration::BatchedBackgroundMigrationGenerator, # Regex is used to match the dynamic schema: <version> in the specs expect(migration_job_spec_file).to match(/#{expected_migration_job_spec_file}/) end + + assert_file('db/docs/batched_background_migrations/my_batched_migration.yml') do |migration_dictionary| + expect(migration_dictionary).to eq(expected_migration_dictionary) + end end end diff --git a/spec/lib/generators/batched_background_migration/expected_files/my_batched_migration_dictionary.txt b/spec/lib/generators/batched_background_migration/expected_files/my_batched_migration_dictionary.txt new file mode 100644 index 00000000000..0b350961abd --- /dev/null +++ b/spec/lib/generators/batched_background_migration/expected_files/my_batched_migration_dictionary.txt @@ -0,0 +1,6 @@ +--- +migration_job_name: MyBatchedMigration +description: # Please capture what MyBatchedMigration does +feature_category: database +introduced_by_url: # URL of the MR (or issue/commit) that introduced the migration +milestone: diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb index 09d8ea3cc0a..7bdfa8922d3 100644 --- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb @@ -213,8 +213,13 @@ RSpec.describe Gitlab::GitalyClient::RefService, feature_category: :gitaly do client.local_branches(sort_by: 'name_asc') end - it 'raises an argument error if an invalid sort_by parameter is passed' do - expect { client.local_branches(sort_by: 'invalid_sort') }.to raise_error(ArgumentError) + it 'uses default sort by name' do + expect_any_instance_of(Gitaly::RefService::Stub) + .to receive(:find_local_branches) + .with(gitaly_request_with_params(sort_by: :NAME), kind_of(Hash)) + .and_return([]) + + client.local_branches(sort_by: 'invalid') end end @@ -270,6 +275,17 @@ RSpec.describe Gitlab::GitalyClient::RefService, feature_category: :gitaly do client.tags(sort_by: 'version_asc') end end + + context 'when sorting option is invalid' do + it 'uses default sort by name' do + expect_any_instance_of(Gitaly::RefService::Stub) + .to receive(:find_all_tags) + .with(gitaly_request_with_params(sort_by: nil), kind_of(Hash)) + .and_return([]) + + client.tags(sort_by: 'invalid') + end + end end context 'with pagination option' do diff --git a/spec/lib/gitlab/utils/username_and_email_generator_spec.rb b/spec/lib/gitlab/utils/username_and_email_generator_spec.rb new file mode 100644 index 00000000000..45df8f08055 --- /dev/null +++ b/spec/lib/gitlab/utils/username_and_email_generator_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Utils::UsernameAndEmailGenerator, feature_category: :system_access do + let(:username_prefix) { 'username_prefix' } + let(:email_domain) { 'example.com' } + + subject { described_class.new(username_prefix: username_prefix, email_domain: email_domain) } + + describe 'email domain' do + it 'defaults to `Gitlab.config.gitlab.host`' do + expect(described_class.new(username_prefix: username_prefix).email).to end_with("@#{Gitlab.config.gitlab.host}") + end + + context 'when specified' do + it 'uses the specified email domain' do + expect(subject.email).to end_with("@#{email_domain}") + end + end + end + + include_examples 'username and email pair is generated by Gitlab::Utils::UsernameAndEmailGenerator' +end |