diff options
Diffstat (limited to 'spec/support/shared_contexts')
7 files changed, 30 insertions, 74 deletions
diff --git a/spec/support/shared_contexts/bulk_imports_requests_shared_context.rb b/spec/support/shared_contexts/bulk_imports_requests_shared_context.rb index 7074b073a0c..997ed448d4d 100644 --- a/spec/support/shared_contexts/bulk_imports_requests_shared_context.rb +++ b/spec/support/shared_contexts/bulk_imports_requests_shared_context.rb @@ -23,7 +23,6 @@ RSpec.shared_context 'bulk imports requests context' do |url| headers: { 'Content-Type' => 'application/json' }) stub_request(:get, "https://gitlab.example.com/api/v4/groups?min_access_level=50&page=1&per_page=20&private_token=demo-pat&search=test&top_level_only=true") - .with(headers: request_headers) .to_return( status: 200, body: [{ diff --git a/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb b/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb index 848e333d88b..e4c97fa1143 100644 --- a/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb +++ b/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb @@ -5,12 +5,14 @@ # The following let binding should be defined: # - `integration`: Integration name. See `Integration.available_integration_names`. RSpec.shared_context 'with integration' do + include Integrations::TestHelpers include JiraIntegrationHelpers let(:dashed_integration) { integration.dasherize } let(:integration_method) { Project.integration_association_name(integration) } let(:integration_klass) { Integration.integration_name_to_model(integration) } let(:integration_instance) { integration_klass.new } + let(:integration_factory) { factory_for(integration_instance) } # Build a list of all attributes that an integration supports. let(:integration_attrs_list) do @@ -44,62 +46,6 @@ RSpec.shared_context 'with integration' do } end - let(:integration_attrs) do - integration_attrs_list.inject({}) do |hash, k| - if k =~ /^(token*|.*_token|.*_key)/ && !integration.in?(%w[apple_app_store google_play]) - hash.merge!(k => 'secrettoken') - elsif integration == 'confluence' && k == :confluence_url - hash.merge!(k => 'https://example.atlassian.net/wiki') - elsif integration == 'datadog' && k == :datadog_site - hash.merge!(k => 'datadoghq.com') - elsif integration == 'datadog' && k == :datadog_tags - hash.merge!(k => 'key:value') - elsif integration == 'packagist' && k == :server - hash.merge!(k => 'https://packagist.example.com') - elsif /^(.*_url|url|webhook)/.match?(k) - hash.merge!(k => "http://example.com") - elsif integration_klass.method_defined?("#{k}?") - hash.merge!(k => true) - elsif integration == 'irker' && k == :recipients - hash.merge!(k => 'irc://irc.network.net:666/#channel') - elsif integration == 'irker' && k == :server_port - hash.merge!(k => 1234) - elsif integration == 'jira' && k == :jira_issue_transition_id - hash.merge!(k => '1,2,3') - elsif integration == 'jira' && k == :jira_issue_transition_automatic # rubocop:disable Lint/DuplicateBranch - hash.merge!(k => true) - elsif integration == 'jira' && k == :jira_auth_type # rubocop:disable Lint/DuplicateBranch - hash.merge!(k => 0) - elsif integration == 'emails_on_push' && k == :recipients - hash.merge!(k => 'foo@bar.com') - elsif (integration == 'slack' || integration == 'mattermost') && k == :labels_to_be_notified_behavior - hash.merge!(k => "match_any") - elsif integration == 'campfire' && k == :room - hash.merge!(k => '1234') - elsif integration == 'apple_app_store' && k == :app_store_issuer_id - hash.merge!(k => 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee') - elsif integration == 'apple_app_store' && k == :app_store_private_key - hash.merge!(k => File.read('spec/fixtures/ssl_key.pem')) - elsif integration == 'apple_app_store' && k == :app_store_key_id - hash.merge!(k => 'ABC1') - elsif integration == 'apple_app_store' && k == :app_store_private_key_file_name - hash.merge!(k => 'ssl_key.pem') - elsif integration == 'apple_app_store' && k == :app_store_protected_refs # rubocop:disable Lint/DuplicateBranch - hash.merge!(k => true) - elsif integration == 'google_play' && k == :package_name - hash.merge!(k => 'com.gitlab.foo.bar') - elsif integration == 'google_play' && k == :service_account_key - hash.merge!(k => File.read('spec/fixtures/service_account.json')) - elsif integration == 'google_play' && k == :service_account_key_file_name - hash.merge!(k => 'service_account.json') - elsif integration == 'google_play' && k == :google_play_protected_refs # rubocop:disable Lint/DuplicateBranch - hash.merge!(k => true) - else - hash.merge!(k => "someword") - end - end - end - let(:licensed_features) do { 'github' => :github_integration @@ -111,15 +57,6 @@ RSpec.shared_context 'with integration' do stub_jira_integration_test if integration == 'jira' end - def initialize_integration(integration, attrs = {}) - record = project.find_or_initialize_integration(integration) - record.reset_updated_properties if integration == 'datadog' - record.attributes = attrs - record.properties = integration_attrs - record.save! - record - end - private def enable_license_for_integration(integration) diff --git a/spec/support/shared_contexts/merge_request_create_shared_context.rb b/spec/support/shared_contexts/merge_request_create_shared_context.rb index bf8eeeb7ab6..fc9a3767365 100644 --- a/spec/support/shared_contexts/merge_request_create_shared_context.rb +++ b/spec/support/shared_contexts/merge_request_create_shared_context.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.shared_context 'merge request create context' do - include ContentEditorHelpers - let(:user) { create(:user) } let(:user2) { create(:user) } let(:target_project) { create(:project, :public, :repository) } @@ -25,7 +23,5 @@ RSpec.shared_context 'merge request create context' do source_branch: 'fix', target_branch: 'master' }) - - close_rich_text_promo_popover_if_present end end diff --git a/spec/support/shared_contexts/merge_request_edit_shared_context.rb b/spec/support/shared_contexts/merge_request_edit_shared_context.rb index 8fe0174b13e..f0e89b0c5f9 100644 --- a/spec/support/shared_contexts/merge_request_edit_shared_context.rb +++ b/spec/support/shared_contexts/merge_request_edit_shared_context.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true RSpec.shared_context 'merge request edit context' do - include ContentEditorHelpers - let(:user) { create(:user) } let(:user2) { create(:user) } let!(:milestone) { create(:milestone, project: target_project) } @@ -27,6 +25,5 @@ RSpec.shared_context 'merge request edit context' do sign_in(user) visit edit_project_merge_request_path(target_project, merge_request) - close_rich_text_promo_popover_if_present end end diff --git a/spec/support/shared_contexts/policies/group_policy_shared_context.rb b/spec/support/shared_contexts/policies/group_policy_shared_context.rb index 70b48322efd..4564fa23236 100644 --- a/spec/support/shared_contexts/policies/group_policy_shared_context.rb +++ b/spec/support/shared_contexts/policies/group_policy_shared_context.rb @@ -19,7 +19,7 @@ RSpec.shared_context 'GroupPolicy context' do let(:guest_permissions) do %i[ - read_label read_group upload_file read_namespace read_group_activity + read_label read_group upload_file read_namespace read_namespace_via_membership read_group_activity read_group_issues read_group_boards read_group_labels read_group_milestones read_group_merge_requests ] diff --git a/spec/support/shared_contexts/policies/project_policy_table_shared_context.rb b/spec/support/shared_contexts/policies/project_policy_table_shared_context.rb index d9ea7bc7f82..11f6d816fc1 100644 --- a/spec/support/shared_contexts/policies/project_policy_table_shared_context.rb +++ b/spec/support/shared_contexts/policies/project_policy_table_shared_context.rb @@ -72,6 +72,31 @@ RSpec.shared_context 'ProjectPolicyTable context' do :private | :disabled | :anonymous | nil | 0 end + # group_level, :membership, :admin_mode, :expected_count + # We need a new table because epics are at a group level only. + def permission_table_for_epics_access + :public | :admin | true | 1 + :public | :admin | false | 1 + :public | :reporter | nil | 1 + :public | :guest | nil | 1 + :public | :non_member | nil | 1 + :public | :anonymous | nil | 1 + + :internal | :admin | true | 1 + :internal | :admin | false | 0 + :internal | :reporter | nil | 0 + :internal | :guest | nil | 0 + :internal | :non_member | nil | 0 + :internal | :anonymous | nil | 0 + + :private | :admin | true | 1 + :private | :admin | false | 0 + :private | :reporter | nil | 0 + :private | :guest | nil | 0 + :private | :non_member | nil | 0 + :private | :anonymous | nil | 0 + end + # project_level, :feature_access_level, :membership, :admin_mode, :expected_count def permission_table_for_guest_feature_access :public | :enabled | :admin | true | 1 diff --git a/spec/support/shared_contexts/requests/api/nuget_packages_shared_context.rb b/spec/support/shared_contexts/requests/api/nuget_packages_shared_context.rb index f877d6299bd..2543195e779 100644 --- a/spec/support/shared_contexts/requests/api/nuget_packages_shared_context.rb +++ b/spec/support/shared_contexts/requests/api/nuget_packages_shared_context.rb @@ -6,5 +6,7 @@ RSpec.shared_context 'nuget api setup' do include HttpBasicAuthHelpers let_it_be(:user) { create(:user) } + let_it_be_with_reload(:project) { create(:project, :public) } let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } + let_it_be_with_reload(:job) { create(:ci_build, user: user, status: :running, project: project) } end |