Commit 9eea3623 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'frozen_string_spec_support' into 'master'

Add frozen_string_literal to spec/support

See merge request gitlab-org/gitlab-ce!31132
parents 32be68af d4ef3be3
...@@ -60,8 +60,7 @@ module Gitlab ...@@ -60,8 +60,7 @@ module Gitlab
def get_info(key) def get_info(key)
value = info[key] value = info[key]
Gitlab::Utils.force_utf8(value) if value value.is_a?(String) ? Gitlab::Utils.force_utf8(value) : value
value
end end
def username_and_email def username_and_email
......
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
end end
def force_utf8(str) def force_utf8(str)
str.force_encoding(Encoding::UTF_8) str.dup.force_encoding(Encoding::UTF_8)
end end
def ensure_utf8_size(str, bytes:) def ensure_utf8_size(str, bytes:)
......
...@@ -13,7 +13,7 @@ describe 'User browses commits' do ...@@ -13,7 +13,7 @@ describe 'User browses commits' do
it 'renders commit' do it 'renders commit' do
visit project_commit_path(project, sample_commit.id) visit project_commit_path(project, sample_commit.id)
expect(page).to have_content(sample_commit.message.gsub!(/\s+/, ' ')) expect(page).to have_content(sample_commit.message.gsub(/\s+/, ' '))
.and have_content("Showing #{sample_commit.files_changed_count} changed files") .and have_content("Showing #{sample_commit.files_changed_count} changed files")
.and have_content('Side-by-side') .and have_content('Side-by-side')
end end
......
...@@ -40,7 +40,11 @@ describe Gitlab::Auth::OAuth::AuthHash do ...@@ -40,7 +40,11 @@ describe Gitlab::Auth::OAuth::AuthHash do
last_name: last_name_ascii, last_name: last_name_ascii,
name: name_ascii, name: name_ascii,
nickname: nickname_ascii, nickname: nickname_ascii,
uid: uid_ascii uid: uid_ascii,
address: {
locality: 'some locality',
country: 'some country'
}
} }
end end
...@@ -51,6 +55,7 @@ describe Gitlab::Auth::OAuth::AuthHash do ...@@ -51,6 +55,7 @@ describe Gitlab::Auth::OAuth::AuthHash do
it { expect(auth_hash.username).to eql nickname_utf8 } it { expect(auth_hash.username).to eql nickname_utf8 }
it { expect(auth_hash.name).to eql name_utf8 } it { expect(auth_hash.name).to eql name_utf8 }
it { expect(auth_hash.password).not_to be_empty } it { expect(auth_hash.password).not_to be_empty }
it { expect(auth_hash.location).to eq 'some locality, some country' }
end end
context 'email not provided' do context 'email not provided' do
......
# frozen_string_literal: true
shared_examples_for 'group and project boards' do |route_definition, ee = false| shared_examples_for 'group and project boards' do |route_definition, ee = false|
let(:root_url) { route_definition.gsub(":id", board_parent.id.to_s) } let(:root_url) { route_definition.gsub(":id", board_parent.id.to_s) }
......
# frozen_string_literal: true
shared_examples 'creating an issue resolving discussions through the API' do shared_examples 'creating an issue resolving discussions through the API' do
it 'creates a new project issue' do it 'creates a new project issue' do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
......
# frozen_string_literal: true
shared_examples 'a 404 response when source is private' do shared_examples 'a 404 response when source is private' do
before do before do
source.update_column(:visibility_level, Gitlab::VisibilityLevel::PRIVATE) source.update_column(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
......
# frozen_string_literal: true
shared_examples_for 'group and project milestones' do |route_definition| shared_examples_for 'group and project milestones' do |route_definition|
let(:resource_route) { "#{route}/#{milestone.id}" } let(:resource_route) { "#{route}/#{milestone.id}" }
let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) } let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
......
# frozen_string_literal: true
shared_context 'disabled repository' do shared_context 'disabled repository' do
before do before do
project.project_feature.update!( project.project_feature.update!(
......
# frozen_string_literal: true
module SchemaPath module SchemaPath
def self.expand(schema, dir = nil) def self.expand(schema, dir = nil)
if Gitlab.ee? && dir.nil? if Gitlab.ee? && dir.nil?
......
# frozen_string_literal: true
shared_examples_for 'allows the "read_user" scope' do |api_version| shared_examples_for 'allows the "read_user" scope' do |api_version|
let(:version) { api_version || 'v4' } let(:version) { api_version || 'v4' }
......
# frozen_string_literal: true
shared_examples 'an unauthorized API user' do shared_examples 'an unauthorized API user' do
it { is_expected.to eq(403) } it { is_expected.to eq(403) }
end end
......
# frozen_string_literal: true
# Specs for reference links containing HTML. # Specs for reference links containing HTML.
# #
# Requires a reference: # Requires a reference:
......
# frozen_string_literal: true
RSpec.configure do |config| RSpec.configure do |config|
config.after do config.after do
BatchLoader::Executor.clear_current BatchLoader::Executor.clear_current
......
# frozen_string_literal: true
# rubocop:disable Style/GlobalVars # rubocop:disable Style/GlobalVars
require 'capybara/rails' require 'capybara/rails'
require 'capybara/rspec' require 'capybara/rspec'
......
# frozen_string_literal: true
CarrierWave.root = File.expand_path('tmp/tests/public', Rails.root) CarrierWave.root = File.expand_path('tmp/tests/public', Rails.root)
RSpec.configure do |config| RSpec.configure do |config|
......
# frozen_string_literal: true
module ChunkedIOHelpers module ChunkedIOHelpers
def sample_trace_raw def sample_trace_raw
@sample_trace_raw ||= File.read(expand_fixture_path('trace/sample_trace')) @sample_trace_raw ||= File.read(expand_fixture_path('trace/sample_trace'))
......
# frozen_string_literal: true
module CommitTrailersSpecHelper module CommitTrailersSpecHelper
extend ActiveSupport::Concern extend ActiveSupport::Concern
......
# frozen_string_literal: true
shared_context 'a GitHub-ish import controller' do shared_context 'a GitHub-ish import controller' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:token) { "asdasd12345" } let(:token) { "asdasd12345" }
......
# frozen_string_literal: true
# Specifications for behavior common to all objects with an email attribute. # Specifications for behavior common to all objects with an email attribute.
# Takes a list of email-format attributes and requires: # Takes a list of email-format attributes and requires:
# - subject { "the object with a attribute= setter" } # - subject { "the object with a attribute= setter" }
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_context 'Ldap::OmniauthCallbacksController' do shared_context 'Ldap::OmniauthCallbacksController' do
......
# frozen_string_literal: true
shared_examples 'authenticates sessionless user' do |path, format, params| shared_examples 'authenticates sessionless user' do |path, format, params|
params ||= {} params ||= {}
......
# frozen_string_literal: true
# rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/AbcSize
# Note: The ABC size is large here because we have a method generating test cases with # Note: The ABC size is large here because we have a method generating test cases with
......
# frozen_string_literal: true
module DbCleaner module DbCleaner
def delete_from_all_tables!(except: nil) def delete_from_all_tables!(except: nil)
DatabaseCleaner.clean_with(:deletion, cache_tables: false, except: except) DatabaseCleaner.clean_with(:deletion, cache_tables: false, except: except)
......
# frozen_string_literal: true
module ExternalAuthorizationServiceHelpers module ExternalAuthorizationServiceHelpers
def enable_external_authorization_service_check def enable_external_authorization_service_check
stub_application_setting(external_authorization_service_enabled: true) stub_application_setting(external_authorization_service_enabled: true)
......
# frozen_string_literal: true
shared_examples 'thread comments' do |resource_name| shared_examples 'thread comments' do |resource_name|
let(:form_selector) { '.js-main-target-form' } let(:form_selector) { '.js-main-target-form' }
let(:dropdown_selector) { "#{form_selector} .comment-type-dropdown" } let(:dropdown_selector) { "#{form_selector} .comment-type-dropdown" }
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples 'reportable note' do |type| shared_examples 'reportable note' do |type|
......
# frozen_string_literal: true
shared_examples 'creating an issue for a thread' do shared_examples 'creating an issue for a thread' do
it 'shows an issue with the title filled in' do it 'shows an issue with the title filled in' do
title_field = page.find_field('issue[title]') title_field = page.find_field('issue[title]')
......
# frozen_string_literal: true
shared_examples "an autodiscoverable RSS feed with current_user's feed token" do shared_examples "an autodiscoverable RSS feed with current_user's feed token" do
it "has an RSS autodiscovery link tag with current_user's feed token" do it "has an RSS autodiscovery link tag with current_user's feed token" do
expect(page).to have_css("link[type*='atom+xml'][href*='feed_token=#{user.feed_token}']", visible: false) expect(page).to have_css("link[type*='atom+xml'][href*='feed_token=#{user.feed_token}']", visible: false)
......
# frozen_string_literal: true
shared_examples 'variable list' do shared_examples 'variable list' do
it 'shows list of variables' do it 'shows list of variables' do
page.within('.js-ci-variable-list-section') do page.within('.js-ci-variable-list-section') do
......
# frozen_string_literal: true
module ForgeryProtection module ForgeryProtection
def with_forgery_protection def with_forgery_protection
ActionController::Base.allow_forgery_protection = true ActionController::Base.allow_forgery_protection = true
......
# frozen_string_literal: true
module GoogleApi module GoogleApi
module CloudPlatformHelpers module CloudPlatformHelpers
def stub_google_api_validate_token def stub_google_api_validate_token
......
# frozen_string_literal: true
module ApiHelpers module ApiHelpers
# Public: Prepend a request path with the path to the API # Public: Prepend a request path with the path to the API
# #
...@@ -30,11 +32,12 @@ module ApiHelpers ...@@ -30,11 +32,12 @@ module ApiHelpers
end end
if query_string if query_string
full_path << (path.index('?') ? '&' : '?') separator = path.index('?') ? '&' : '?'
full_path << query_string
end
full_path full_path + separator + query_string
else
full_path
end
end end
def expect_paginated_array_response(items) def expect_paginated_array_response(items)
......
# frozen_string_literal: true
module AssetsHelpers module AssetsHelpers
# In a CI environment the assets are not compiled, as there is a CI job # In a CI environment the assets are not compiled, as there is a CI job
# `compile-assets` that compiles them in the prepare stage for all following # `compile-assets` that compiles them in the prepare stage for all following
......
# frozen_string_literal: true
require 'zlib' require 'zlib'
class BareRepoOperations class BareRepoOperations
......
# frozen_string_literal: true
module BoardHelpers module BoardHelpers
def click_card(card) def click_card(card)
within card do within card do
......
# frozen_string_literal: true
module CapybaraHelpers module CapybaraHelpers
# Execute a block a certain number of times before considering it a failure # Execute a block a certain number of times before considering it a failure
# #
......
# frozen_string_literal: true
# frozen_sting_literal: true # frozen_sting_literal: true
# This generates fake CI metadata .gz for testing # This generates fake CI metadata .gz for testing
......
# frozen_string_literal: true
# Helper for setting cookies in Selenium/WebDriver # Helper for setting cookies in Selenium/WebDriver
# #
module CookieHelper module CookieHelper
......
# frozen_string_literal: true
module CycleAnalyticsHelpers module CycleAnalyticsHelpers
include GitHelpers include GitHelpers
......
# frozen_string_literal: true
module DatabaseConnectionHelpers module DatabaseConnectionHelpers
def run_with_new_database_connection def run_with_new_database_connection
pool = ActiveRecord::Base.connection_pool pool = ActiveRecord::Base.connection_pool
......
# frozen_string_literal: true
module DeviseHelpers module DeviseHelpers
# explicitly tells Devise which mapping to use # explicitly tells Devise which mapping to use
# this is needed when we are testing a Devise controller bypassing the router # this is needed when we are testing a Devise controller bypassing the router
......
# frozen_string_literal: true
module DragTo module DragTo
def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body', duration: 1000) def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body', duration: 1000)
evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), duration: #{duration}, from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});") evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), duration: #{duration}, from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});")
......
# frozen_string_literal: true
module DropzoneHelper module DropzoneHelper
# Provides a way to perform `attach_file` for a Dropzone-based file input # Provides a way to perform `attach_file` for a Dropzone-based file input
# #
......
# frozen_string_literal: true
module EmailHelpers module EmailHelpers
def sent_to_user(user, recipients: email_recipients) def sent_to_user(user, recipients: email_recipients)
recipients.count { |to| to == user.notification_email } recipients.count { |to| to == user.notification_email }
......
# frozen_string_literal: true
module ExclusiveLeaseHelpers module ExclusiveLeaseHelpers
def stub_exclusive_lease(key = nil, uuid = 'uuid', renew: false, timeout: nil) def stub_exclusive_lease(key = nil, uuid = 'uuid', renew: false, timeout: nil)
key ||= instance_of(String) key ||= instance_of(String)
......
# frozen_string_literal: true
module ExpectNextInstanceOf module ExpectNextInstanceOf
def expect_next_instance_of(klass, *new_args) def expect_next_instance_of(klass, *new_args)
receive_new = receive(:new) receive_new = receive(:new)
......
# frozen_string_literal: true
require 'rubocop/rspec/support' require 'rubocop/rspec/support'
# https://github.com/backus/rubocop-rspec/blob/master/spec/support/expect_offense.rb # https://github.com/backus/rubocop-rspec/blob/master/spec/support/expect_offense.rb
......
# frozen_string_literal: true
module FakeBlobHelpers module FakeBlobHelpers
class FakeBlob class FakeBlob
include BlobLike include BlobLike
......
# frozen_string_literal: true
class FakeRenameReservedPathMigrationV1 < ActiveRecord::Migration[4.2] class FakeRenameReservedPathMigrationV1 < ActiveRecord::Migration[4.2]
include Gitlab::Database::RenameReservedPathsMigration::V1 include Gitlab::Database::RenameReservedPathsMigration::V1
......
# frozen_string_literal: true
class FakeU2fDevice class FakeU2fDevice
attr_reader :name attr_reader :name
......
# frozen_string_literal: true
# These helpers allow you to manipulate with sorting features. # These helpers allow you to manipulate with sorting features.
# #
# Usage: # Usage:
......
# frozen_string_literal: true
# These helpers allow you to manipulate with notes. # These helpers allow you to manipulate with notes.
# #
# Usage: # Usage:
......
# frozen_string_literal: true
# These helpers allow you to manipulate with sorting features. # These helpers allow you to manipulate with sorting features.
# #
# Usage: # Usage:
......
# frozen_string_literal: true
# Helper methods for Banzai filter specs # Helper methods for Banzai filter specs
# #
# Must be included into specs manually # Must be included into specs manually
......
# frozen_string_literal: true
module FilteredSearchHelpers module FilteredSearchHelpers
def filtered_search def filtered_search
page.find('.filtered-search') page.find('.filtered-search')
......
# frozen_string_literal: true
module FixtureHelpers module FixtureHelpers
def fixture_file(filename, dir: '') def fixture_file(filename, dir: '')
return '' if filename.blank? return '' if filename.blank?
......
# frozen_string_literal: true
require_relative 'workhorse_helpers' require_relative 'workhorse_helpers'
module GitHttpHelpers module GitHttpHelpers
......
# frozen_string_literal: true
module GitlabVerifyHelpers module GitlabVerifyHelpers
def collect_ranges(args = {}) def collect_ranges(args = {})
verifier = described_class.new(args.merge(batch_size: 1)) verifier = described_class.new(args.merge(batch_size: 1))
......
# frozen_string_literal: true
module GraphqlHelpers module GraphqlHelpers
MutationDefinition = Struct.new(:query, :variables) MutationDefinition = Struct.new(:query, :variables)
......
# frozen_string_literal: true
require 'ostruct' require 'ostruct'
# Helper methods for controller specs in the Import namespace # Helper methods for controller specs in the Import namespace
......
# frozen_string_literal: true
# see app/assets/javascripts/test_utils/simulate_input.js # see app/assets/javascripts/test_utils/simulate_input.js
module InputHelper module InputHelper
......
# frozen_string_literal: true
require_relative './wait_for_requests' require_relative './wait_for_requests'
module InspectRequests module InspectRequests
......
# frozen_string_literal: true
module IssueHelpers module IssueHelpers
def visit_issues(project, opts = {}) def visit_issues(project, opts = {})
visit project_issues_path project, opts visit project_issues_path project, opts
......
# frozen_string_literal: true
require 'action_dispatch/testing/test_request' require 'action_dispatch/testing/test_request'
require 'fileutils' require 'fileutils'
......
# frozen_string_literal: true
module JiraServiceHelper module JiraServiceHelper
JIRA_URL = "http://jira.example.net".freeze JIRA_URL = "http://jira.example.net".freeze
JIRA_API = JIRA_URL + "/rest/api/2" JIRA_API = JIRA_URL + "/rest/api/2"
......
# frozen_string_literal: true
module Spec module Spec
module Support module Support
module Helpers module Helpers
......
# frozen_string_literal: true
module KubernetesHelpers module KubernetesHelpers
include Gitlab::Kubernetes include Gitlab::Kubernetes
......
# frozen_string_literal: true
module LdapHelpers module LdapHelpers
def ldap_adapter(provider = 'ldapmain', ldap = double(:ldap)) def ldap_adapter(provider = 'ldapmain', ldap = double(:ldap))
::Gitlab::Auth::LDAP::Adapter.new(provider, ldap) ::Gitlab::Auth::LDAP::Adapter.new(provider, ldap)
......
# frozen_string_literal: true
require 'io/console' require 'io/console'
module LiveDebugger module LiveDebugger
......
# frozen_string_literal: true
require_relative 'devise_helpers' require_relative 'devise_helpers'
module LoginHelpers module LoginHelpers
......
# frozen_string_literal: true
# This is a helper class used by the GitLab Markdown feature spec # This is a helper class used by the GitLab Markdown feature spec
# #
# Because the feature spec only cares about the output of the Markdown, and the # Because the feature spec only cares about the output of the Markdown, and the
......
# frozen_string_literal: true
module MergeRequestDiffHelpers module MergeRequestDiffHelpers
def click_diff_line(line_holder, diff_side = nil) def click_diff_line(line_holder, diff_side = nil)
line = get_line_components(line_holder, diff_side) line = get_line_components(line_holder, diff_side)
......
# frozen_string_literal: true
module MergeRequestHelpers module MergeRequestHelpers
def visit_merge_requests(project, opts = {}) def visit_merge_requests(project, opts = {})
visit project_merge_requests_path project, opts visit project_merge_requests_path project, opts
......
# frozen_string_literal: true
module MigrationsHelpers module MigrationsHelpers
def active_record_base def active_record_base
ActiveRecord::Base ActiveRecord::Base
......
# frozen_string_literal: true
module MobileHelpers module MobileHelpers
def resize_screen_xs def resize_screen_xs
resize_window(575, 768) resize_window(575, 768)
......
# frozen_string_literal: true
module NoteInteractionHelpers module NoteInteractionHelpers
def open_more_actions_dropdown(note) def open_more_actions_dropdown(note)
note_element = find("#note_#{note.id}") note_element = find("#note_#{note.id}")
......
# frozen_string_literal: true
module NotificationHelpers module NotificationHelpers
extend self extend self
......
# frozen_string_literal: true
module ProjectForksHelper module ProjectForksHelper
def fork_project(project, user = nil, params = {}) def fork_project(project, user = nil, params = {})
Gitlab::GitalyClient.allow_n_plus_1_calls do Gitlab::GitalyClient.allow_n_plus_1_calls do
......
# frozen_string_literal: true
module PrometheusHelpers module PrometheusHelpers
def prometheus_memory_query(environment_slug) def prometheus_memory_query(environment_slug)
%{avg(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}) / 2^20} %{avg(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}) / 2^20}
......
# frozen_string_literal: true
module ActiveRecord module ActiveRecord
class QueryRecorder class QueryRecorder
attr_reader :log, :skip_cached, :cached attr_reader :log, :skip_cached, :cached
......
# frozen_string_literal: true
module QuickActionsHelpers module QuickActionsHelpers
def write_note(text) def write_note(text)
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
......
# frozen_string_literal: true
module RakeHelpers module RakeHelpers
def run_rake_task(task_name, *args) def run_rake_task(task_name, *args)
Rake::Task[task_name].reenable Rake::Task[task_name].reenable
......
# frozen_string_literal: true
module ReactiveCachingHelpers module ReactiveCachingHelpers
def reactive_cache_key(subject, *qualifiers) def reactive_cache_key(subject, *qualifiers)
([subject.class.reactive_cache_key.call(subject)].flatten + qualifiers).join(':') ([subject.class.reactive_cache_key.call(subject)].flatten + qualifiers).join(':')
......
# frozen_string_literal: true
class Redis class Redis
ForbiddenCommand = Class.new(StandardError) ForbiddenCommand = Class.new(StandardError)
......
# frozen_string_literal: true
module ReferenceParserHelpers module ReferenceParserHelpers
def empty_html_link def empty_html_link
Nokogiri::HTML.fragment('<a></a>').children[0] Nokogiri::HTML.fragment('<a></a>').children[0]
......
# frozen_string_literal: true
module RepoHelpers module RepoHelpers
extend self extend self
......
# frozen_string_literal: true
module RoutesHelpers module RoutesHelpers
def fake_routes(&block) def fake_routes(&block)
@routes = @routes.dup @routes = @routes.dup
......
# frozen_string_literal: true
module SearchHelpers module SearchHelpers
def select_filter(name) def select_filter(name)
find(:xpath, "//ul[contains(@class, 'search-filter')]//a[contains(.,'#{name}')]").click find(:xpath, "//ul[contains(@class, 'search-filter')]//a[contains(.,'#{name}')]").click
......
# frozen_string_literal: true
# This file is generated by generate-seed-repo-rb. Do not edit this file manually. # This file is generated by generate-seed-repo-rb. Do not edit this file manually.
# #
# Seed repo: # Seed repo:
......
# frozen_string_literal: true
require_relative 'wait_for_requests' require_relative 'wait_for_requests'
# Select2 ajax programmatic helper # Select2 ajax programmatic helper
......
# frozen_string_literal: true
module SelectionHelper module SelectionHelper
def select_element(selector) def select_element(selector)
find(selector) find(selector)
......
# frozen_string_literal: true
# Helper allows you to sort items # Helper allows you to sort items
# #
# Params # Params
......
# frozen_string_literal: true
require 'active_support/core_ext/hash/transform_values' require 'active_support/core_ext/hash/transform_values'
require 'active_support/hash_with_indifferent_access' require 'active_support/hash_with_indifferent_access'
require 'active_support/dependencies' require 'active_support/dependencies'
......
# frozen_string_literal: true
# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb # Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
module StubENV module StubENV
def stub_env(key_or_hash, value = nil) def stub_env(key_or_hash, value = nil)
......
# frozen_string_literal: true
module StubFeatureFlags module StubFeatureFlags
# Stub Feature flags with `flag_name: true/false` # Stub Feature flags with `flag_name: true/false`
# #
......
# frozen_string_literal: true
module StubGitlabCalls module StubGitlabCalls
def stub_gitlab_calls def stub_gitlab_calls
stub_user stub_user
......
# frozen_string_literal: true
module StubGitlabData module StubGitlabData
def gitlab_ci_yaml def gitlab_ci_yaml
File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
......
# frozen_string_literal: true
module StubMetrics module StubMetrics
def authentication_metrics def authentication_metrics
Gitlab::Auth::Activity Gitlab::Auth::Activity
......
# frozen_string_literal: true
module StubObjectStorage module StubObjectStorage
def stub_object_storage_uploader( def stub_object_storage_uploader(
config:, config:,
......
# frozen_string_literal: true
module StubRequests module StubRequests
IP_ADDRESS_STUB = '8.8.8.9'.freeze IP_ADDRESS_STUB = '8.8.8.9'.freeze
......
# frozen_string_literal: true
# Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb # Inspired by https://github.com/ljkbennett/stub_env/blob/master/lib/stub_env/helpers.rb
module StubWorker module StubWorker
def stub_worker(queue:) def stub_worker(queue:)
......
# frozen_string_literal: true
module TermsHelper module TermsHelper
def enforce_terms def enforce_terms
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
......
# frozen_string_literal: true
require 'rspec/mocks' require 'rspec/mocks'
require 'toml-rb' require 'toml-rb'
......
# frozen_string_literal: true
require 'fileutils' require 'fileutils'
module UploadHelpers module UploadHelpers
......
# frozen_string_literal: true
module WaitForRequests module WaitForRequests
extend self extend self
......
# frozen_string_literal: true
module WaitHelpers module WaitHelpers
extend self extend self
......
# frozen_string_literal: true
module WikiHelpers module WikiHelpers
extend self extend self
......
# frozen_string_literal: true
module WorkhorseHelpers module WorkhorseHelpers
extend self extend self
......
# frozen_string_literal: true
module HttpIOHelpers module HttpIOHelpers
def stub_remote_url_206(url, file_path) def stub_remote_url_206(url, file_path)
WebMock.stub_request(:get, url) WebMock.stub_request(:get, url)
......
# frozen_string_literal: true
module ImportExport module ImportExport
module CommonUtil module CommonUtil
def setup_symlink(tmpdir, symlink_name) def setup_symlink(tmpdir, symlink_name)
......
# frozen_string_literal: true
module ConfigurationHelper module ConfigurationHelper
# Returns a list of models from hashes/arrays contained in +project_tree+ # Returns a list of models from hashes/arrays contained in +project_tree+
def names_from_tree(project_tree) def names_from_tree(project_tree)
......
# frozen_string_literal: true
require './spec/support/import_export/configuration_helper' require './spec/support/import_export/configuration_helper'
module ExportFileHelper module ExportFileHelper
......
# frozen_string_literal: true
# This class can generate a lot of output if it fails, # This class can generate a lot of output if it fails,
# so squelch the instance variable output. # so squelch the instance variable output.
class ActiveSupport::Cache::NullStore class ActiveSupport::Cache::NullStore
......
# frozen_string_literal: true
shared_examples 'issuables requiring filter' do |action| shared_examples 'issuables requiring filter' do |action|
it "doesn't load any issuables if no filter is set" do it "doesn't load any issuables if no filter is set" do
expect_any_instance_of(described_class).not_to receive(:issuables_collection) expect_any_instance_of(described_class).not_to receive(:issuables_collection)
......
# frozen_string_literal: true
RSpec.configure do |config| RSpec.configure do |config|
config.include_context 'JSON response', type: :controller config.include_context 'JSON response', type: :controller
config.include_context 'JSON response', type: :request config.include_context 'JSON response', type: :request
......
# frozen_string_literal: true
RSpec::Matchers.define :abort_execution do RSpec::Matchers.define :abort_execution do
match do |code_block| match do |code_block|
@captured_stderr = StringIO.new @captured_stderr = StringIO.new
......
# frozen_string_literal: true
# AccessMatchers # AccessMatchers
# #
# The custom matchers contained in this module are used to test a user's access # The custom matchers contained in this module are used to test a user's access
......
# frozen_string_literal: true
# AccessMatchersForController # AccessMatchersForController
# #
# For testing authorize_xxx in controller. # For testing authorize_xxx in controller.
......
# frozen_string_literal: true
RSpec::Matchers.define :be_scheduled_delayed_migration do |delay, *expected| RSpec::Matchers.define :be_scheduled_delayed_migration do |delay, *expected|
match do |migration| match do |migration|
BackgroundMigrationWorker.jobs.any? do |job| BackgroundMigrationWorker.jobs.any? do |job|
......
# frozen_string_literal: true
RSpec::Matchers.define :be_a_binary_string do |_| RSpec::Matchers.define :be_a_binary_string do |_|
match do |actual| match do |actual|
actual.is_a?(String) && actual.encoding == Encoding.find('ASCII-8BIT') actual.is_a?(String) && actual.encoding == Encoding.find('ASCII-8BIT')
......
# frozen_string_literal: true
RSpec::Matchers.define :be_like_time do |expected| RSpec::Matchers.define :be_like_time do |expected|
match do |actual| match do |actual|
expect(actual).to be_within(1.second).of(expected) expect(actual).to be_within(1.second).of(expected)
......
# frozen_string_literal: true
RSpec::Matchers.define :be_url do |_| RSpec::Matchers.define :be_url do |_|
match do |actual| match do |actual|
URI.parse(actual) rescue false URI.parse(actual) rescue false
......
# frozen_string_literal: true
RSpec::Matchers.define :be_utf8 do |_| RSpec::Matchers.define :be_utf8 do |_|
match do |actual| match do |actual|
actual.is_a?(String) && actual.encoding == Encoding.find('UTF-8') actual.is_a?(String) && actual.encoding == Encoding.find('UTF-8')
......
# frozen_string_literal: true
RSpec::Matchers.define :be_valid_commit do RSpec::Matchers.define :be_valid_commit do
match do |actual| match do |actual|
actual && actual &&
......
# frozen_string_literal: true
RSpec::Matchers.define :disallow_request do RSpec::Matchers.define :disallow_request do
match do |middleware| match do |middleware|
alert = middleware.env['rack.session'].to_hash alert = middleware.env['rack.session'].to_hash
......
# frozen_string_literal: true
module ExceedQueryLimitHelpers module ExceedQueryLimitHelpers
def with_threshold(threshold) def with_threshold(threshold)
@threshold = threshold @threshold = threshold
......
# frozen_string_literal: true
RSpec::Matchers.define :execute_check do |expected| RSpec::Matchers.define :execute_check do |expected|
match do |actual| match do |actual|
expect(actual).to eq(SystemCheck) expect(actual).to eq(SystemCheck)
......
# frozen_string_literal: true
RSpec::Matchers.define :gitaly_request_with_path do |storage_name, relative_path| RSpec::Matchers.define :gitaly_request_with_path do |storage_name, relative_path|
match do |actual| match do |actual|
repository = actual.repository repository = actual.repository
......
# frozen_string_literal: true
RSpec::Matchers.define :gitlab_git_repository_with do |values| RSpec::Matchers.define :gitlab_git_repository_with do |values|
match do |actual| match do |actual|
actual.is_a?(Gitlab::Git::Repository) && actual.is_a?(Gitlab::Git::Repository) &&
......
# frozen_string_literal: true
RSpec::Matchers.define :require_graphql_authorizations do |*expected| RSpec::Matchers.define :require_graphql_authorizations do |*expected|
match do |field| match do |field|
expect(field.metadata[:authorize]).to eq(*expected) expect(field.metadata[:authorize]).to eq(*expected)
......
# frozen_string_literal: true
RSpec::Matchers.define :have_emoji do |emoji_name| RSpec::Matchers.define :have_emoji do |emoji_name|
match do |actual| match do |actual|
expect(actual).to have_selector("gl-emoji[data-name='#{emoji_name}']") expect(actual).to have_selector("gl-emoji[data-name='#{emoji_name}']")
......
# frozen_string_literal: true
RSpec::Matchers.define :have_gitlab_http_status do |expected| RSpec::Matchers.define :have_gitlab_http_status do |expected|
match do |actual| match do |actual|
expect(actual).to have_http_status(expected) expect(actual).to have_http_status(expected)
......
# frozen_string_literal: true
RSpec::Matchers.define :have_issuable_counts do |opts| RSpec::Matchers.define :have_issuable_counts do |opts|
expected_counts = opts.map do |state, count| expected_counts = opts.map do |state, count|
"#{state.to_s.humanize} #{count}" "#{state.to_s.humanize} #{count}"
......
# frozen_string_literal: true
RSpec::Matchers.define :include_module do |expected| RSpec::Matchers.define :include_module do |expected|
match do match do
described_class.included_modules.include?(expected) described_class.included_modules.include?(expected)
......
# frozen_string_literal: true
RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".md"| RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".md"|
match do |actual| match do |actual|
node = find("#{parent} h#{level} a#user-content-#{id}") node = find("#{parent} h#{level} a#user-content-#{id}")
......
# frozen_string_literal: true
# MarkdownMatchers # MarkdownMatchers
# #
# Custom matchers for our custom HTML::Pipeline filters. These are used to test # Custom matchers for our custom HTML::Pipeline filters. These are used to test
......
# frozen_string_literal: true
RSpec::Matchers.define :match_file do |expected| RSpec::Matchers.define :match_file do |expected|
match do |actual| match do |actual|
expect(Digest::MD5.hexdigest(actual)).to eq(Digest::MD5.hexdigest(File.read(expected))) expect(Digest::MD5.hexdigest(actual)).to eq(Digest::MD5.hexdigest(File.read(expected)))
......
# frozen_string_literal: true
RSpec::Matchers.define :match_ids do |*expected| RSpec::Matchers.define :match_ids do |*expected|
match do |actual| match do |actual|
actual_ids = map_ids(actual) actual_ids = map_ids(actual)
......
# frozen_string_literal: true
RSpec::Matchers.define :increment do |counter| RSpec::Matchers.define :increment do |counter|
match do |adapter| match do |adapter|
expect(adapter.send(counter)) expect(adapter.send(counter))
......
# frozen_string_literal: true
RSpec::Matchers.define :have_active_navigation do |expected| RSpec::Matchers.define :have_active_navigation do |expected|
match do |page| match do |page|
expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
......
# frozen_string_literal: true
RSpec::Matchers.define :include_pagination_headers do |expected| RSpec::Matchers.define :include_pagination_headers do |expected|
match do |actual| match do |actual|
expect(actual.headers).to include('X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page', 'Link') expect(actual.headers).to include('X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page', 'Link')
......
# frozen_string_literal: true
RSpec::Matchers.define :make_queries_matching do |matcher, expected_count = nil| RSpec::Matchers.define :make_queries_matching do |matcher, expected_count = nil|
supports_block_expectations supports_block_expectations
......
# frozen_string_literal: true
# These matchers are a syntactic hack to provide more readable expectations for # These matchers are a syntactic hack to provide more readable expectations for
# an Enumerable object. # an Enumerable object.
# #
......
# frozen_string_literal: true
RSpec::Matchers.define :include_security_headers do |expected| RSpec::Matchers.define :include_security_headers do |expected|
match do |actual| match do |actual|
expect(actual.headers).to include('X-Content-Type-Options') expect(actual.headers).to include('X-Content-Type-Options')
......
# frozen_string_literal: true
module MigrationsHelpers module MigrationsHelpers
module TrackUntrackedUploadsHelpers module TrackUntrackedUploadsHelpers
PUBLIC_DIR = File.join(Rails.root, 'tmp', 'tests', 'public') PUBLIC_DIR = File.join(Rails.root, 'tmp', 'tests', 'public')
......
# frozen_string_literal: true
OmniAuth.config.test_mode = true OmniAuth.config.test_mode = true
# frozen_string_literal: true
RSpec.shared_examples 'additional metrics query' do RSpec.shared_examples 'additional metrics query' do
include Prometheus::MetricBuilders include Prometheus::MetricBuilders
......
# frozen_string_literal: true
module Prometheus module Prometheus
module MetricBuilders module MetricBuilders
def simple_query(suffix = 'a', **opts) def simple_query(suffix = 'a', **opts)
......
# frozen_string_literal: true
RSpec.shared_examples "protected tags > access control > CE" do RSpec.shared_examples "protected tags > access control > CE" do
ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)| ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)|
it "allows creating protected tags that #{access_type_name} can create" do it "allows creating protected tags that #{access_type_name} can create" do
......
# frozen_string_literal: true
module RedisHelpers module RedisHelpers
# config/README.md # config/README.md
......
# frozen_string_literal: true
RSpec.shared_examples "redis_shared_examples" do RSpec.shared_examples "redis_shared_examples" do
include StubENV include StubENV
......
# frozen_string_literal: true
require_relative "helpers/stub_configuration" require_relative "helpers/stub_configuration"
require_relative "helpers/stub_metrics" require_relative "helpers/stub_metrics"
require_relative "helpers/stub_object_storage" require_relative "helpers/stub_object_storage"
......
# frozen_string_literal: true
RSpec.configure do |config| RSpec.configure do |config|
config.include SeedHelper, :seed_helper config.include SeedHelper, :seed_helper
......
# frozen_string_literal: true
shared_context 'valid cluster create params' do shared_context 'valid cluster create params' do
let(:params) do let(:params) do
{ {
......
# frozen_string_literal: true
# Specifications for behavior common to all objects with executable attributes. # Specifications for behavior common to all objects with executable attributes.
# It can take a `default_params`. # It can take a `default_params`.
......
# frozen_string_literal: true
shared_examples 'issuable update service' do shared_examples 'issuable update service' do
def update_issuable(opts) def update_issuable(opts)
described_class.new(project, user, opts).execute(open_issuable) described_class.new(project, user, opts).execute(open_issuable)
......
# frozen_string_literal: true
require "spec_helper" require "spec_helper"
shared_examples "migrating a deleted user's associated records to the ghost user" do |record_class, fields| shared_examples "migrating a deleted user's associated records to the ghost user" do |record_class, fields|
......
# frozen_string_literal: true
RSpec.configure do |config| RSpec.configure do |config|
def builds_path def builds_path
Rails.root.join('tmp/tests/builds') Rails.root.join('tmp/tests/builds')
......
# frozen_string_literal: true
shared_context :email_shared_context do shared_context :email_shared_context do
let(:mail_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" } let(:mail_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" }
let(:receiver) { Gitlab::Email::Receiver.new(email_raw) } let(:receiver) { Gitlab::Email::Receiver.new(email_raw) }
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
RSpec.shared_context 'GroupProjectsFinder context' do RSpec.shared_context 'GroupProjectsFinder context' do
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
RSpec.shared_context 'IssuesFinder context' do RSpec.shared_context 'IssuesFinder context' do
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests context' do RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests context' do
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
RSpec.shared_context 'UsersFinder#execute filter by project context' do RSpec.shared_context 'UsersFinder#execute filter by project context' do
......
# frozen_string_literal: true
shared_context 'JSON response' do shared_context 'JSON response' do
let(:json_response) { JSON.parse(response.body) } let(:json_response) { JSON.parse(response.body) }
end end
# frozen_string_literal: true
shared_context 'merge request allowing collaboration' do shared_context 'merge request allowing collaboration' do
include ProjectForksHelper include ProjectForksHelper
......
# frozen_string_literal: true
Service.available_services_names.each do |service| Service.available_services_names.each do |service|
shared_context service do shared_context service do
let(:dashed_service) { service.dasherize } let(:dashed_service) { service.dasherize }
......
# frozen_string_literal: true
shared_context 'invalid urls' do shared_context 'invalid urls' do
let(:urls_with_CRLF) do let(:urls_with_CRLF) do
["http://127.0.0.1:333/pa\rth", ["http://127.0.0.1:333/pa\rth",
......
# frozen_string_literal: true
RSpec.shared_examples 'chat slash commands service' do RSpec.shared_examples 'chat slash commands service' do
describe "Associations" do describe "Associations" do
it { is_expected.to respond_to :token } it { is_expected.to respond_to :token }
......
# frozen_string_literal: true
shared_examples_for 'common trace features' do shared_examples_for 'common trace features' do
describe '#html' do describe '#html' do
before do before do
......
# frozen_string_literal: true
shared_examples 'system note creation' do |update_params, note_text| shared_examples 'system note creation' do |update_params, note_text|
subject { described_class.new(project, user).execute(issuable, old_labels: []) } subject { described_class.new(project, user).execute(issuable, old_labels: []) }
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples 'disabled when using an external authorization service' do shared_examples 'disabled when using an external authorization service' do
......
# frozen_string_literal: true
shared_examples 'issuable notes filter' do shared_examples 'issuable notes filter' do
let(:params) do let(:params) do
if issuable_parent.is_a?(Project) if issuable_parent.is_a?(Project)
......
# frozen_string_literal: true
shared_examples 'set sort order from user preference' do shared_examples 'set sort order from user preference' do
describe '#set_sort_order_from_user_preference' do describe '#set_sort_order_from_user_preference' do
# There is no issuable_sorting_field defined in any CE controllers yet, # There is no issuable_sorting_field defined in any CE controllers yet,
......
# frozen_string_literal: true
shared_examples 'todos actions' do shared_examples 'todos actions' do
context 'when authorized' do context 'when authorized' do
before do before do
......
# frozen_string_literal: true
shared_examples 'handle uploads' do shared_examples 'handle uploads' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') } let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
......
# frozen_string_literal: true
shared_examples 'GET #show lists all variables' do shared_examples 'GET #show lists all variables' do
it 'renders the variables as json' do it 'renders the variables as json' do
subject subject
......
# frozen_string_literal: true
shared_examples 'dirty submit form' do |selector_args| shared_examples 'dirty submit form' do |selector_args|
selectors = selector_args.is_a?(Array) ? selector_args : [selector_args] selectors = selector_args.is_a?(Array) ? selector_args : [selector_args]
......
# frozen_string_literal: true
# Specifications for behavior common to all objects with an email attribute. # Specifications for behavior common to all objects with an email attribute.
# Takes a list of email-format attributes and requires: # Takes a list of email-format attributes and requires:
# - subject { "the object with a attribute= setter" } # - subject { "the object with a attribute= setter" }
......
# frozen_string_literal: true
shared_examples_for 'fast destroyable' do shared_examples_for 'fast destroyable' do
describe 'Forbid #destroy and #destroy_all' do describe 'Forbid #destroy and #destroy_all' do
it 'does not delete database rows and associted external data' do it 'does not delete database rows and associted external data' do
......
# frozen_string_literal: true
shared_examples 'comment on merge request file' do shared_examples 'comment on merge request file' do
it 'adds a comment' do it 'adds a comment' do
click_diff_line(find("[id='#{sample_commit.line_code}']")) click_diff_line(find("[id='#{sample_commit.line_code}']"))
......
# frozen_string_literal: true
RSpec.shared_examples 'a creatable merge request' do RSpec.shared_examples 'a creatable merge request' do
include WaitForRequests include WaitForRequests
......
# frozen_string_literal: true
RSpec.shared_examples 'an editable merge request' do RSpec.shared_examples 'an editable merge request' do
it 'updates merge request', :js do it 'updates merge request', :js do
find('.js-assignee-search').click find('.js-assignee-search').click
......
# frozen_string_literal: true
shared_examples 'issue sidebar stays collapsed on mobile' do shared_examples 'issue sidebar stays collapsed on mobile' do
before do before do
resize_screen_xs resize_screen_xs
......
# frozen_string_literal: true
shared_examples 'issuable user dropdown behaviors' do shared_examples 'issuable user dropdown behaviors' do
include FilteredSearchHelpers include FilteredSearchHelpers
......
# frozen_string_literal: true
RSpec.shared_examples 'Maintainer manages access requests' do RSpec.shared_examples 'Maintainer manages access requests' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:maintainer) { create(:user) } let(:maintainer) { create(:user) }
......
# frozen_string_literal: true
shared_examples 'project features apply to issuables' do |klass| shared_examples 'project features apply to issuables' do |klass|
let(:described_class) { klass } let(:described_class) { klass }
......
# frozen_string_literal: true
shared_examples "protected branches > access control > CE" do shared_examples "protected branches > access control > CE" do
ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)| ProtectedRefAccess::HUMAN_ACCESS_LEVELS.each do |(access_type_id, access_type_name)|
it "allows creating protected branches that #{access_type_name} can push to" do it "allows creating protected branches that #{access_type_name} can push to" do
......
# frozen_string_literal: true
shared_examples 'top right search form' do shared_examples 'top right search form' do
it 'does not show top right search form' do it 'does not show top right search form' do
expect(page).not_to have_selector('.search') expect(page).not_to have_selector('.search')
......
# frozen_string_literal: true
shared_examples 'file finder' do shared_examples 'file finder' do
let(:query) { 'files' } let(:query) { 'files' }
let(:search_results) { subject.find(query) } let(:search_results) { subject.find(query) }
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples 'a finder with external authorization service' do shared_examples 'a finder with external authorization service' do
......
# frozen_string_literal: true
RSpec.shared_examples 'Gitlab::Verify::BatchVerifier subclass' do RSpec.shared_examples 'Gitlab::Verify::BatchVerifier subclass' do
describe 'batching' do describe 'batching' do
let(:first_batch) { objects[0].id..objects[0].id } let(:first_batch) { objects[0].id..objects[0].id }
......
# frozen_string_literal: true
RSpec.shared_examples 'issuable state' do RSpec.shared_examples 'issuable state' do
it 'exposes all the existing issuable states' do it 'exposes all the existing issuable states' do
expect(described_class.values.keys).to include(*%w[opened closed locked]) expect(described_class.values.keys).to include(*%w[opened closed locked])
......
# frozen_string_literal: true
RSpec.shared_examples 'members and requesters associations' do RSpec.shared_examples 'members and requesters associations' do
describe '#members_and_requesters' do describe '#members_and_requesters' do
it 'includes members and requesters' do it 'includes members and requesters' do
......
# frozen_string_literal: true
shared_examples 'helm commands' do shared_examples 'helm commands' do
describe '#generate_script' do describe '#generate_script' do
let(:helm_setup) do let(:helm_setup) do
......
# frozen_string_literal: true
shared_examples 'cache counters invalidator' do shared_examples 'cache counters invalidator' do
it 'invalidates counter cache for assignees' do it 'invalidates counter cache for assignees' do
expect_any_instance_of(User).to receive(:invalidate_merge_request_cache_counts) expect_any_instance_of(User).to receive(:invalidate_merge_request_cache_counts)
......
# frozen_string_literal: true
shared_examples 'issuables list meta-data' do |issuable_type, action = nil| shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
include ProjectForksHelper include ProjectForksHelper
......
# frozen_string_literal: true
RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr| RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr|
it { is_expected.to allow_value('https://example.com').for(url_attr) } it { is_expected.to allow_value('https://example.com').for(url_attr) }
......
# frozen_string_literal: true
shared_examples_for 'normalizes a DN' do shared_examples_for 'normalizes a DN' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
......
# frozen_string_literal: true
shared_examples 'redirecting a legacy path' do |source, target| shared_examples 'redirecting a legacy path' do |source, target|
include RSpec::Rails::RequestExampleGroup include RSpec::Rails::RequestExampleGroup
......
# frozen_string_literal: true
shared_examples 'backfill migration for project repositories' do |storage| shared_examples 'backfill migration for project repositories' do |storage|
describe '#perform' do describe '#perform' do
let(:storage_versions) { storage == :legacy ? [nil, 0] : [1, 2] } let(:storage_versions) { storage == :legacy ? [nil, 0] : [1, 2] }
......
# frozen_string_literal: true
require 'timeout' require 'timeout'
shared_examples 'malicious regexp' do shared_examples 'malicious regexp' do
......
# frozen_string_literal: true
# Specifications for behavior common to all Mentionable implementations. # Specifications for behavior common to all Mentionable implementations.
# Requires a shared context containing: # Requires a shared context containing:
# - subject { "the mentionable implementation" } # - subject { "the mentionable implementation" }
......
# frozen_string_literal: true
shared_examples 'milestone tabs' do shared_examples 'milestone tabs' do
def go(path, extra_params = {}) def go(path, extra_params = {})
params = params =
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples_for 'AtomicInternalId' do |validate_presence: true| shared_examples_for 'AtomicInternalId' do |validate_presence: true|
......
# frozen_string_literal: true
require "spec_helper" require "spec_helper"
shared_examples_for "chat service" do |service_name| shared_examples_for "chat service" do |service_name|
......
# frozen_string_literal: true
shared_examples 'cluster application core specs' do |application_name| shared_examples 'cluster application core specs' do |application_name|
it { is_expected.to belong_to(:cluster) } it { is_expected.to belong_to(:cluster) }
it { is_expected.to validate_presence_of(:cluster) } it { is_expected.to validate_presence_of(:cluster) }
......
# frozen_string_literal: true
shared_examples 'cluster application helm specs' do |application_name| shared_examples 'cluster application helm specs' do |application_name|
let(:application) { create(application_name) } let(:application) { create(application_name) }
......
# frozen_string_literal: true
shared_examples 'cluster application status specs' do |application_name| shared_examples 'cluster application status specs' do |application_name|
describe '#status' do describe '#status' do
let(:cluster) { create(:cluster, :provided_by_gcp) } let(:cluster) { create(:cluster, :provided_by_gcp) }
......
# frozen_string_literal: true
# This shared example requires a `builder` and `user` variable # This shared example requires a `builder` and `user` variable
shared_examples 'issuable hook data' do |kind| shared_examples 'issuable hook data' do |kind|
let(:data) { builder.build(user: user) } let(:data) { builder.build(user: user) }
......
# frozen_string_literal: true
RSpec.shared_examples 'members notifications' do |entity_type| RSpec.shared_examples 'members notifications' do |entity_type|
let(:notification_service) { double('NotificationService').as_null_object } let(:notification_service) { double('NotificationService').as_null_object }
......
# frozen_string_literal: true
shared_examples 'project hook data with deprecateds' do |project_key: :project| shared_examples 'project hook data with deprecateds' do |project_key: :project|
it 'contains project data' do it 'contains project data' do
expect(data[project_key][:name]).to eq(project.name) expect(data[project_key][:name]).to eq(project.name)
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples_for 'model with uploads' do |supports_fileuploads| shared_examples_for 'model with uploads' do |supports_fileuploads|
......
# frozen_string_literal: true
shared_context 'gitlab email notification' do shared_context 'gitlab email notification' do
set(:group) { create(:group) } set(:group) { create(:group) }
set(:subgroup) { create(:group, parent: group) } set(:subgroup) { create(:group, parent: group) }
......
# frozen_string_literal: true
shared_examples_for "position formatter" do shared_examples_for "position formatter" do
let(:formatter) { described_class.new(attrs) } let(:formatter) { described_class.new(attrs) }
......
# frozen_string_literal: true
RSpec.shared_examples "referenced feature visibility" do |*related_features| RSpec.shared_examples "referenced feature visibility" do |*related_features|
let(:feature_fields) do let(:feature_fields) do
related_features.map { |feature| (feature + "_access_level").to_sym } related_features.map { |feature| (feature + "_access_level").to_sym }
......
# frozen_string_literal: true
shared_examples 'custom attributes endpoints' do |attributable_name| shared_examples 'custom attributes endpoints' do |attributable_name|
let!(:custom_attribute1) { attributable.custom_attributes.create key: 'foo', value: 'foo' } let!(:custom_attribute1) { attributable.custom_attributes.create key: 'foo', value: 'foo' }
let!(:custom_attribute2) { attributable.custom_attributes.create key: 'bar', value: 'bar' } let!(:custom_attribute2) { attributable.custom_attributes.create key: 'bar', value: 'bar' }
......
# frozen_string_literal: true
shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "includes diff discussions" do it "includes diff discussions" do
......
# frozen_string_literal: true
shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_reply_to_individual_notes: false| shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_reply_to_individual_notes: false|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "returns an array of discussions" do it "returns an array of discussions" do
......
# frozen_string_literal: true
shared_examples 'issuable participants endpoint' do shared_examples 'issuable participants endpoint' do
let(:area) { entity.class.name.underscore.pluralize } let(:area) { entity.class.name.underscore.pluralize }
......
# frozen_string_literal: true
def get_issue def get_issue
json_response.is_a?(Array) ? json_response.detect {|issue| issue['id'] == target_issue.id} : json_response json_response.is_a?(Array) ? json_response.detect {|issue| issue['id'] == target_issue.id} : json_response
end end
......
# frozen_string_literal: true
shared_examples 'noteable API' do |parent_type, noteable_type, id_name| shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes" do describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes" do
context 'sorting' do context 'sorting' do
......
# frozen_string_literal: true
shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_name| shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_name|
describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id" do describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id" do
it "resolves discussion if resolved is true" do it "resolves discussion if resolved is true" do
......
# frozen_string_literal: true
# Specs for status checking. # Specs for status checking.
# #
# Requires an API request: # Requires an API request:
......
# frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
shared_examples 'a working graphql query' do shared_examples 'a working graphql query' do
......
# frozen_string_literal: true
shared_examples 'note entity' do shared_examples 'note entity' do
subject { entity.as_json } subject { entity.as_json }
......
# frozen_string_literal: true
shared_examples 'boards create service' do shared_examples 'boards create service' do
context 'when parent does not have a board' do context 'when parent does not have a board' do
it 'creates a new board' do it 'creates a new board' do
......
# frozen_string_literal: true
shared_examples 'boards list service' do shared_examples 'boards list service' do
context 'when parent does not have a board' do context 'when parent does not have a board' do
it 'creates a new parent board' do it 'creates a new parent board' do
......
# frozen_string_literal: true
shared_examples 'issues list service' do shared_examples 'issues list service' do
it 'delegates search to IssuesFinder' do it 'delegates search to IssuesFinder' do
params = { board_id: board.id, id: list1.id } params = { board_id: board.id, id: list1.id }
......
# frozen_string_literal: true
shared_examples 'issues move service' do |group| shared_examples 'issues move service' do |group|
shared_examples 'updating timestamps' do shared_examples 'updating timestamps' do
it 'updates updated_at' do it 'updates updated_at' do
......
# frozen_string_literal: true
shared_examples 'lists destroy service' do shared_examples 'lists destroy service' do
context 'when list type is label' do context 'when list type is label' do
it 'removes list from board' do it 'removes list from board' do
......
# frozen_string_literal: true
shared_examples 'lists list service' do shared_examples 'lists list service' do
context 'when the board has a backlog list' do context 'when the board has a backlog list' do
let!(:backlog_list) { create(:backlog_list, board: board) } let!(:backlog_list) { create(:backlog_list, board: board) }
......
# frozen_string_literal: true
shared_examples 'lists move service' do shared_examples 'lists move service' do
let!(:planning) { create(:list, board: board, position: 0) } let!(:planning) { create(:list, board: board, position: 0) }
let!(:development) { create(:list, board: board, position: 1) } let!(:development) { create(:list, board: board, position: 1) }
......
# frozen_string_literal: true
shared_examples 'check ingress ip executions' do |app_name| shared_examples 'check ingress ip executions' do |app_name|
describe '#execute' do describe '#execute' do
let(:application) { create(app_name, :installed) } let(:application) { create(app_name, :installed) }
......
# frozen_string_literal: true
shared_examples 'gitlab projects import validations' do shared_examples 'gitlab projects import validations' do
context 'with an invalid path' do context 'with an invalid path' do
let(:path) { '/invalid-path/' } let(:path) { '/invalid-path/' }
......
# frozen_string_literal: true
Dir[Rails.root.join("app/models/project_services/chat_message/*.rb")].each { |f| require f } Dir[Rails.root.join("app/models/project_services/chat_message/*.rb")].each { |f| require f }
RSpec.shared_examples 'slack or mattermost notifications' do RSpec.shared_examples 'slack or mattermost notifications' do
......
# frozen_string_literal: true
RSpec.shared_examples 'snippet visibility' do RSpec.shared_examples 'snippet visibility' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
......
# frozen_string_literal: true
# These shared examples expect a `snippets` array of snippets # These shared examples expect a `snippets` array of snippets
RSpec.shared_examples 'paginated snippets' do |remote: false| RSpec.shared_examples 'paginated snippets' do |remote: false|
it "is limited to #{Snippet.default_per_page} items per page" do it "is limited to #{Snippet.default_per_page} items per page" do
......
# frozen_string_literal: true
# Specs for task state functionality for issues and merge requests. # Specs for task state functionality for issues and merge requests.
# #
# Requires a context containing: # Requires a context containing:
......
# frozen_string_literal: true
shared_examples_for 'throttled touch' do shared_examples_for 'throttled touch' do
describe '#touch' do describe '#touch' do
it 'updates the updated_at timestamp' do it 'updates the updated_at timestamp' do
......
# frozen_string_literal: true
shared_context 'unique ips sign in limit' do shared_context 'unique ips sign in limit' do
include StubENV include StubENV
before do before do
......
# frozen_string_literal: true
shared_examples 'update invalid issuable' do |klass| shared_examples 'update invalid issuable' do |klass|
let(:params) do let(:params) do
{ {
......
# frozen_string_literal: true
RSpec.shared_examples 'updating mentions' do |service_class| RSpec.shared_examples 'updating mentions' do |service_class|
let(:mentioned_user) { create(:user) } let(:mentioned_user) { create(:user) }
let(:service_class) { service_class } let(:service_class) { service_class }
......
# frozen_string_literal: true
shared_examples "matches the method pattern" do |method| shared_examples "matches the method pattern" do |method|
let(:target) { subject } let(:target) { subject }
let(:args) { nil } let(:args) { nil }
......
# frozen_string_literal: true
shared_context 'with storage' do |store, **stub_params| shared_context 'with storage' do |store, **stub_params|
before do before do
subject.object_store = store subject.object_store = store
......
# frozen_string_literal: true
RSpec.shared_examples 'url validator examples' do |schemes| RSpec.shared_examples 'url validator examples' do |schemes|
let(:validator) { described_class.new(attributes: [:link_url], **options) } let(:validator) { described_class.new(attributes: [:link_url], **options) }
let!(:badge) { build(:badge, link_url: 'http://www.example.com') } let!(:badge) { build(:badge, link_url: 'http://www.example.com') }
......
# frozen_string_literal: true
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
# If Sidekiq::Testing.inline! is used, SQL transactions done inside # If Sidekiq::Testing.inline! is used, SQL transactions done inside
......
# frozen_string_literal: true
RSpec.configure do |config| RSpec.configure do |config|
config.before(:each, :broken_storage) do config.before(:each, :broken_storage) do
allow(Gitlab::GitalyClient).to receive(:call) do allow(Gitlab::GitalyClient).to receive(:call) do
......
# frozen_string_literal: true
module TestReportsHelper module TestReportsHelper
def create_test_case_rspec_success(name = 'test_spec') def create_test_case_rspec_success(name = 'test_spec')
Gitlab::Ci::Reports::TestCase.new( Gitlab::Ci::Reports::TestCase.new(
......
# frozen_string_literal: true
module TraceHelpers module TraceHelpers
def create_legacy_trace(build, content) def create_legacy_trace(build, content)
File.open(legacy_trace_path(build), 'wb') { |stream| stream.write(content) } File.open(legacy_trace_path(build), 'wb') { |stream| stream.write(content) }
......
# frozen_string_literal: true
require 'webmock' require 'webmock'
require 'webmock/rspec' require 'webmock/rspec'
......
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