diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-31 12:10:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-31 12:10:44 +0300 |
commit | 3608a02eb461c2cadbac0e08c0c6edec471d6648 (patch) | |
tree | 928249e7dfdf79b8a0bf0aa0444fd95764c2fdc9 /spec | |
parent | 03f56ec7f8285ce17ea3ce59d397a2ee78ce6469 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
18 files changed, 24 insertions, 157 deletions
diff --git a/spec/factories/project_metrics_settings.rb b/spec/factories/project_metrics_settings.rb deleted file mode 100644 index b5c0fd88a6c..00000000000 --- a/spec/factories/project_metrics_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :project_metrics_setting, class: 'ProjectMetricsSetting' do - project - external_dashboard_url { 'https://grafana.com' } - end -end diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb index 76b07d903bc..857cb1f39a2 100644 --- a/spec/features/issues/user_creates_issue_spec.rb +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "User creates issue", feature_category: :team_planning do sign_out(:user) end - it "redirects to signin then back to new issue after signin", :js, quarantine: 'https://gitlab.com/gitlab-org/quality/engineering-productivity/master-broken-incidents/-/issues/1486' do + it "redirects to signin then back to new issue after signin", :js do create(:issue, project: project) visit project_issues_path(project) diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index a7038e38412..341cc150a64 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -130,7 +130,7 @@ RSpec.describe 'User creates snippet', :js, feature_category: :source_code_manag expect(page).not_to have_content(files_validation_message) end - it 'previews a snippet with file', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/408203' do + it 'previews a snippet with file' do # Click placeholder first to expand full description field snippet_fill_in_description('My Snippet') dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') @@ -145,7 +145,11 @@ RSpec.describe 'User creates snippet', :js, feature_category: :source_code_manag # Adds a cache buster for checking if the image exists as Selenium is now handling the cached requests # not anymore as requests when they come straight from memory cache. # accept_confirm is needed because of https://gitlab.com/gitlab-org/gitlab/-/issues/262102 - reqs = inspect_requests { accept_confirm { visit("#{link}?ran=#{SecureRandom.base64(20)}") } } + reqs = inspect_requests do + visit("#{link}?ran=#{SecureRandom.base64(20)}") do + page.driver.browser.switch_to.alert.accept + end + end expect(reqs.first.status_code).to eq(200) end end diff --git a/spec/helpers/environments_helper_spec.rb b/spec/helpers/environments_helper_spec.rb index 6be86694b10..6624404bc49 100644 --- a/spec/helpers/environments_helper_spec.rb +++ b/spec/helpers/environments_helper_spec.rb @@ -34,7 +34,6 @@ RSpec.describe EnvironmentsHelper, feature_category: :environment_management do 'project_path' => project_path(project), 'tags_path' => project_tags_path(project), 'has_metrics' => environment.has_metrics?.to_s, - 'external_dashboard_url' => nil, 'environment_state' => environment.state, 'custom_metrics_path' => project_prometheus_metrics_path(project), 'validate_query_path' => validate_query_project_prometheus_metrics_path(project), @@ -58,16 +57,6 @@ RSpec.describe EnvironmentsHelper, feature_category: :environment_management do end end - context 'with metrics_setting' do - before do - create(:project_metrics_setting, project: project, external_dashboard_url: 'http://gitlab.com') - end - - it 'adds external_dashboard_url' do - expect(metrics_data['external_dashboard_url']).to eq('http://gitlab.com') - end - end - context 'when the environment is not available' do before do environment.stop diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index aa064a26ec4..71004ef2a08 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -809,22 +809,6 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do end end - describe '#metrics_external_dashboard_url' do - context 'metrics_setting exists' do - it 'returns external_dashboard_url' do - metrics_setting = create(:project_metrics_setting, project: project) - - expect(helper.metrics_external_dashboard_url).to eq(metrics_setting.external_dashboard_url) - end - end - - context 'metrics_setting does not exist' do - it 'returns nil' do - expect(helper.metrics_external_dashboard_url).to eq(nil) - end - end - end - describe '#grafana_integration_url' do subject { helper.grafana_integration_url } diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 5bbb95b3ea5..b1b438fa592 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -690,7 +690,6 @@ project: - pool_repository - kubernetes_namespaces - error_tracking_setting -- metrics_setting - gitlab_slack_application_integration - github_integration - protected_environments @@ -872,8 +871,6 @@ suggestions: - note diff_note_positions: - note -metrics_setting: -- project protected_environments: - project - group diff --git a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb index 8089b40cae8..08abd7908d2 100644 --- a/spec/lib/gitlab/import_export/attributes_permitter_spec.rb +++ b/spec/lib/gitlab/import_export/attributes_permitter_spec.rb @@ -97,7 +97,6 @@ RSpec.describe Gitlab::ImportExport::AttributesPermitter, feature_category: :imp :user | true :author | false :ci_cd_settings | true - :metrics_setting | true :project_badges | true :pipeline_schedules | true :error_tracking_setting | true diff --git a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb index 1d3fc764b50..09a2417ce1e 100644 --- a/spec/lib/gitlab/import_export/import_test_coverage_spec.rb +++ b/spec/lib/gitlab/import_export/import_test_coverage_spec.rb @@ -48,7 +48,6 @@ RSpec.describe 'Test coverage of the Project Import', feature_category: :importe project.ci_pipelines.notes.events.push_event_payload project.protected_branches.unprotect_access_levels project.prometheus_metrics - project.metrics_setting project.boards.lists.label.priorities project.service_desk_setting project.security_setting diff --git a/spec/lib/gitlab/sql/cte_spec.rb b/spec/lib/gitlab/sql/cte_spec.rb index 523380eae34..d2d3fdbb450 100644 --- a/spec/lib/gitlab/sql/cte_spec.rb +++ b/spec/lib/gitlab/sql/cte_spec.rb @@ -15,8 +15,7 @@ RSpec.describe Gitlab::SQL::CTE do expected = [ "#{name} AS ", - Gitlab::Database::AsWithMaterialized.materialized_if_supported, - (' ' unless Gitlab::Database::AsWithMaterialized.materialized_if_supported.blank?), + 'MATERIALIZED ', "(#{sql1})" ].join diff --git a/spec/lib/gitlab/usage/metrics/query_spec.rb b/spec/lib/gitlab/usage/metrics/query_spec.rb index 355d619f768..750d340551a 100644 --- a/spec/lib/gitlab/usage/metrics/query_spec.rb +++ b/spec/lib/gitlab/usage/metrics/query_spec.rb @@ -77,7 +77,7 @@ RSpec.describe Gitlab::Usage::Metrics::Query do it 'returns the histogram sql' do expect(described_class.for(:histogram, AlertManagement::HttpIntegration.active, :project_id, buckets: 1..2, bucket_size: 101)) - .to match(/^WITH "count_cte" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "count_cte" AS MATERIALIZED/) end end diff --git a/spec/lib/gitlab/usage_data_queries_spec.rb b/spec/lib/gitlab/usage_data_queries_spec.rb index 30588324adf..3ec7bf33623 100644 --- a/spec/lib/gitlab/usage_data_queries_spec.rb +++ b/spec/lib/gitlab/usage_data_queries_spec.rb @@ -82,7 +82,7 @@ RSpec.describe Gitlab::UsageDataQueries do it 'returns the histogram sql' do expect(described_class.histogram(AlertManagement::HttpIntegration.active, :project_id, buckets: 1..2, bucket_size: 101)) - .to match(/^WITH "count_cte" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "count_cte" AS MATERIALIZED/) end end diff --git a/spec/models/concerns/as_cte_spec.rb b/spec/models/concerns/as_cte_spec.rb index 06d9650ec46..c92d46ef25f 100644 --- a/spec/models/concerns/as_cte_spec.rb +++ b/spec/models/concerns/as_cte_spec.rb @@ -21,7 +21,7 @@ RSpec.describe AsCte do it { expect(subject.query).to eq(query) } it { expect(subject.table.name).to eq(name.to_s) } - context 'with materialized parameter', if: Gitlab::Database::AsWithMaterialized.materialized_supported? do + context 'with materialized parameter' do subject { query.as_cte(name, materialized: materialized).to_arel.to_sql } context 'as true' do diff --git a/spec/models/project_metrics_setting_spec.rb b/spec/models/project_metrics_setting_spec.rb deleted file mode 100644 index 6639f9cb208..00000000000 --- a/spec/models/project_metrics_setting_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe ProjectMetricsSetting do - describe 'Associations' do - it { is_expected.to belong_to(:project) } - end - - describe 'Validations' do - context 'when external_dashboard_url is over 255 chars' do - before do - subject.external_dashboard_url = 'https://' + 'a' * 250 - end - - it 'fails validation' do - expect(subject).not_to be_valid - expect(subject.errors.messages[:external_dashboard_url]) - .to include('is too long (maximum is 255 characters)') - end - end - - context 'with unsafe url' do - before do - subject.external_dashboard_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>} - end - - it { is_expected.to be_invalid } - end - - context 'non ascii chars in external_dashboard_url' do - before do - subject.external_dashboard_url = 'http://gitlab.com/api/0/projects/project1/something€' - end - - it { is_expected.to be_invalid } - end - - context 'internal url in external_dashboard_url' do - before do - subject.external_dashboard_url = 'http://192.168.1.1' - end - - it { is_expected.to be_valid } - end - - context 'dashboard_timezone' do - it { is_expected.to define_enum_for(:dashboard_timezone).with_values({ local: 0, utc: 1 }) } - - it 'defaults to local' do - expect(subject.dashboard_timezone).to eq('local') - end - end - end - - describe '#dashboard_timezone=' do - it 'downcases string' do - subject.dashboard_timezone = 'UTC' - - expect(subject.dashboard_timezone).to eq('utc') - end - end -end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 8b25bc7d118..9577afbf11a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -5099,7 +5099,7 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr subject { described_class.wrap_with_cte(projects) } it 'wrapped query matches original' do - expect(subject.to_sql).to match(/^WITH "projects_cte" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + expect(subject.to_sql).to match(/^WITH "projects_cte" AS MATERIALIZED/) expect(subject).to match_array(projects) end end @@ -8090,14 +8090,6 @@ RSpec.describe Project, factory_default: :keep, feature_category: :groups_and_pr it { is_expected.not_to include(user) } end - describe "#metrics_setting" do - let(:project) { build(:project) } - - it 'creates setting if it does not exist' do - expect(project.metrics_setting).to be_an_instance_of(ProjectMetricsSetting) - end - end - describe '#enabled_group_deploy_keys' do let_it_be(:project) { create(:project) } diff --git a/spec/support/multiple_databases.rb b/spec/support/multiple_databases.rb index 616cf00269c..1c556858018 100644 --- a/spec/support/multiple_databases.rb +++ b/spec/support/multiple_databases.rb @@ -7,8 +7,6 @@ RSpec.configure do |config| # at startup, but that generates its own # `Gitlab::Database::Reflection` so the result is not memoized by # callers of `ApplicationRecord.database.version`, such as - # `Gitlab::Database::AsWithMaterialized.materialized_supported?`. - # TODO This can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/325639 is completed. [ApplicationRecord, ::Ci::ApplicationRecord].each { |record| record.database.version } config.around(:each, :reestablished_active_record_base) do |example| diff --git a/spec/support/shared_examples/finders/issues_finder_shared_examples.rb b/spec/support/shared_examples/finders/issues_finder_shared_examples.rb index 19001abcbe2..ed8feebf1f6 100644 --- a/spec/support/shared_examples/finders/issues_finder_shared_examples.rb +++ b/spec/support/shared_examples/finders/issues_finder_shared_examples.rb @@ -1406,7 +1406,7 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it 'returns true' do expect(finder.use_cte_for_search?).to be_truthy expect(finder.execute.to_sql) - .to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "issues" AS MATERIALIZED/) end end @@ -1416,7 +1416,7 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it 'returns true' do expect(finder.use_cte_for_search?).to be_truthy expect(finder.execute.to_sql) - .to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "issues" AS MATERIALIZED/) end end @@ -1426,7 +1426,7 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it 'returns true' do expect(finder.use_cte_for_search?).to be_truthy expect(finder.execute.to_sql) - .to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "issues" AS MATERIALIZED/) end end @@ -1436,7 +1436,7 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it 'returns true' do expect(finder.use_cte_for_search?).to be_truthy expect(finder.execute.to_sql) - .to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + .to match(/^WITH "issues" AS MATERIALIZED/) end end end diff --git a/spec/support/shared_examples/lib/gitlab/database/cte_materialized_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/cte_materialized_shared_examples.rb index df795723874..b80a51a1fc6 100644 --- a/spec/support/shared_examples/lib/gitlab/database/cte_materialized_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/database/cte_materialized_shared_examples.rb @@ -4,40 +4,17 @@ RSpec.shared_examples 'CTE with MATERIALIZED keyword examples' do describe 'adding MATERIALIZE to the CTE' do let(:options) { {} } - before do - # Clear the cached value before the test - Gitlab::Database::AsWithMaterialized.clear_memoization(:materialized_supported) - end - - context 'when PG version is <12' do - it 'does not add MATERIALIZE keyword' do - allow(ApplicationRecord.database).to receive(:version).and_return('11.1') + it 'adds MATERIALIZE keyword' do + allow(ApplicationRecord.database).to receive(:version).and_return('12.1') - expect(query).to include(expected_query_block_without_materialized) - end + expect(query).to include(expected_query_block_with_materialized) end - context 'when PG version is >=12' do - it 'adds MATERIALIZE keyword' do - allow(ApplicationRecord.database).to receive(:version).and_return('12.1') - - expect(query).to include(expected_query_block_with_materialized) - end + context 'when materialized is disabled' do + let(:options) { { materialized: false } } - context 'when version is higher than 12' do - it 'adds MATERIALIZE keyword' do - allow(ApplicationRecord.database).to receive(:version).and_return('15.1') - - expect(query).to include(expected_query_block_with_materialized) - end - end - - context 'when materialized is disabled' do - let(:options) { { materialized: false } } - - it 'does not add MATERIALIZE keyword' do - expect(query).to include(expected_query_block_without_materialized) - end + it 'does not add MATERIALIZE keyword' do + expect(query).to include(expected_query_block_without_materialized) end end end diff --git a/spec/support_specs/database/multiple_databases_helpers_spec.rb b/spec/support_specs/database/multiple_databases_helpers_spec.rb index 2577b64f214..0191a759605 100644 --- a/spec/support_specs/database/multiple_databases_helpers_spec.rb +++ b/spec/support_specs/database/multiple_databases_helpers_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Database::MultipleDatabasesHelpers' do let(:query) do <<~SQL - WITH cte AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported} (SELECT 1) SELECT 1; + WITH cte AS MATERIALIZED (SELECT 1) SELECT 1; SQL end |