diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-10 15:09:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-10 15:09:12 +0300 |
commit | 0e0df204c1a0d859ccbbe1be83a5e09a53381f17 (patch) | |
tree | e7bf6fed5fa2b74caf31957c468b0cbc303f4c45 /spec/lib | |
parent | a2344dbf1942dc3919c55b0684d2566368e03852 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
4 files changed, 54 insertions, 5 deletions
diff --git a/spec/lib/gitlab/database/partitioning/list/convert_table_spec.rb b/spec/lib/gitlab/database/partitioning/list/convert_table_spec.rb index d9dd1b387dc..81b00f82803 100644 --- a/spec/lib/gitlab/database/partitioning/list/convert_table_spec.rb +++ b/spec/lib/gitlab/database/partitioning/list/convert_table_spec.rb @@ -74,9 +74,11 @@ RSpec.describe Gitlab::Database::Partitioning::List::ConvertTable, feature_categ it 'adds a PostgresAsyncConstraintValidation record' do expect { prepare }.to change { Gitlab::Database::AsyncConstraints::PostgresAsyncConstraintValidation.count - }.from(0).to(1) + }.by(1) + + record = Gitlab::Database::AsyncConstraints::PostgresAsyncConstraintValidation + .where(table_name: table_name).last - record = Gitlab::Database::AsyncConstraints::PostgresAsyncConstraintValidation.last expect(record.name).to eq described_class::PARTITIONING_CONSTRAINT_NAME expect(record).to be_check_constraint end 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 4a0a740f121..571c67db597 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 @@ -547,10 +547,13 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe it 'deletes those pertaining to the given table' do expect { migration.cleanup_partitioning_data_migration(source_table) } - .to change { ::Gitlab::Database::BackgroundMigration::BatchedMigration.count }.from(2).to(1) + .to change { ::Gitlab::Database::BackgroundMigration::BatchedMigration.count }.by(-1) - remaining_record = ::Gitlab::Database::BackgroundMigration::BatchedMigration.first - expect(remaining_record.table_name).to eq('other_table') + expect(::Gitlab::Database::BackgroundMigration::BatchedMigration.where(table_name: 'other_table').any?) + .to be_truthy + + expect(::Gitlab::Database::BackgroundMigration::BatchedMigration.where(table_name: source_table).any?) + .to be_falsy end end end diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/installation_creation_date_approximation_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/installation_creation_date_approximation_metric_spec.rb new file mode 100644 index 00000000000..11e1139e542 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/installation_creation_date_approximation_metric_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::InstallationCreationDateApproximationMetric, + feature_category: :service_ping do + let_it_be(:application_setting) { create(:application_setting) } + + context 'with a root user' do + let_it_be(:root) { create(:user, id: 1, created_at: DateTime.current - 2.days) } + let_it_be(:expected_value) { root.reload.created_at } # reloading to get the timestamp from the database + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'database' } + end + + context 'without a root user' do + let_it_be(:another_user) { create(:user, id: 2, created_at: DateTime.current + 2.days) } + let_it_be(:expected_value) { application_setting.reload.created_at } + + it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'database' } + end +end diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb index c44bb64a5c0..8ed0a2df586 100644 --- a/spec/lib/gitlab_spec.rb +++ b/spec/lib/gitlab_spec.rb @@ -132,6 +132,28 @@ RSpec.describe Gitlab do end end + describe '.com_except_jh?' do + subject { described_class.com_except_jh? } + + before do + allow(described_class).to receive(:com?).and_return(com?) + allow(described_class).to receive(:jh?).and_return(jh?) + end + + using RSpec::Parameterized::TableSyntax + + where(:com?, :jh?, :expected) do + true | true | false + true | false | true + false | true | false + false | false | false + end + + with_them do + it { is_expected.to eq(expected) } + end + end + describe '.com' do subject { described_class.com { true } } |