diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
commit | ec8cf3f7c8d9ac408a81af714db7a0640cf0199d (patch) | |
tree | cbe011f521781fe98c656330cb5f42703bd71c03 /spec | |
parent | af833d9730dd367984b55ef02ccc3fe6eb83f0e4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
12 files changed, 55 insertions, 76 deletions
diff --git a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb index 8b5ea522641..8bb3b577135 100644 --- a/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb +++ b/spec/contracts/provider_specs/helpers/provider/contract_source_helper_spec.rb @@ -71,15 +71,18 @@ RSpec.describe Provider::ContractSourceHelper, feature_category: :not_owned do describe '#local_contract_location' do it 'returns the contract file path with the prefix path for a rake task' do - rake_task_relative_path = '/gitlab/spec/contracts/contracts/project' + rake_task_relative_path = '/spec/contracts/contracts/project' - expect(subject.local_contract_location(:rake, split_pact_helper_path)).to include(rake_task_relative_path) + rake_task_path = subject.local_contract_location(:rake, split_pact_helper_path) + + expect(rake_task_path).to include(rake_task_relative_path) + expect(rake_task_path).not_to include('../') end it 'returns the contract file path with the prefix path for a spec' do - rake_task_relative_path = '../contracts/project' + spec_relative_path = '../contracts/project' - expect(subject.local_contract_location(:spec, split_pact_helper_path)).to include(rake_task_relative_path) + expect(subject.local_contract_location(:spec, split_pact_helper_path)).to include(spec_relative_path) end end diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 081e3169c3a..fe197fcac30 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -191,7 +191,7 @@ RSpec.describe GraphqlController do expected_message = "Authentication error: " \ "enable 2FA in your profile settings to continue using GitLab: %{mfa_help_page}" % - { mfa_help_page: controller.mfa_help_page_url } + { mfa_help_page: controller.mfa_help_page_url } expect(json_response).to eq({ 'errors' => [{ 'message' => expected_message }] }) end diff --git a/spec/features/user_sees_marketing_header_spec.rb b/spec/features/user_sees_marketing_header_spec.rb deleted file mode 100644 index eae964cec02..00000000000 --- a/spec/features/user_sees_marketing_header_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe 'User sees experimental lmarketing header' do - let_it_be(:project) { create(:project, :public) } - - context 'when not logged in' do - it 'shows marketing header links', :aggregate_failures do - visit project_path(project) - - expect(page).to have_text "About GitLab" - expect(page).to have_text "Pricing" - expect(page).to have_text "Talk to an expert" - expect(page).to have_text "Sign up now" - expect(page).to have_text "Login" - end - end - - context 'when logged in' do - it 'does not show marketing header links', :aggregate_failures do - sign_in(create(:user)) - - visit project_path(project) - - expect(page).not_to have_text "About GitLab" - expect(page).not_to have_text "Pricing" - expect(page).not_to have_text "Talk to an expert" - end - end -end diff --git a/spec/finders/clusters/agent_tokens_finder_spec.rb b/spec/finders/clusters/agent_tokens_finder_spec.rb index b03bb7d2a4a..bd0668f9a43 100644 --- a/spec/finders/clusters/agent_tokens_finder_spec.rb +++ b/spec/finders/clusters/agent_tokens_finder_spec.rb @@ -5,23 +5,39 @@ require 'spec_helper' RSpec.describe Clusters::AgentTokensFinder do describe '#execute' do let_it_be(:project) { create(:project) } + let_it_be(:agent) { create(:cluster_agent, project: project) } let(:user) { create(:user, maintainer_projects: [project]) } - let(:agent) { create(:cluster_agent, project: project) } - let!(:matching_agent_tokens) do + let_it_be(:active_agent_tokens) do [ create(:cluster_agent_token, agent: agent), + create(:cluster_agent_token, agent: agent) + ] + end + + let_it_be(:revoked_agent_tokens) do + [ + create(:cluster_agent_token, :revoked, agent: agent), create(:cluster_agent_token, :revoked, agent: agent) ] end + let_it_be(:token_for_different_agent) { create(:cluster_agent_token, agent: create(:cluster_agent)) } + subject(:execute) { described_class.new(agent, user).execute } - it 'returns the tokens of the specified agent' do - # creating a token in a different agent to make sure it will not be included in the result - create(:cluster_agent_token, agent: create(:cluster_agent)) + it { is_expected.to match_array(active_agent_tokens + revoked_agent_tokens) } + + context 'when filtering by status=active' do + subject(:execute) { described_class.new(agent, user, status: 'active').execute } + + it { is_expected.to match_array(active_agent_tokens) } + end + + context 'when filtering by status=revoked' do + subject(:execute) { described_class.new(agent, user, status: 'revoked').execute } - expect(execute).to match_array(matching_agent_tokens) + it { is_expected.to match_array(revoked_agent_tokens) } end context 'when user does not have permission' do diff --git a/spec/frontend/fixtures/tabs.rb b/spec/frontend/fixtures/tabs.rb index 697ff1c7c20..57ecb32e289 100644 --- a/spec/frontend/fixtures/tabs.rb +++ b/spec/frontend/fixtures/tabs.rb @@ -11,14 +11,14 @@ RSpec.describe 'GlTabsBehavior', '(JavaScript fixtures)', type: :helper do it 'tabs/tabs.html' do tabs = gl_tabs_nav({ data: { testid: 'tabs' } }) do gl_tab_link_to('Foo', '#foo', item_active: true, data: { testid: 'foo-tab' }) + - gl_tab_link_to('Bar', '#bar', item_active: false, data: { testid: 'bar-tab' }) + - gl_tab_link_to('Qux', '#qux', item_active: false, data: { testid: 'qux-tab' }) + gl_tab_link_to('Bar', '#bar', item_active: false, data: { testid: 'bar-tab' }) + + gl_tab_link_to('Qux', '#qux', item_active: false, data: { testid: 'qux-tab' }) end panels = content_tag(:div, class: 'tab-content') do content_tag(:div, 'Foo', { id: 'foo', class: 'tab-pane active', data: { testid: 'foo-panel' } }) + - content_tag(:div, 'Bar', { id: 'bar', class: 'tab-pane', data: { testid: 'bar-panel' } }) + - content_tag(:div, 'Qux', { id: 'qux', class: 'tab-pane', data: { testid: 'qux-panel' } }) + content_tag(:div, 'Bar', { id: 'bar', class: 'tab-pane', data: { testid: 'bar-panel' } }) + + content_tag(:div, 'Qux', { id: 'qux', class: 'tab-pane', data: { testid: 'qux-panel' } }) end @tabs = tabs + panels diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 7571ae75ab5..ac811b46c39 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -555,25 +555,15 @@ RSpec.describe ApplicationHelper do end describe '#page_class' do - let_it_be(:expected_class) { 'logged-out-marketing-header' } - - let(:current_user) { nil } - - subject do + subject(:page_class) do helper.page_class.flatten end before do - allow(helper).to receive(:current_user) { current_user } + allow(helper).to receive(:current_user).and_return(nil) end - it { is_expected.to include(expected_class) } - - context 'when a user is logged in' do - let(:current_user) { create(:user) } - - it { is_expected.not_to include(expected_class) } - end + it { is_expected.not_to include('logged-out-marketing-header') } end describe '#dispensable_render' do diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index ee95cf4d2f8..e552b9e9c0c 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -635,12 +635,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do context 'non-matches' do where(:keyword, :source) do - %w[web trigger schedule api external].map { |source| ['pushes', source] } + - %w[push trigger schedule api external].map { |source| ['web', source] } + - %w[push web schedule api external].map { |source| ['triggers', source] } + - %w[push web trigger api external].map { |source| ['schedules', source] } + - %w[push web trigger schedule external].map { |source| ['api', source] } + - %w[push web trigger schedule api].map { |source| ['external', source] } + %w[web trigger schedule api external].map { |source| ['pushes', source] } + + %w[push trigger schedule api external].map { |source| ['web', source] } + + %w[push web schedule api external].map { |source| ['triggers', source] } + + %w[push web trigger api external].map { |source| ['schedules', source] } + + %w[push web trigger schedule external].map { |source| ['api', source] } + + %w[push web trigger schedule api].map { |source| ['external', source] } end with_them do diff --git a/spec/lib/security/weak_passwords_spec.rb b/spec/lib/security/weak_passwords_spec.rb index 9d12c352abf..afa9448e746 100644 --- a/spec/lib/security/weak_passwords_spec.rb +++ b/spec/lib/security/weak_passwords_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Security::WeakPasswords do +RSpec.describe Security::WeakPasswords, feature_category: :authentication_and_authorization do describe "#weak_for_user?" do using RSpec::Parameterized::TableSyntax @@ -34,6 +34,7 @@ RSpec.describe Security::WeakPasswords do "!@mCwEaKy" | true "A1B2pass" | true "A1B2C3jr" | false # jr is too short + "3e18a7f60a908e329958396d68131d39e1b66a03ea420725e2a0fce7cb17pass" | false # Password is >= 64 chars # Predictable username substrings "56d4ab689a" | true diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index afa9ab81851..8628e95ba80 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -79,11 +79,11 @@ RSpec.describe Ci::CreatePipelineService, :yaml_processor_feature_flag_corectnes let(:accepted_n_plus_ones) do 1 + # SELECT "ci_instance_variables" - 1 + # INSERT INTO "ci_stages" - 1 + # SELECT "ci_builds".* FROM "ci_builds" - 1 + # INSERT INTO "ci_builds" - 1 + # INSERT INTO "ci_builds_metadata" - 1 # SELECT "taggings".* FROM "taggings" + 1 + # INSERT INTO "ci_stages" + 1 + # SELECT "ci_builds".* FROM "ci_builds" + 1 + # INSERT INTO "ci_builds" + 1 + # INSERT INTO "ci_builds_metadata" + 1 # SELECT "taggings".* FROM "taggings" end end end diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb index 285687505e9..68456c1554d 100644 --- a/spec/services/projects/import_export/export_service_spec.rb +++ b/spec/services/projects/import_export/export_service_spec.rb @@ -216,7 +216,7 @@ RSpec.describe Projects::ImportExport::ExportService do it 'fails' do expected_message = "User with ID: %s does not have required permissions for Project: %s with ID: %s" % - [another_user.id, project.name, project.id] + [another_user.id, project.name, project.id] expect { service.execute }.to raise_error(Gitlab::ImportExport::Error).with_message(expected_message) end end diff --git a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb index a28fefcfc58..286f10a186d 100644 --- a/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/database/background_migration_job_shared_examples.rb @@ -28,7 +28,7 @@ RSpec.shared_examples 'finalized background migration' do |worker_class| .new .select do |scheduled| scheduled.klass == worker_class.name && - scheduled.args.first == job_class_name + scheduled.args.first == job_class_name end expect(queued.size).to eq(0) end diff --git a/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb b/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb index e86f1e77447..d6071b20dca 100644 --- a/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb +++ b/spec/support/shared_examples/models/with_debian_distributions_shared_examples.rb @@ -9,9 +9,9 @@ RSpec.shared_examples 'model with Debian distributions' do it 'removes distribution files on removal' do distribution_file_paths = distributions.map do |distribution| [distribution.file.path] + - distribution.component_files.map do |component_file| - component_file.file.path - end + distribution.component_files.map do |component_file| + component_file.file.path + end end.flatten expect { subject.destroy! } |