Commit b4240f4b authored by Rémy Coutable's avatar Rémy Coutable

EE: Organize the shared context and examples

This follows the documented convention.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 0a12d92f
# frozen_string_literal: true
shared_context 'project with approval rules' do
RSpec.shared_context 'project with approval rules' do
let(:approver) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public, :repository) }
......
# frozen_string_literal: true
shared_context 'push rules checks context' do
RSpec.shared_context 'push rules checks context' do
include_context 'change access checks context'
let(:project) { create(:project, :public, :repository, push_rule: push_rule) }
......
# frozen_string_literal: true
shared_examples_for 'a project system note' do
it 'has the project attribute set' do
expect(subject.project).to eq project
end
it_behaves_like 'a system note', exclude_project: true
end
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'group permission check on the controller level' do
RSpec.shared_examples 'group permission check on the controller level' do
context 'when `group_id` is not provided' do
before do
params[:group_id] = nil
......@@ -65,7 +63,7 @@ shared_examples 'group permission check on the controller level' do
end
end
shared_context 'when invalid stage parameters are given' do
RSpec.shared_context 'when invalid stage parameters are given' do
before do
params[:name] = ''
end
......@@ -78,7 +76,7 @@ shared_context 'when invalid stage parameters are given' do
end
end
shared_examples 'cycle analytics data endpoint examples' do
RSpec.shared_examples 'cycle analytics data endpoint examples' do
before do
params[:created_after] = '2019-01-01'
params[:created_before] = '2020-01-01'
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'pushes wip limits to frontend' do
RSpec.shared_examples 'pushes wip limits to frontend' do
let(:plan_license) { :free_plan }
let(:group) { create(:group, plan: plan_license) }
let(:global_license) { create(:license) }
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'cluster metrics' do
RSpec.shared_examples 'cluster metrics' do
include AccessMatchersForController
describe 'GET #metrics' do
......@@ -188,7 +186,7 @@ shared_examples 'cluster metrics' do
end
end
shared_examples_for 'the default dashboard' do
shared_examples 'the default dashboard' do
it 'returns a json object with the correct keys' do
get :metrics_dashboard, params: metrics_params, format: :json
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples DescriptionDiffActions do
RSpec.shared_examples DescriptionDiffActions do
let(:base_params) { { namespace_id: project.namespace, project_id: project, id: issuable } }
describe 'GET description_diff' do
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples ProjectVulnerabilityFindingsActions do
RSpec.shared_examples ProjectVulnerabilityFindingsActions do
include ApiHelpers
include VulnerableHelpers
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples SecurityDashboardsPermissions do
RSpec.shared_examples SecurityDashboardsPermissions do
include ApiHelpers
let(:security_dashboard_user) { create(:user) }
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'multiple issue boards show' do
RSpec.shared_examples 'multiple issue boards show' do
let!(:board1) { create(:board, resource_parent: parent, name: 'b') }
let!(:board2) { create(:board, resource_parent: parent, name: 'a') }
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'returns recently visited boards' do
RSpec.shared_examples 'returns recently visited boards' do
let(:boards) { create_list(:board, 8, resource_parent: parent) }
it 'returns last 4 visited boards' do
......@@ -17,7 +15,7 @@ shared_examples 'returns recently visited boards' do
end
end
shared_examples 'redirects to last visited board' do
RSpec.shared_examples 'redirects to last visited board' do
let(:boards) { create_list(:board, 3, resource_parent: parent) }
before do
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples Security::ApplicationController do
RSpec.shared_examples Security::ApplicationController do
context 'when the user is authenticated' do
let(:security_application_controller_user) { create(:user) }
......
# frozen_string_literal: true
shared_examples 'audit event contains custom message' do
RSpec.shared_examples 'audit event contains custom message' do
let(:custom_message) { "Message_with_spaces" }
let(:details) do
{
......
# frozen_string_literal: true
shared_examples_for 'audit events filter' do
RSpec.shared_examples_for 'audit events filter' do
it 'shows only 2 days old events' do
page.within '.content' do
fill_in 'Created after', with: 4.days.ago
......
# frozen_string_literal: true
shared_examples 'dashboard gold trial callout' do
RSpec.shared_examples 'dashboard gold trial callout' do
before do
sign_in(user)
end
......@@ -58,7 +58,7 @@ shared_examples 'dashboard gold trial callout' do
end
end
shared_examples 'billings gold trial callout' do
RSpec.shared_examples 'billings gold trial callout' do
context 'on a free plan' do
let(:plan) { free_plan }
......
# frozen_string_literal: true
shared_examples "protected branches > access control > EE" do
RSpec.shared_examples "protected branches > access control > EE" do
%w[merge push].each do |git_operation|
# Need to set a default for the `git_operation` access level that _isn't_ being tested
other_git_operation = git_operation == 'merge' ? 'push' : 'merge'
......
# frozen_string_literal: true
shared_examples_for 'a file registry finder' do
RSpec.shared_examples 'a file registry finder' do
it 'responds to file registry finder methods' do
file_registry_finder_methods = %i{
syncable
......
# frozen_string_literal: true
shared_examples_for ::Security::JobsFinder do |default_job_types|
RSpec.shared_examples ::Security::JobsFinder do |default_job_types|
let(:pipeline) { create(:ci_pipeline) }
describe '#new' do
......
......@@ -3,7 +3,7 @@
# To use these shared examples, you may define a value in scope named
# `extra_design_fields`, to pass any extra fields in addition to the
# standard design fields.
shared_examples 'a GraphQL type with design fields' do
RSpec.shared_examples 'a GraphQL type with design fields' do
let(:extra_design_fields) { [] }
it { expect(described_class).to require_graphql_authorizations(:read_design) }
......
# frozen_string_literal: true
shared_examples 'vulnerability location' do
RSpec.shared_examples 'vulnerability location' do
describe '#initialize' do
subject { described_class.new(**params) }
......
# frozen_string_literal: true
shared_examples 'a read-only GitLab instance' do
RSpec.shared_examples 'a read-only GitLab instance' do
it 'denies push access' do
project.add_maintainer(user)
......
# frozen_string_literal: true
shared_examples 'check ignored when push rule unlicensed' do
RSpec.shared_examples 'check ignored when push rule unlicensed' do
before do
stub_licensed_features(push_rules: false)
end
......
# frozen_string_literal: true
shared_examples 'a certificate store' do
RSpec.shared_examples 'a certificate store' do
describe '.store' do
before do
allow(Gitlab.config.smartcard).to receive(:ca_file).and_return('ca_file')
......@@ -40,7 +40,7 @@ shared_examples 'a certificate store' do
end
end
shared_examples 'a valid certificate is required' do
RSpec.shared_examples 'a valid certificate is required' do
context 'invalid certificate' do
it 'returns nil' do
allow(openssl_certificate_store).to receive(:verify).and_return(false)
......
# frozen_string_literal: true
shared_examples 'it should show Gmail Actions View Epic link' do
RSpec.shared_examples 'it should show Gmail Actions View Epic link' do
it_behaves_like 'it should have Gmail Actions links'
it { is_expected.to have_body_text('View Epic') }
end
shared_examples 'an epic email starting a new thread with reply-by-email enabled' do
RSpec.shared_examples 'an epic email starting a new thread with reply-by-email enabled' do
include_examples 'a new thread email with reply-by-email enabled'
context 'when reply-by-email is enabled with incoming address with %{key}' do
......
# frozen_string_literal: true
shared_examples 'no results when the user cannot read cross project' do
RSpec.shared_examples 'no results when the user cannot read cross project' do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project2) { create(:project, :public) }
......
# frozen_string_literal: true
shared_examples 'limited indexing is enabled' do
RSpec.shared_examples 'limited indexing is enabled' do
set(:project) { create :project, :repository, name: 'test1' }
before do
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples_for Vulnerable do
RSpec.shared_examples Vulnerable do
include VulnerableHelpers
let(:external_project) { as_external_vulnerable_project(vulnerable) }
......
# frozen_string_literal: true
shared_examples 'an elasticsearch indexed container' do
RSpec.shared_examples 'an elasticsearch indexed container' do
describe 'validations' do
subject { create container }
......
# frozen_string_literal: true
shared_examples_for 'a Geo registry' do
RSpec.shared_examples 'a Geo registry' do
describe '#start_sync!' do
it 'updates last_synced_at' do
expect { registry.start_sync! }
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples_for 'member validations' do
RSpec.shared_examples 'member validations' do
describe 'validations' do
context 'validates SSO enforcement' do
let(:user) { create(:user) }
......
......@@ -6,7 +6,7 @@
# - let(:backref_text) { "the way that +subject+ should refer to itself in backreferences " }
# - let(:set_mentionable_text) { lambda { |txt| "block that assigns txt to the subject's mentionable_text" } }
shared_context 'mentionable context with EE-specific mentions' do
RSpec.shared_context 'mentionable context with EE-specific mentions' do
let(:group) { create(:group) }
let(:mentioned_epic) { create(:epic, group: group) }
let(:ref_string) do
......@@ -21,7 +21,7 @@ shared_context 'mentionable context with EE-specific mentions' do
end
end
shared_examples 'a mentionable with EE-specific mentions' do
RSpec.shared_examples 'a mentionable with EE-specific mentions' do
include_context 'mentionable context'
include_context 'mentionable context with EE-specific mentions'
......@@ -45,7 +45,7 @@ shared_examples 'a mentionable with EE-specific mentions' do
end
end
shared_examples 'an editable mentionable with EE-specific mentions' do
RSpec.shared_examples 'an editable mentionable with EE-specific mentions' do
include_context 'mentionable context'
include_context 'mentionable context with EE-specific mentions'
......
# frozen_string_literal: true
RSpec.shared_examples 'protected environments access' do |developer_access = true|
using RSpec::Parameterized::TableSyntax
......
# frozen_string_literal: true
shared_examples_for 'assignee board list' do
RSpec.shared_examples 'assignee board list' do
context 'when assignee_id is sent' do
it 'returns 400 if user is not found' do
other_user = create(:user)
......
# frozen_string_literal: true
shared_examples_for 'milestone board list' do
RSpec.shared_examples 'milestone board list' do
context 'when milestone_id is sent' do
it 'returns 400 if milestone is not found' do
other_milestone = create(:milestone)
......
# frozen_string_literal: true
shared_examples_for 'group and project milestone burndowns' do |route_definition|
RSpec.shared_examples 'group and project milestone burndowns' do |route_definition|
let(:resource_route) { "#{route}/#{milestone.id}/burndown_events" }
describe "GET #{route_definition}" do
......
# frozen_string_literal: true
shared_examples_for 'multiple and scoped issue boards' do |route_definition|
RSpec.shared_examples 'multiple and scoped issue boards' do |route_definition|
let(:root_url) { route_definition.gsub(":id", board_parent.id.to_s) }
context 'multiple issue boards' do
......
# frozen_string_literal: true
shared_examples 'rejects nuget packages access' do |user_type, status, add_member = true|
RSpec.shared_examples 'rejects nuget packages access' do |user_type, status, add_member = true|
context "for user type #{user_type}" do
before do
project.send("add_#{user_type}", user) if add_member && user_type != :anonymous
......@@ -18,7 +18,7 @@ shared_examples 'rejects nuget packages access' do |user_type, status, add_membe
end
end
shared_examples 'process nuget service index request' do |user_type, status, add_member = true|
RSpec.shared_examples 'process nuget service index request' do |user_type, status, add_member = true|
context "for user type #{user_type}" do
before do
project.send("add_#{user_type}", user) if add_member && user_type != :anonymous
......@@ -47,7 +47,7 @@ shared_examples 'process nuget service index request' do |user_type, status, add
end
end
shared_examples 'process nuget workhorse authorization' do |user_type, status, add_member = true|
RSpec.shared_examples 'process nuget workhorse authorization' do |user_type, status, add_member = true|
context "for user type #{user_type}" do
before do
project.send("add_#{user_type}", user) if add_member && user_type != :anonymous
......@@ -77,7 +77,7 @@ shared_examples 'process nuget workhorse authorization' do |user_type, status, a
end
end
shared_examples 'process nuget upload' do |user_type, status, add_member = true|
RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member = true|
shared_examples 'creates nuget package files' do
it 'creates package files' do
expect { subject }
......@@ -144,7 +144,7 @@ shared_examples 'process nuget upload' do |user_type, status, add_member = true|
end
end
shared_examples 'rejects nuget access with invalid project id' do
RSpec.shared_examples 'rejects nuget access with invalid project id' do
context 'with a project id with invalid integers' do
using RSpec::Parameterized::TableSyntax
......@@ -166,7 +166,7 @@ shared_examples 'rejects nuget access with invalid project id' do
end
end
shared_examples 'rejects nuget access with unknown project id' do
RSpec.shared_examples 'rejects nuget access with unknown project id' do
context 'with an unknown project' do
let(:project) { OpenStruct.new(id: 1234567890) }
......
# frozen_string_literal: true
shared_examples 'rejects package tags access' do |user_type, status|
RSpec.shared_examples 'rejects package tags access' do |user_type, status|
context "for user type #{user_type}" do
before do
project.send("add_#{user_type}", user) unless user_type == :no_type
......@@ -10,7 +10,7 @@ shared_examples 'rejects package tags access' do |user_type, status|
end
end
shared_examples 'returns package tags' do |user_type|
RSpec.shared_examples 'returns package tags' do |user_type|
using RSpec::Parameterized::TableSyntax
before do
......@@ -48,7 +48,7 @@ shared_examples 'returns package tags' do |user_type|
end
end
shared_examples 'create package tag' do |user_type|
RSpec.shared_examples 'create package tag' do |user_type|
using RSpec::Parameterized::TableSyntax
before do
......@@ -128,7 +128,7 @@ shared_examples 'create package tag' do |user_type|
end
end
shared_examples 'delete package tag' do |user_type|
RSpec.shared_examples 'delete package tag' do |user_type|
using RSpec::Parameterized::TableSyntax
before do
......
# frozen_string_literal: true
shared_examples_for 'an API endpoint for creating project approval rule' do
RSpec.shared_examples 'an API endpoint for creating project approval rule' do
let(:current_user) { user }
let(:params) do
{
......@@ -75,8 +75,8 @@ shared_examples_for 'an API endpoint for creating project approval rule' do
end
end
shared_examples_for 'an API endpoint for updating project approval rule' do
shared_examples_for 'a user with access' do
RSpec.shared_examples 'an API endpoint for updating project approval rule' do
shared_examples 'a user with access' do
before do
project.add_developer(approver)
end
......@@ -154,7 +154,7 @@ shared_examples_for 'an API endpoint for updating project approval rule' do
end
end
shared_examples_for 'an API endpoint for deleting project approval rule' do
RSpec.shared_examples 'an API endpoint for deleting project approval rule' do
it 'destroys' do
delete api(url, user)
......
# frozen_string_literal: true
shared_examples 'forbids access to vulnerability API endpoint in case of disabled features' do
RSpec.shared_examples 'forbids access to vulnerability API endpoint in case of disabled features' do
context 'when "first-class vulnerabilities" feature is disabled' do
before do
stub_feature_flags(first_class_vulnerabilities: false)
......@@ -26,7 +26,7 @@ shared_examples 'forbids access to vulnerability API endpoint in case of disable
end
end
shared_examples 'responds with "not found" for an unknown vulnerability ID' do
RSpec.shared_examples 'responds with "not found" for an unknown vulnerability ID' do
let(:vulnerability_id) { 0 }
it do
......
# frozen_string_literal: true
shared_examples 'returning response status' do |status|
RSpec.shared_examples 'returning response status' do |status|
it "returns #{status}" do
subject
......
# frozen_string_literal: true
require 'spec_helper'
shared_examples 'instance security dashboard JSON endpoint' do
RSpec.shared_examples 'instance security dashboard JSON endpoint' do
context 'when the user is authenticated' do
let(:security_application_controller_user) { create(:user) }
......
# frozen_string_literal: true
shared_examples 'report list' do
RSpec.shared_examples 'report list' do
describe '#as_json' do
let(:entity) do
described_class.represent(items, build: ci_build, request: request)
......
# frozen_string_literal: true
shared_examples 'permission check for cycle analytics stage services' do |required_license|
RSpec.shared_examples 'permission check for cycle analytics stage services' do |required_license|
context 'when user has no access' do
before do
group.add_user(user, :guest)
......
# frozen_string_literal: true
shared_examples_for 'audit event logging' do
RSpec.shared_examples 'audit event logging' do
before do
stub_licensed_features(extended_audit_events: true)
end
......@@ -24,7 +24,7 @@ shared_examples_for 'audit event logging' do
end
end
shared_examples_for 'logs the custom audit event' do
RSpec.shared_examples 'logs the custom audit event' do
let(:logger) { instance_double(Gitlab::AuditJsonLogger) }
before do
......@@ -52,7 +52,7 @@ shared_examples_for 'logs the custom audit event' do
end
end
shared_examples_for 'logs the release audit event' do
RSpec.shared_examples 'logs the release audit event' do
let(:logger) { instance_double(Gitlab::AuditJsonLogger) }
let(:user) { create(:user) }
......
# frozen_string_literal: true
shared_examples 'geo base sync execution' do
RSpec.shared_examples 'geo base sync execution' do
describe '#execute' do
let(:project) { build('project')}
......@@ -32,7 +32,7 @@ shared_examples 'geo base sync execution' do
end
end
shared_examples 'cleans temporary repositories' do
RSpec.shared_examples 'cleans temporary repositories' do
context 'there is a leftover repository' do
let(:temp_repo_path) { "@geo-temporary/#{repository.disk_path}" }
......@@ -50,7 +50,7 @@ shared_examples 'cleans temporary repositories' do
end
end
shared_examples 'geo base sync fetch' do
RSpec.shared_examples 'geo base sync fetch' do
describe '#sync_repository' do
it 'tells registry that sync will start now' do
registry = subject.send(:registry)
......@@ -93,7 +93,7 @@ shared_examples 'geo base sync fetch' do
end
end
shared_examples 'sync retries use the snapshot RPC' do
RSpec.shared_examples 'sync retries use the snapshot RPC' do
context 'snapshot synchronization method' do
before do
allow(subject).to receive(:temp_repo) { repository }
......@@ -139,7 +139,7 @@ shared_examples 'sync retries use the snapshot RPC' do
end
end
shared_examples 'reschedules sync due to race condition instead of waiting for backfill' do
RSpec.shared_examples 'reschedules sync due to race condition instead of waiting for backfill' do
describe '#mark_sync_as_successful' do
let(:mark_sync_as_successful) { subject.send(:mark_sync_as_successful) }
let(:registry) { subject.send(:registry) }
......@@ -155,7 +155,7 @@ shared_examples 'reschedules sync due to race condition instead of waiting for b
end
end
shared_context 'lease handling' do
RSpec.shared_context 'lease handling' do
it 'returns the lease when succeed' do
expect_to_cancel_exclusive_lease(lease_key, lease_uuid)
......
# frozen_string_literal: true
shared_examples 'setting a milestone scope' do
RSpec.shared_examples 'setting a milestone scope' do
before do
stub_licensed_features(scoped_issue_board: true)
end
......
# frozen_string_literal: true
RSpec.shared_examples 'restricts access to protected environments' do |developer_access_when_protected, developer_access_when_unprotected|
context 'when build is related to a protected environment' do
let(:user) { create(:user) }
......
# frozen_string_literal: true
shared_examples_for 'a Geo event store' do |event_class|
RSpec.shared_examples 'a Geo event store' do |event_class|
context 'when running on a secondary node' do
before do
stub_secondary_node
......
# frozen_string_literal: true
shared_examples 'base SamlProvider service' do
RSpec.shared_examples 'base SamlProvider service' do
let(:params) do
{
sso_url: 'https://test',
......@@ -23,7 +23,7 @@ shared_examples 'base SamlProvider service' do
end
end
shared_examples 'SamlProvider service toggles Group Managed Accounts' do
RSpec.shared_examples 'SamlProvider service toggles Group Managed Accounts' do
let(:cleanup_members_service_spy) { spy('GroupSaml::GroupManagedAccounts::CleanUpMembersService') }
before do
......
# frozen_string_literal: true
shared_examples 'merge validation hooks' do |args|
RSpec.shared_examples 'merge validation hooks' do |args|
def hooks_error
service.hooks_validation_error(merge_request)
end
......
# frozen_string_literal: true
shared_examples 'assigns build to package' do
RSpec.shared_examples 'assigns build to package' do
context 'with build info' do
let(:job) { create(:ci_build, user: user) }
let(:params) { super().merge(build: job) }
......@@ -14,7 +14,7 @@ shared_examples 'assigns build to package' do
end
end
shared_examples 'returns packages' do |container_type, user_type|
RSpec.shared_examples 'returns packages' do |container_type, user_type|
context "for #{user_type}" do
before do
send(container_type)&.send("add_#{user_type}", user) unless user_type == :no_type
......@@ -41,7 +41,7 @@ shared_examples 'returns packages' do |container_type, user_type|
end
end
shared_examples 'returns packages with subgroups' do |container_type, user_type|
RSpec.shared_examples 'returns packages with subgroups' do |container_type, user_type|
context "with subgroups for #{user_type}" do
before do
send(container_type)&.send("add_#{user_type}", user) unless user_type == :no_type
......@@ -68,7 +68,7 @@ shared_examples 'returns packages with subgroups' do |container_type, user_type|
end
end
shared_examples 'rejects packages access' do |container_type, user_type, status|
RSpec.shared_examples 'rejects packages access' do |container_type, user_type, status|
context "for #{user_type}" do
before do
send(container_type)&.send("add_#{user_type}", user) unless user_type == :no_type
......@@ -78,7 +78,7 @@ shared_examples 'rejects packages access' do |container_type, user_type, status|
end
end
shared_examples 'returns paginated packages' do
RSpec.shared_examples 'returns paginated packages' do
let(:per_page) { 2 }
context 'when viewing the first page' do
......@@ -102,7 +102,7 @@ shared_examples 'returns paginated packages' do
end
end
shared_examples 'background upload schedules a file migration' do
RSpec.shared_examples 'background upload schedules a file migration' do
context 'background upload enabled' do
before do
stub_package_file_object_storage(background_upload: true)
......
# frozen_string_literal: true
shared_context 'exclusive labels creation' do
RSpec.shared_context 'exclusive labels creation' do
def create_label(title)
if parent.is_a?(Group)
create(:group_label, group: parent, title: title)
......@@ -14,7 +14,7 @@ shared_context 'exclusive labels creation' do
end
end
shared_examples_for 'new issuable with scoped labels' do
RSpec.shared_examples 'new issuable with scoped labels' do
include_context 'exclusive labels creation' do
context 'scoped labels are avaialble' do
before do
......@@ -56,7 +56,7 @@ shared_examples_for 'new issuable with scoped labels' do
end
end
shared_examples_for 'existing issuable with scoped labels' do
RSpec.shared_examples 'existing issuable with scoped labels' do
include_context 'exclusive labels creation' do
let(:label1) { create_label('key::label1') }
let(:label2) { create_label('key::label2') }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment