Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-02-06 18:08:54 +00:00
parent 0eb3d2f799
commit 0d6fa03312
93 changed files with 1070 additions and 447 deletions

View File

@ -6,6 +6,14 @@
.if-canonical-gitlab-merge-request: &if-canonical-gitlab-merge-request
if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAMESPACE == "gitlab-org" && $CI_MERGE_REQUEST_IID'
# Make sure to update all the similar conditions in other CI config files if you modify these conditions
.if-not-ee: &if-not-ee
if: '$CI_PROJECT_NAME !~ /^gitlab(-ee)?$/'
# Make sure to update all the similar conditions in other CI config files if you modify these conditions
.if-default-refs: &if-default-refs
if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable(-ee)?$/ || $CI_COMMIT_REF_NAME =~ /^\d+-\d+-auto-deploy-\d+$/ || $CI_COMMIT_REF_NAME =~ /^security\// || $CI_MERGE_REQUEST_IID || $CI_COMMIT_TAG'
# Make sure to update all the similar patterns in other CI config files if you modify these patterns
.code-patterns: &code-patterns
- ".gitlab/ci/**/*"
@ -27,12 +35,43 @@
- ".dockerignore"
- "qa/**/*"
# Make sure to update all the similar patterns in other CI config files if you modify these patterns
.code-qa-patterns: &code-qa-patterns
- ".gitlab/ci/**/*"
- ".{eslintignore,gitattributes,nvmrc,prettierrc,stylelintrc,yamllint}"
- ".{codeclimate,eslintrc,gitlab-ci,haml-lint,haml-lint_todo,rubocop,rubocop_todo,scss-lint}.yml"
- ".csscomb.json"
- "Dockerfile.assets"
- "*_VERSION"
- "Gemfile{,.lock}"
- "Rakefile"
- "{babel.config,jest.config}.js"
- "config.ru"
- "{package.json,yarn.lock}"
- "{,ee/}{app,bin,config,db,haml_lint,lib,locale,public,scripts,symbol,vendor}/**/*"
- "doc/api/graphql/reference/*" # Files in this folder are auto-generated
# QA changes
- ".dockerignore"
- "qa/**/*"
.qa:rules:ee-and-foss:
rules:
- <<: *if-default-refs
changes: *code-qa-patterns
when: on_success
.qa:rules:ee-only:
rules:
- <<: *if-not-ee
when: never
- <<: *if-default-refs
changes: *code-qa-patterns
when: on_success
.qa-job-base:
extends:
- .default-tags
- .default-retry
- .default-only
- .only:changes-code-qa
stage: test
dependencies: []
cache:
@ -46,26 +85,32 @@
- bundle check
qa:internal:
extends: .qa-job-base
extends:
- .qa-job-base
- .qa:rules:ee-and-foss
script:
- bundle exec rspec
qa:internal-foss:
extends:
- .qa-job-base
- .only-ee-as-if-foss
- .qa:rules:ee-only
- .as-if-foss
script:
- bundle exec rspec
qa:selectors:
extends: .qa-job-base
extends:
- .qa-job-base
- .qa:rules:ee-and-foss
script:
- bundle exec bin/qa Test::Sanity::Selectors
qa:selectors-foss:
extends:
- qa:selectors
- .only-ee-as-if-foss
- .qa:rules:ee-only
- .as-if-foss
.package-and-qa-base:
image: ruby:2.6-alpine

View File

@ -334,17 +334,15 @@ RSpec/UnspecifiedException:
# Work in progress. See https://gitlab.com/gitlab-org/gitlab/issues/196163
RSpec/HaveGitlabHttpStatus:
Enabled: true
Exclude:
- 'spec/support/matchers/have_gitlab_http_status.rb'
Include:
- 'spec/support/shared_examples/**/*'
- 'ee/spec/support/shared_examples/**/*'
- 'spec/support/**/*'
- 'ee/spec/support/**/*'
- 'spec/features/**/*'
- 'ee/spec/features/**/*'
- 'spec/controllers/*.rb'
- 'ee/spec/controllers/*.rb'
- 'spec/controllers/projects/**/*.rb'
- 'ee/spec/controllers/projects/**/*.rb'
- 'spec/controllers/groups/**/*.rb'
- 'ee/spec/controllers/groups/**/*.rb'
- 'spec/controllers/**/*'
- 'ee/spec/controllers/**/*'
- 'spec/requests/*.rb'
- 'ee/spec/requests/*.rb'

View File

@ -36,6 +36,7 @@ import initSearchAutocomplete from './search_autocomplete';
import GlFieldErrors from './gl_field_errors';
import initUserPopovers from './user_popovers';
import initBroadcastNotifications from './broadcast_notification';
import PersistentUserCallout from './persistent_user_callout';
import { initUserTracking } from './tracking';
import { __ } from './locale';
@ -108,6 +109,9 @@ function deferredInitialisation() {
initUserTracking();
initBroadcastNotifications();
const recoverySettingsCallout = document.querySelector('.js-recovery-settings-callout');
PersistentUserCallout.factory(recoverySettingsCallout);
if (document.querySelector('.search')) initSearchAutocomplete();
addSelectOnFocusBehaviour('.js-select-on-focus');

View File

@ -2,7 +2,10 @@
class UserCalloutsController < ApplicationController
def create
if ensure_callout.persisted?
callout = ensure_callout
if callout.persisted?
callout.update(dismissed_at: Time.now)
respond_to do |format|
format.json { head :ok }
end

View File

@ -16,7 +16,8 @@ module Types
:create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages,
:admin_remote_mirror, :create_label, :update_wiki, :destroy_wiki,
:create_pages, :destroy_pages, :read_pages_content, :admin_operations
:create_pages, :destroy_pages, :read_pages_content, :admin_operations,
:read_merge_request
permission_field :create_snippet

View File

@ -153,7 +153,7 @@ module MarkupHelper
other_markup_unsafe(file_name, text, context)
end
rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, project_id: @project&.id, file_name: file_name, context: context)
Gitlab::ErrorTracking.track_exception(e, project_id: @project&.id, file_name: file_name)
simple_format(text)
end

View File

@ -22,6 +22,9 @@ module UserCalloutsHelper
def render_dashboard_gold_trial(user)
end
def render_account_recovery_regular_check
end
def show_suggest_popover?
!user_dismissed?(SUGGEST_POPOVER_DISMISSED)
end
@ -32,8 +35,10 @@ module UserCalloutsHelper
private
def user_dismissed?(feature_name)
current_user&.callouts&.find_by(feature_name: UserCallout.feature_names[feature_name])
def user_dismissed?(feature_name, ignore_dismissal_earlier_than = nil)
return false unless current_user
current_user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: ignore_dismissal_earlier_than)
end
end

View File

@ -4,19 +4,78 @@ module Ci
class Bridge < Ci::Processable
include Ci::Contextable
include Ci::PipelineDelegator
include Ci::Metadatable
include Importable
include AfterCommitQueue
include HasRef
include Gitlab::Utils::StrongMemoize
InvalidBridgeTypeError = Class.new(StandardError)
belongs_to :project
belongs_to :trigger_request
has_many :sourced_pipelines, class_name: "::Ci::Sources::Pipeline",
foreign_key: :source_job_id
validates :ref, presence: true
# rubocop:disable Cop/ActiveRecordSerialize
serialize :options
serialize :yaml_variables, ::Gitlab::Serializer::Ci::Variables
# rubocop:enable Cop/ActiveRecordSerialize
state_machine :status do
event :manual do
transition all => :manual
end
event :scheduled do
transition all => :scheduled
end
end
def self.retry(bridge, current_user)
raise NotImplementedError
end
def inherit_status_from_downstream!(pipeline)
case pipeline.status
when 'success'
self.success!
when 'failed', 'canceled', 'skipped'
self.drop!
else
false
end
end
def downstream_pipeline_params
return child_params if triggers_child_pipeline?
return cross_project_params if downstream_project.present?
{}
end
def downstream_project
strong_memoize(:downstream_project) do
if downstream_project_path
::Project.find_by_full_path(downstream_project_path)
elsif triggers_child_pipeline?
project
end
end
end
def downstream_project_path
strong_memoize(:downstream_project_path) do
options&.dig(:trigger, :project)
end
end
def triggers_child_pipeline?
yaml_for_downstream.present?
end
def tags
[:bridge]
end
@ -55,7 +114,68 @@ module Ci
end
def yaml_for_downstream
nil
strong_memoize(:yaml_for_downstream) do
includes = options&.dig(:trigger, :include)
YAML.dump('include' => includes) if includes
end
end
def target_ref
branch = options&.dig(:trigger, :branch)
return unless branch
scoped_variables.to_runner_variables.yield_self do |all_variables|
::ExpandVariables.expand(branch, all_variables)
end
end
def dependent?
strong_memoize(:dependent) do
options&.dig(:trigger, :strategy) == 'depend'
end
end
def downstream_variables
variables = scoped_variables.concat(pipeline.persisted_variables)
variables.to_runner_variables.yield_self do |all_variables|
yaml_variables.to_a.map do |hash|
{ key: hash[:key], value: ::ExpandVariables.expand(hash[:value], all_variables) }
end
end
end
private
def cross_project_params
{
project: downstream_project,
source: :pipeline,
target_revision: {
ref: target_ref || downstream_project.default_branch
},
execute_params: { ignore_skip_ci: true }
}
end
def child_params
parent_pipeline = pipeline
{
project: project,
source: :parent_pipeline,
target_revision: {
ref: parent_pipeline.ref,
checkout_sha: parent_pipeline.sha,
before: parent_pipeline.before_sha,
source_sha: parent_pipeline.source_sha,
target_sha: parent_pipeline.target_sha
},
execute_params: {
ignore_skip_ci: true,
bridge: self
}
}
end
end
end

View File

@ -58,5 +58,12 @@ module PrometheusAdapter
def build_query_args(*args)
args.map { |arg| arg.respond_to?(:id) ? arg.id : arg }
end
def clear_prometheus_reactive_cache!(query_name, *args)
query_class = query_klass_for(query_name)
query_args = build_query_args(*args)
clear_reactive_cache!(query_class.name, *query_args)
end
end
end

View File

@ -11,6 +11,7 @@ class Environment < ApplicationRecord
has_many :deployments, -> { visible }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :successful_deployments, -> { success }, class_name: 'Deployment'
has_many :prometheus_alerts, inverse_of: :environment
has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment'
has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus'
@ -105,6 +106,14 @@ class Environment < ApplicationRecord
find_or_create_by(name: name)
end
def clear_prometheus_reactive_cache!(query_name)
cluster_prometheus_adapter&.clear_prometheus_reactive_cache!(query_name, self)
end
def cluster_prometheus_adapter
@cluster_prometheus_adapter ||= ::Gitlab::Prometheus::Adapter.new(project, deployment_platform&.cluster).cluster_prometheus_adapter
end
def predefined_variables
Gitlab::Ci::Variables::Collection.new
.append(key: 'CI_ENVIRONMENT_NAME', value: name)

View File

@ -244,6 +244,7 @@ class Project < ApplicationRecord
has_many :management_clusters, class_name: 'Clusters::Cluster', foreign_key: :management_project_id, inverse_of: :management_project
has_many :prometheus_metrics
has_many :prometheus_alerts, inverse_of: :project
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy

View File

@ -0,0 +1,81 @@
# frozen_string_literal: true
class PrometheusAlert < ApplicationRecord
include Sortable
OPERATORS_MAP = {
lt: "<",
eq: "==",
gt: ">"
}.freeze
belongs_to :environment, validate: true, inverse_of: :prometheus_alerts
belongs_to :project, validate: true, inverse_of: :prometheus_alerts
belongs_to :prometheus_metric, validate: true, inverse_of: :prometheus_alerts
has_many :prometheus_alert_events, inverse_of: :prometheus_alert
has_many :related_issues, through: :prometheus_alert_events
after_save :clear_prometheus_adapter_cache!
after_destroy :clear_prometheus_adapter_cache!
validates :environment, :project, :prometheus_metric, presence: true
validate :require_valid_environment_project!
validate :require_valid_metric_project!
enum operator: { lt: 0, eq: 1, gt: 2 }
delegate :title, :query, to: :prometheus_metric
scope :for_metric, -> (metric) { where(prometheus_metric: metric) }
scope :for_project, -> (project) { where(project_id: project) }
scope :for_environment, -> (environment) { where(environment_id: environment) }
def self.distinct_projects
sub_query = self.group(:project_id).select(1)
self.from(sub_query)
end
def self.operator_to_enum(op)
OPERATORS_MAP.invert.fetch(op)
end
def full_query
"#{query} #{computed_operator} #{threshold}"
end
def computed_operator
OPERATORS_MAP.fetch(operator.to_sym)
end
def to_param
{
"alert" => title,
"expr" => full_query,
"for" => "5m",
"labels" => {
"gitlab" => "hook",
"gitlab_alert_id" => prometheus_metric_id
}
}
end
private
def clear_prometheus_adapter_cache!
environment.clear_prometheus_reactive_cache!(:additional_metrics_environment)
end
def require_valid_environment_project!
return if project == environment&.project
errors.add(:environment, "invalid project")
end
def require_valid_metric_project!
return if prometheus_metric&.common?
return if project == prometheus_metric&.project
errors.add(:prometheus_metric, "invalid project")
end
end

View File

@ -1644,6 +1644,13 @@ class User < ApplicationRecord
end
# End of signup_flow experiment methods
def dismissed_callout?(feature_name:, ignore_dismissal_earlier_than: nil)
callouts = self.callouts.with_feature_name(feature_name)
callouts = callouts.with_dismissed_after(ignore_dismissal_earlier_than) if ignore_dismissal_earlier_than
callouts.any?
end
# @deprecated
alias_method :owned_or_masters_groups, :owned_or_maintainers_groups

View File

@ -12,4 +12,7 @@ class UserCallout < ApplicationRecord
presence: true,
uniqueness: { scope: :user_id },
inclusion: { in: UserCallout.feature_names.keys }
scope :with_feature_name, -> (feature_name) { where(feature_name: UserCallout.feature_names[feature_name]) }
scope :with_dismissed_after, -> (dismissed_after) { where('dismissed_at > ?', dismissed_after) }
end

View File

@ -4,6 +4,8 @@
.table-mobile-header{ role: "rowheader" }= s_("ClusterIntegration|Kubernetes cluster")
.table-mobile-content
= cluster.item_link(clusterable, html_options: { data: { qa_selector: 'cluster', qa_cluster_name: cluster.name } })
- if cluster.status_name == :creating
.spinner.ml-2.align-middle.has-tooltip{ title: s_("ClusterIntegration|Cluster being created") }
- unless cluster.enabled?
%span.badge.badge-danger Connection disabled
.table-section.section-25

View File

@ -11,6 +11,7 @@
= render "layouts/nav/classification_level_banner"
= yield :flash_message
= render "shared/ping_consent"
= render_account_recovery_regular_check
- unless @hide_breadcrumbs
= render "layouts/nav/breadcrumbs"
.d-flex

View File

@ -0,0 +1,6 @@
.gl-alert.gl-alert-warning.js-recovery-settings-callout{ role: 'alert', data: { feature_id: "account_recovery_regular_check", dismiss_endpoint: user_callouts_path, defer_links: "true" } }
%button.js-close.gl-alert-dismiss.gl-cursor-pointer{ type: 'button', 'aria-label' => _('Dismiss') }
= sprite_icon('close', size: 16, css_class: 'gl-icon')
.gl-alert-body
- account_link_start = '<a class="deferred-link" href="%{url}">'.html_safe % { url: profile_account_path }
= _("Please ensure your account's %{account_link_start}recovery settings%{account_link_end} are up to date.").html_safe % { account_link_start: account_link_start, account_link_end: '</a>'.html_safe }

View File

@ -0,0 +1,5 @@
---
title: Add loading icon to clusters being created
merge_request: 24370
author:
type: added

View File

@ -0,0 +1,5 @@
---
title: Don't leak entire objects into the error log when rendering markup fails
merge_request: 24599
author:
type: fixed

View File

@ -0,0 +1,6 @@
---
title: Remove username lookup when mapping users when importing projects using Project
Import/Export and rely on email only
merge_request: 24464
author:
type: changed

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
class AddDissmisedAtToUserCallouts < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
add_column :user_callouts, :dismissed_at, :datetime_with_timezone
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_02_04_131054) do
ActiveRecord::Schema.define(version: 2020_02_05_143231) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
@ -4101,6 +4101,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do
create_table "user_callouts", id: :serial, force: :cascade do |t|
t.integer "feature_name", null: false
t.integer "user_id", null: false
t.datetime_with_timezone "dismissed_at"
t.index ["user_id", "feature_name"], name: "index_user_callouts_on_user_id_and_feature_name", unique: true
t.index ["user_id"], name: "index_user_callouts_on_user_id"
end

View File

@ -727,7 +727,7 @@ For example:
Geo database has an outdated FDW remote schema. It contains 229 of 236 expected tables. Please refer to Geo Troubleshooting.
```
To resolve this, run the following command:
To resolve this, run the following command on the **secondary**:
```shell
sudo gitlab-rake geo:db:refresh_foreign_tables

View File

@ -5831,6 +5831,11 @@ type ProjectPermissions {
"""
readDesign: Boolean!
"""
Indicates the user can perform `read_merge_request` on this resource
"""
readMergeRequest: Boolean!
"""
Indicates the user can perform `read_pages_content` on this resource
"""

View File

@ -2253,6 +2253,24 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "readMergeRequest",
"description": "Indicates the user can perform `read_merge_request` on this resource",
"args": [
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "readPagesContent",
"description": "Indicates the user can perform `read_pages_content` on this resource",

View File

@ -867,6 +867,7 @@ Information about pagination in a connection.
| `readCommitStatus` | Boolean! | Indicates the user can perform `read_commit_status` on this resource |
| `readCycleAnalytics` | Boolean! | Indicates the user can perform `read_cycle_analytics` on this resource |
| `readDesign` | Boolean! | Indicates the user can perform `read_design` on this resource |
| `readMergeRequest` | Boolean! | Indicates the user can perform `read_merge_request` on this resource |
| `readPagesContent` | Boolean! | Indicates the user can perform `read_pages_content` on this resource |
| `readProject` | Boolean! | Indicates the user can perform `read_project` on this resource |
| `readProjectMember` | Boolean! | Indicates the user can perform `read_project_member` on this resource |

View File

@ -26,7 +26,7 @@ Note the following:
and are deleted every 24 hours by a specific worker.
- Group members are exported as project members, as long as the user has
maintainer or admin access to the group where the exported project lives. An admin
in the import side is required to map the users, based on email or username.
in the import side is required to map the users, based on email.
Otherwise, a supplementary comment is left to mention the original author and
the MRs, notes, or issues will be owned by the importer.
- Project members with owner access will be imported as maintainers.

View File

@ -636,10 +636,9 @@ module Gitlab
end
# Delete the specified branch from the repository
# Note: No Git hooks are executed for this action
def delete_branch(branch_name)
wrapped_gitaly_errors do
gitaly_ref_client.delete_branch(branch_name)
end
write_ref(branch_name, Gitlab::Git::BLANK_SHA)
rescue CommandError => e
raise DeleteBranchError, e
end
@ -651,14 +650,13 @@ module Gitlab
end
# Create a new branch named **ref+ based on **stat_point+, HEAD by default
# Note: No Git hooks are executed for this action
#
# Examples:
# create_branch("feature")
# create_branch("other-feature", "master")
def create_branch(ref, start_point = "HEAD")
wrapped_gitaly_errors do
gitaly_ref_client.create_branch(ref, start_point)
end
write_ref(ref, start_point)
end
# If `mirror_refmap` is present the remote is set as mirror with that mapping

View File

@ -151,40 +151,6 @@ module Gitlab
Gitlab::Git::Branch.new(@repository, encode!(branch.name.dup), branch.target_commit.id, target_commit)
end
def create_branch(ref, start_point)
request = Gitaly::CreateBranchRequest.new(
repository: @gitaly_repo,
name: encode_binary(ref),
start_point: encode_binary(start_point)
)
response = GitalyClient.call(@repository.storage, :ref_service, :create_branch, request, timeout: GitalyClient.medium_timeout)
case response.status
when :OK
branch = response.branch
target_commit = Gitlab::Git::Commit.decorate(@repository, branch.target_commit)
Gitlab::Git::Branch.new(@repository, branch.name, branch.target_commit.id, target_commit)
when :ERR_INVALID
invalid_ref!("Invalid ref name")
when :ERR_EXISTS
invalid_ref!("Branch #{ref} already exists")
when :ERR_INVALID_START_POINT
invalid_ref!("Invalid reference #{start_point}")
else
raise "Unknown response status: #{response.status}"
end
end
def delete_branch(branch_name)
request = Gitaly::DeleteBranchRequest.new(
repository: @gitaly_repo,
name: encode_binary(branch_name)
)
GitalyClient.call(@repository.storage, :ref_service, :delete_branch, request, timeout: GitalyClient.medium_timeout)
end
def delete_refs(refs: [], except_with_prefixes: [])
request = Gitaly::DeleteRefsRequest.new(
repository: @gitaly_repo,

View File

@ -82,7 +82,7 @@ module Gitlab
end
def find_user_query(member)
user_arel[:email].eq(member['user']['email']).or(user_arel[:username].eq(member['user']['username']))
user_arel[:email].eq(member['user']['email'])
end
def user_arel

View File

@ -8,15 +8,19 @@ module Gitlab
AmbiguousProcessError = Class.new(IdentificationError)
UnknownProcessError = Class.new(IdentificationError)
AVAILABLE_RUNTIMES = [
:console,
:geo_log_cursor,
:puma,
:rake,
:sidekiq,
:test_suite,
:unicorn
].freeze
class << self
def identify
matches = []
matches << :puma if puma?
matches << :unicorn if unicorn?
matches << :console if console?
matches << :sidekiq if sidekiq?
matches << :rake if rake?
matches << :test_suite if test_suite?
matches = AVAILABLE_RUNTIMES.select { |runtime| public_send("#{runtime}?") } # rubocop:disable GitlabSecurity/PublicSend
if matches.one?
matches.first
@ -56,6 +60,10 @@ module Gitlab
!!defined?(::Rails::Console)
end
def geo_log_cursor?
!!defined?(::GeoLogCursorOptionParser)
end
def web_server?
puma? || unicorn?
end

View File

@ -3974,6 +3974,9 @@ msgstr ""
msgid "ClusterIntegration|Cloud Run"
msgstr ""
msgid "ClusterIntegration|Cluster being created"
msgstr ""
msgid "ClusterIntegration|Cluster health"
msgstr ""
@ -13858,6 +13861,9 @@ msgstr ""
msgid "Please enable and migrate to hashed storage to avoid security issues and ensure data integrity. %{migrate_link}"
msgstr ""
msgid "Please ensure your account's %{account_link_start}recovery settings%{account_link_end} are up to date."
msgstr ""
msgid "Please enter a non-negative number"
msgstr ""

View File

@ -16,7 +16,7 @@ describe Admin::ApplicationsController do
it 'renders the application form' do
get :index
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end

View File

@ -36,7 +36,7 @@ describe Admin::Clusters::ApplicationsController do
expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once
expect { subject }.to change { current_application.count }
expect(response).to have_http_status(:no_content)
expect(response).to have_gitlab_http_status(:no_content)
expect(cluster.application_helm).to be_scheduled
end
@ -47,7 +47,7 @@ describe Admin::Clusters::ApplicationsController do
it 'return 404' do
expect { subject }.not_to change { current_application.count }
expect(response).to have_http_status(:not_found)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -55,7 +55,7 @@ describe Admin::Clusters::ApplicationsController do
let(:application) { 'unkwnown-app' }
it 'return 404' do
is_expected.to have_http_status(:not_found)
is_expected.to have_gitlab_http_status(:not_found)
end
end
@ -65,7 +65,7 @@ describe Admin::Clusters::ApplicationsController do
end
it 'returns 400' do
is_expected.to have_http_status(:bad_request)
is_expected.to have_gitlab_http_status(:bad_request)
end
end
end
@ -99,7 +99,7 @@ describe Admin::Clusters::ApplicationsController do
it "schedules an application update" do
expect(ClusterPatchAppWorker).to receive(:perform_async).with(application.name, anything).once
is_expected.to have_http_status(:no_content)
is_expected.to have_gitlab_http_status(:no_content)
expect(cluster.application_cert_manager).to be_scheduled
end
@ -110,13 +110,13 @@ describe Admin::Clusters::ApplicationsController do
cluster.destroy!
end
it { is_expected.to have_http_status(:not_found) }
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when application is unknown' do
let(:application_name) { 'unkwnown-app' }
it { is_expected.to have_http_status(:not_found) }
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when application is already scheduled' do
@ -124,7 +124,7 @@ describe Admin::Clusters::ApplicationsController do
application.make_scheduled!
end
it { is_expected.to have_http_status(:bad_request) }
it { is_expected.to have_gitlab_http_status(:bad_request) }
end
end

View File

@ -567,7 +567,7 @@ describe Admin::ClustersController do
put_update(format: :json)
cluster.reload
expect(response).to have_http_status(:no_content)
expect(response).to have_gitlab_http_status(:no_content)
expect(cluster.enabled).to be_falsey
expect(cluster.name).to eq('my-new-cluster-name')
expect(cluster).not_to be_managed
@ -587,7 +587,7 @@ describe Admin::ClustersController do
it 'rejects changes' do
put_update(format: :json)
expect(response).to have_http_status(:bad_request)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end

View File

@ -11,7 +11,7 @@ describe Admin::GitalyServersController do
it 'shows the gitaly servers page' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end

View File

@ -24,7 +24,7 @@ describe Admin::HooksController do
post :create, params: { hook: hook_params }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(SystemHook.all.size).to eq(1)
expect(SystemHook.first).to have_attributes(hook_params)
end

View File

@ -24,7 +24,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in" do
@ -48,7 +48,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in as the impersonator" do
@ -67,7 +67,7 @@ describe Admin::ImpersonationsController do
it "responds with status 404" do
delete :destroy
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it "doesn't sign us in as the impersonator" do

View File

@ -29,7 +29,7 @@ describe Admin::ProjectsController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).not_to match(pending_delete_project.name)
expect(response.body).to match(project.name)
end
@ -61,7 +61,7 @@ describe Admin::ProjectsController do
it 'renders show page' do
get :show, params: { namespace_id: project.namespace.path, id: project.path }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to match(project.name)
end
end

View File

@ -36,7 +36,7 @@ describe Admin::RequestsProfilesController do
it 'renders the data' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(sample_data)
end
end
@ -54,7 +54,7 @@ describe Admin::RequestsProfilesController do
it 'renders the data' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to eq(sample_data)
end
end

View File

@ -15,7 +15,7 @@ describe Admin::RunnersController do
it 'lists all runners' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'avoids N+1 queries', :request_store do
@ -29,7 +29,7 @@ describe Admin::RunnersController do
# We also need to add 1 because it takes 2 queries to preload tags
expect { get :index }.not_to exceed_query_limit(control_count + 6)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to have_content('tag1')
expect(response.body).to have_content('tag2')
end
@ -49,13 +49,13 @@ describe Admin::RunnersController do
it 'shows a particular runner' do
get :show, params: { id: runner.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'shows 404 for unknown runner' do
get :show, params: { id: 0 }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'avoids N+1 queries', :request_store do
@ -70,7 +70,7 @@ describe Admin::RunnersController do
# needs_new_sso_session permission
expect { get :show, params: { id: runner.id } }.not_to exceed_query_limit(control_count + 1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -84,7 +84,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(runner.description).to eq(new_desc)
end
end
@ -93,7 +93,7 @@ describe Admin::RunnersController do
it 'destroys the runner' do
delete :destroy, params: { id: runner.id }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(Ci::Runner.find_by(id: runner.id)).to be_nil
end
end
@ -108,7 +108,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(runner.active).to eq(true)
end
end
@ -123,7 +123,7 @@ describe Admin::RunnersController do
runner.reload
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(runner.active).to eq(false)
end
end

View File

@ -22,7 +22,7 @@ describe Admin::ServicesController do
it 'successfully displays the template' do
get :edit, params: { id: service.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
@ -48,7 +48,7 @@ describe Admin::ServicesController do
put :update, params: { id: service.id, service: { active: true } }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'does not call the propagation worker when service is not active' do
@ -56,7 +56,7 @@ describe Admin::ServicesController do
put :update, params: { id: service.id, service: { properties: {} } }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end

View File

@ -124,7 +124,7 @@ describe Admin::SessionsController, :do_not_mock_admin_mode do
it 'shows error page' do
post :destroy
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(controller.current_user_mode.admin_mode?).to be(false)
end
end

View File

@ -16,7 +16,7 @@ describe Admin::SpamLogsController do
it 'lists all spam logs' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -24,14 +24,14 @@ describe Admin::SpamLogsController do
it 'removes only the spam log when removing log' do
expect { delete :destroy, params: { id: first_spam.id } }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'removes user and his spam logs when removing the user', :sidekiq_might_not_need_inline do
delete :destroy, params: { id: first_spam.id, remove_user: true }
expect(flash[:notice]).to eq "User #{user.username} was successfully removed."
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(SpamLog.count).to eq(0)
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
@ -46,7 +46,7 @@ describe Admin::SpamLogsController do
it 'submits the log as ham' do
post :mark_as_ham, params: { id: first_spam.id }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy
end
end

View File

@ -47,7 +47,7 @@ describe Admin::UsersController do
it 'deletes user and ghosts their contributions' do
delete :destroy, params: { id: user.username }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(User.exists?(user.id)).to be_falsy
expect(issue.reload.author).to be_ghost
end
@ -55,7 +55,7 @@ describe Admin::UsersController do
it 'deletes the user and their contributions when hard delete is specified' do
delete :destroy, params: { id: user.username, hard_delete: true }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(User.exists?(user.id)).to be_falsy
expect(Issue.exists?(issue.id)).to be_falsy
end
@ -399,7 +399,7 @@ describe Admin::UsersController do
it "shows error page" do
post :impersonate, params: { id: user.username }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end

View File

@ -28,7 +28,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: 999, list: list2
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -106,7 +106,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
list_issues user: user, board: board, list: 999
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@ -132,7 +132,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
list_issues user: unauth_user, board: board, list: list2
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
@ -148,7 +148,7 @@ describe Boards::IssuesController do
list_issues(user: user, board: group_board)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'is successful for project boards' do
@ -156,7 +156,7 @@ describe Boards::IssuesController do
list_issues(user: user, board: project_board)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -215,7 +215,7 @@ describe Boards::IssuesController do
expect(response).to have_gitlab_http_status(expected_status)
list_issues user: requesting_user, board: board, list: list2
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('entities/issue_boards')
@ -391,7 +391,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
create_issue user: user, board: board, list: list1, title: 'New issue'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the created issue' do
@ -406,7 +406,7 @@ describe Boards::IssuesController do
it 'returns an unprocessable entity 422 response' do
create_issue user: user, board: board, list: list1, title: nil
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@ -416,7 +416,7 @@ describe Boards::IssuesController do
create_issue user: user, board: board, list: list, title: 'New issue'
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -424,7 +424,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: 999, list: list1, title: 'New issue'
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -432,7 +432,7 @@ describe Boards::IssuesController do
it 'returns a not found 404 response' do
create_issue user: user, board: board, list: 999, title: 'New issue'
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@ -443,7 +443,7 @@ describe Boards::IssuesController do
open_list = board.lists.create(list_type: :backlog)
create_issue user: guest, board: board, list: open_list, title: 'New issue'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -451,7 +451,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
create_issue user: guest, board: board, list: list1, title: 'New issue'
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@ -475,7 +475,7 @@ describe Boards::IssuesController do
it 'returns a successful 200 response' do
move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'moves issue to the desired list' do
@ -489,19 +489,19 @@ describe Boards::IssuesController do
it 'returns a unprocessable entity 422 response for invalid lists' do
move user: user, board: board, issue: issue, from_list_id: nil, to_list_id: nil
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns a not found 404 response for invalid board id' do
move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a not found 404 response for invalid issue id' do
move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -515,7 +515,7 @@ describe Boards::IssuesController do
it 'returns a forbidden 403 response' do
move user: guest, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end

View File

@ -21,7 +21,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
read_board_list user: user, board: board
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json'
end
@ -50,7 +50,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
read_board_list user: unauth_user, board: board
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
@ -73,7 +73,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
create_board_list user: user, board: board, label_id: label.id
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the created list' do
@ -88,7 +88,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
create_board_list user: user, board: board, label_id: nil
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -98,7 +98,7 @@ describe Boards::ListsController do
create_board_list user: user, board: board, label_id: label.id
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@ -109,7 +109,7 @@ describe Boards::ListsController do
create_board_list user: guest, board: board, label_id: label.id
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
@ -134,7 +134,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
move user: user, board: board, list: planning, position: 1
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'moves the list to the desired position' do
@ -148,7 +148,7 @@ describe Boards::ListsController do
it 'returns an unprocessable entity 422 response' do
move user: user, board: board, list: planning, position: 6
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@ -156,7 +156,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
move user: user, board: board, list: 999, position: 1
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -164,7 +164,7 @@ describe Boards::ListsController do
it 'returns a 422 unprocessable entity response' do
move user: guest, board: board, list: planning, position: 6
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@ -173,14 +173,14 @@ describe Boards::ListsController do
save_setting user: user, board: board, list: planning, setting: { collapsed: true }
expect(planning.preferences_for(user).collapsed).to eq(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'saves not collapsed preference for user' do
save_setting user: user, board: board, list: planning, setting: { collapsed: false }
expect(planning.preferences_for(user).collapsed).to eq(false)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -191,14 +191,14 @@ describe Boards::ListsController do
save_setting user: user, board: board, list: closed, setting: { collapsed: true }
expect(closed.preferences_for(user).collapsed).to eq(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'saves not collapsed preference for user' do
save_setting user: user, board: board, list: closed, setting: { collapsed: false }
expect(closed.preferences_for(user).collapsed).to eq(false)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -236,7 +236,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
remove_board_list user: user, board: board, list: planning
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'removes list from board' do
@ -248,7 +248,7 @@ describe Boards::ListsController do
it 'returns a not found 404 response' do
remove_board_list user: user, board: board, list: 999
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -256,7 +256,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
remove_board_list user: guest, board: board, list: planning
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
@ -278,7 +278,7 @@ describe Boards::ListsController do
it 'returns a successful 200 response' do
generate_default_lists user: user, board: board
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the defaults lists' do
@ -294,7 +294,7 @@ describe Boards::ListsController do
generate_default_lists user: user, board: board
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
@ -302,7 +302,7 @@ describe Boards::ListsController do
it 'returns a forbidden 403 response' do
generate_default_lists user: guest, board: board
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end

View File

@ -51,7 +51,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to match(/#{message}/)
end
@ -60,7 +60,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'is skipped when the `unless` condition returns true' do
@ -68,13 +68,13 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'correctly renders an action that does not require cross project access' do
get :show, params: { id: 'nothing' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -113,7 +113,7 @@ describe ControllerWithCrossProjectAccessCheck do
it 'renders a success when the check is skipped' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'is executed when the `if` condition returns false' do
@ -121,7 +121,7 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'is executed when the `unless` condition returns true' do
@ -129,19 +129,19 @@ describe ControllerWithCrossProjectAccessCheck do
get :index
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not skip the check on an action that is not skipped' do
get :show, params: { id: 'hello' }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not skip the check on an action that was not defined to skip' do
get :edit, params: { id: 'hello' }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end

View File

@ -39,7 +39,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
it 'renders ok' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
@ -48,7 +48,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
it 'renders a 404' do
get :index
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not set admin mode' do
@ -75,7 +75,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
let(:user) { create(:admin) }
it 'allows direct access to page' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'does not set admin mode' do
@ -85,7 +85,7 @@ describe EnforcesAdminAuthentication, :do_not_mock_admin_mode do
context 'as a user' do
it 'renders a 404' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not set admin mode' do

View File

@ -30,7 +30,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: project.namespace.to_param, id: project.to_param }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'renders a 403 when the service denies access to the project' do
@ -38,7 +38,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: project.namespace.to_param, id: project.to_param }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to match("External authorization denied access to this project")
end
@ -47,7 +47,7 @@ describe ProjectUnauthorized do
get :show, params: { namespace_id: other_project.namespace.to_param, id: other_project.to_param }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end

View File

@ -47,14 +47,14 @@ describe RoutableActions do
it 'allows access' do
get_routable(routable)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'prevents access when not authorized' do
get_routable(routable)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -75,14 +75,14 @@ describe RoutableActions do
it 'allows access' do
get_routable(routable)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'prevents access when not authorized' do
get_routable(routable)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -92,7 +92,7 @@ describe RoutableActions do
it 'allows access when authorized' do
get_routable(routable)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'prevents access when unauthorized' do
@ -100,7 +100,7 @@ describe RoutableActions do
get_routable(user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@ -111,7 +111,7 @@ describe RoutableActions do
get_routable(routable)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response.location).to end_with('/users/sign_in')
end
end

View File

@ -27,7 +27,7 @@ describe StaticObjectExternalStorage do
do_request
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -75,7 +75,7 @@ describe StaticObjectExternalStorage do
request.headers['X-Gitlab-External-Storage-Token'] = 'letmein'
do_request
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -84,7 +84,7 @@ describe StaticObjectExternalStorage do
request.headers['X-Gitlab-External-Storage-Token'] = 'donotletmein'
do_request
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end

View File

@ -40,7 +40,7 @@ describe Dashboard::GroupsController do
it 'renders only groups the user is a member of when searching hierarchy correctly' do
get :index, params: { filter: 'chef' }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
all_groups = [top_level_result, top_level_a, sub_level_result_a]
expect(assigns(:groups)).to contain_exactly(*all_groups)
end
@ -51,7 +51,7 @@ describe Dashboard::GroupsController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end

View File

@ -40,7 +40,7 @@ describe Dashboard::MilestonesController do
it 'shows milestone page' do
view_milestone
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -55,7 +55,7 @@ describe Dashboard::MilestonesController do
it 'returns group and project milestones to which the user belongs' do
get :index, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.map { |i| i["name"] }).to match_array([group_milestone.name, project_milestone.name])
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
@ -64,7 +64,7 @@ describe Dashboard::MilestonesController do
it 'returns closed group and project milestones to which the user belongs' do
get :index, params: { state: 'closed' }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
expect(json_response.map { |i| i["name"] }).to match_array([closed_group_milestone.name, closed_project_milestone.name])
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)

View File

@ -23,7 +23,7 @@ describe Dashboard::ProjectsController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end

View File

@ -20,19 +20,19 @@ describe Dashboard::TodosController do
get :index, params: { project_id: unauthorized_project.id }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders 404 when given project does not exists' do
get :index, params: { project_id: 999 }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'renders 200 when filtering for "any project" todos' do
get :index, params: { project_id: '' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'renders 200 when user has access on given project' do
@ -40,7 +40,7 @@ describe Dashboard::TodosController do
get :index, params: { project_id: authorized_project.id }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -78,7 +78,7 @@ describe Dashboard::TodosController do
get :index, params: { group_id: unauthorized_group.id }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -130,7 +130,7 @@ describe Dashboard::TodosController do
patch :restore, params: { id: todo.id }
expect(todo.reload).to be_pending
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ "count" => 1, "done_count" => 0 })
end
end
@ -144,7 +144,7 @@ describe Dashboard::TodosController do
todos.each do |todo|
expect(todo.reload).to be_pending
end
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'count' => 2, 'done_count' => 0 })
end
end

View File

@ -23,7 +23,7 @@ describe GoogleApi::AuthorizationsController do
subject
expect(session[GoogleApi::CloudPlatform::Client.session_key_for_token]).to be_nil
expect(response).to have_http_status(:not_found)
expect(response).to have_gitlab_http_status(:not_found)
end
end

View File

@ -123,7 +123,7 @@ describe Import::BitbucketController do
post :create, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 422 response when the project could not be imported' do
@ -133,7 +133,7 @@ describe Import::BitbucketController do
post :create, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it_behaves_like 'project import rate limiter'
@ -330,7 +330,7 @@ describe Import::BitbucketController do
post :create, params: { target_namespace: other_namespace.name }, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end

View File

@ -48,7 +48,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'with project key with tildes' do
@ -61,20 +61,20 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug, format: :json }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
it 'returns an error when an invalid project key is used' do
post :create, params: { project: 'some&project' }
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when an invalid repository slug is used' do
post :create, params: { project: 'some-project', repository: 'try*this' }
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when the project cannot be found' do
@ -82,7 +82,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it 'returns an error when the project cannot be saved' do
@ -92,7 +92,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it "returns an error when the server can't be contacted" do
@ -100,7 +100,7 @@ describe Import::BitbucketServerController do
post :create, params: { project: project_key, repository: repo_slug }, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
it_behaves_like 'project import rate limiter'
@ -118,7 +118,7 @@ describe Import::BitbucketServerController do
expect(session[:bitbucket_server_username]).to be_nil
expect(session[:bitbucket_server_personal_access_token]).to be_nil
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
@ -128,7 +128,7 @@ describe Import::BitbucketServerController do
expect(session[:bitbucket_server_url]).to eq(url)
expect(session[:bitbucket_server_username]).to eq(username)
expect(session[:bitbucket_server_personal_access_token]).to eq(token)
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
end

View File

@ -22,7 +22,7 @@ describe Import::GithubController do
get :new
expect(response).to have_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it "prompts for an access token if GitHub not configured" do
@ -31,7 +31,7 @@ describe Import::GithubController do
get :new
expect(response).to have_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'when importing a CI/CD project' do

View File

@ -86,7 +86,7 @@ describe Import::GitlabController do
post :create, format: :json
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns 422 response when the project could not be imported' do
@ -96,7 +96,7 @@ describe Import::GitlabController do
post :create, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
context "when the repository owner is the GitLab.com user" do
@ -279,7 +279,7 @@ describe Import::GitlabController do
post :create, params: { target_namespace: other_namespace.name }, format: :json
expect(response).to have_gitlab_http_status(422)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end

View File

@ -17,14 +17,14 @@ describe Import::GitlabProjectsController do
post :create, params: { namespace_id: namespace.id, path: '/test', file: file }
expect(flash[:alert]).to start_with('Project could not be imported')
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'redirects with an error when a relative path is used' do
post :create, params: { namespace_id: namespace.id, path: '../test', file: file }
expect(flash[:alert]).to start_with('Project could not be imported')
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
@ -33,7 +33,7 @@ describe Import::GitlabProjectsController do
post :create, params: { namespace_id: namespace.id, path: 'test', file: file }
expect(flash[:notice]).to include('is being imported')
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end

View File

@ -18,7 +18,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: [])
end
it { is_expected.to have_gitlab_http_status(404) }
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the feature is disabled' do
@ -27,7 +27,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: ['phabricator'])
end
it { is_expected.to have_gitlab_http_status(404) }
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the import is available' do
@ -36,7 +36,7 @@ describe Import::PhabricatorController do
stub_application_setting(import_sources: ['phabricator'])
end
it { is_expected.to have_gitlab_http_status(200) }
it { is_expected.to have_gitlab_http_status(:ok) }
end
end

View File

@ -14,7 +14,7 @@ describe Oauth::ApplicationsController do
it 'shows list of applications' do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'redirects back to profile page if OAuth applications are disabled' do
@ -22,7 +22,7 @@ describe Oauth::ApplicationsController do
get :index
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
@ -30,7 +30,7 @@ describe Oauth::ApplicationsController do
it 'creates an application' do
post :create, params: oauth_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(oauth_application_path(Doorkeeper::Application.last))
end
@ -39,7 +39,7 @@ describe Oauth::ApplicationsController do
post :create, params: oauth_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(profile_path)
end

View File

@ -23,7 +23,7 @@ describe Oauth::AuthorizationsController do
it 'returns 200 code and renders error view' do
get :new
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/error')
end
end
@ -34,7 +34,7 @@ describe Oauth::AuthorizationsController do
it 'returns 200 code and renders view' do
get :new, params: params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('doorkeeper/authorizations/new')
end
@ -45,7 +45,7 @@ describe Oauth::AuthorizationsController do
get :new, params: params
expect(request.session['user_return_to']).to be_nil
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
context 'when there is already an access token for the application' do
@ -62,7 +62,7 @@ describe Oauth::AuthorizationsController do
get :new, params: params
expect(request.session['user_return_to']).to be_nil
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end

View File

@ -13,7 +13,7 @@ describe Profiles::AccountsController do
it 'renders 404 if someone tries to unlink a non existent provider' do
delete :unlink, params: { provider: 'github' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
[:saml, :cas3].each do |provider|
@ -25,7 +25,7 @@ describe Profiles::AccountsController do
delete :unlink, params: { provider: provider.to_s }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(user.reload.identities).to include(identity)
end
end
@ -40,7 +40,7 @@ describe Profiles::AccountsController do
delete :unlink, params: { provider: provider.to_s }
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
expect(user.reload.identities).not_to include(identity)
end
end

View File

@ -22,7 +22,7 @@ describe Snippets::NotesController do
end
it "returns status 200" do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "returns not empty array of notes" do
@ -39,7 +39,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: internal_snippet }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -51,7 +51,7 @@ describe Snippets::NotesController do
it "returns status 200" do
get :index, params: { snippet_id: internal_snippet }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
@ -65,7 +65,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: private_snippet }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -77,7 +77,7 @@ describe Snippets::NotesController do
it "returns status 404" do
get :index, params: { snippet_id: private_snippet }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
@ -91,7 +91,7 @@ describe Snippets::NotesController do
it "returns status 200" do
get :index, params: { snippet_id: private_snippet }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "returns 1 note" do
@ -135,7 +135,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@ -158,7 +158,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@ -186,7 +186,7 @@ describe Snippets::NotesController do
it 'returns status 404' do
post :create, params: request_params
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'does not create the note' do
@ -204,7 +204,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note on the public snippet' do
@ -222,7 +222,7 @@ describe Snippets::NotesController do
it 'returns status 302' do
post :create, params: request_params
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
it 'creates the note' do
@ -249,7 +249,7 @@ describe Snippets::NotesController do
it "returns status 200" do
delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "deletes the note" do
@ -277,7 +277,7 @@ describe Snippets::NotesController do
it "returns status 404" do
delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it "does not update the note" do
@ -299,7 +299,7 @@ describe Snippets::NotesController do
it "toggles the award emoji" do
expect { subject }.to change { note.award_emoji.count }.by(1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it "removes the already awarded emoji when it exists" do
@ -307,7 +307,7 @@ describe Snippets::NotesController do
expect { subject }.to change { AwardEmoji.count }.by(-1)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end

View File

@ -13,7 +13,7 @@ describe UserCalloutsController do
subject { post :create, params: { feature_name: feature_name }, format: :json }
context 'with valid feature name' do
let(:feature_name) { UserCallout.feature_names.first.first }
let(:feature_name) { UserCallout.feature_names.keys.first }
context 'when callout entry does not exist' do
it 'creates a callout entry with dismissed state' do
@ -28,7 +28,7 @@ describe UserCalloutsController do
end
context 'when callout entry already exists' do
let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.first.first, user: user) }
let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.keys.first, user: user) }
it 'returns success' do
subject

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
FactoryBot.define do
factory :prometheus_alert do
project
operator { :gt }
threshold { 1 }
environment do |alert|
build(:environment, project: alert.project)
end
prometheus_metric do |alert|
build(:prometheus_metric, project: alert.project)
end
end
end

View File

@ -187,7 +187,7 @@ describe 'User creates branch and merge request on issue page', :js do
let(:branch_name) { "#{issue.iid}-foo" }
before do
project.repository.create_branch(branch_name, 'master')
project.repository.create_branch(branch_name)
visit project_issue_path(project, issue)
end

View File

@ -46,7 +46,7 @@ describe 'Merge request > User posts diff notes', :js do
end
context 'with an old line on the left and a new line on the right' do
it 'allows commenting on the left side' do
it 'allows commenting on the left side', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/199050' do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left')
end

View File

@ -169,8 +169,8 @@ describe 'Merge request > User resolves conflicts', :js do
context "with malicious branch name" do
let(:bad_branch_name) { "malicious-branch-{{toString.constructor('alert(/xss/)')()}}" }
let(:branch) { project.repository.create_branch(bad_branch_name, 'conflict-resolvable') }
let(:merge_request) { create_merge_request(branch.name) }
let!(:branch) { project.repository.create_branch(bad_branch_name, 'conflict-resolvable') }
let(:merge_request) { create_merge_request(bad_branch_name) }
before do
visit project_merge_request_path(project, merge_request)

View File

@ -60,7 +60,7 @@ describe 'Project Graph', :js do
let(:branch_name) { '<h1>evil</h1>' }
before do
project.repository.create_branch(branch_name, 'master')
project.repository.create_branch(branch_name)
visit charts_project_graph_path(project, branch_name)
end

View File

@ -2398,7 +2398,7 @@
"requested_at": null,
"user": {
"id": 16,
"email": "maritza_schoen@block.ca",
"email": "bernard_willms@gitlabexample.com",
"username": "bernard_willms"
}
},
@ -2418,7 +2418,7 @@
"requested_at": null,
"user": {
"id": 6,
"email": "shaina@koelpindenesik.com",
"email": "saul_will@gitlabexample.com",
"username": "saul_will"
}
},

View File

@ -348,7 +348,7 @@
"override": false,
"user": {
"id": 206,
"email": "margaret.bergnaum@reynolds.us",
"email": "gwendolyn_robel@gitlabexample.com",
"username": "gwendolyn_robel"
}
},
@ -394,7 +394,7 @@
"override": false,
"user": {
"id": 1624,
"email": "nakesha.herzog@powlowski.com",
"email": "adriene.mcclure@gitlabexample.com",
"username": "adriene.mcclure"
}
},

View File

@ -12,7 +12,8 @@ describe Types::PermissionTypes::Project do
:read_commit_status, :request_access, :create_pipeline, :create_pipeline_schedule,
:create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label,
:update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content
:update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content,
:read_merge_request
]
expected_permissions.each do |permission|

View File

@ -403,7 +403,7 @@ describe MarkupHelper do
it 'logs the error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
instance_of(StandardError),
project_id: project.id, file_name: 'foo.md', context: context
project_id: project.id, file_name: 'foo.md'
)
subject

View File

@ -310,8 +310,8 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
repository.create_branch('left-branch', 'master')
repository.create_branch('right-branch', 'master')
repository.create_branch('left-branch')
repository.create_branch('right-branch')
left.times do
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
@ -350,8 +350,8 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
repository.create_branch('left-branch', 'master')
repository.create_branch('right-branch', 'master')
repository.create_branch('left-branch')
repository.create_branch('right-branch')
left.times do
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
@ -420,55 +420,6 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
describe "#delete_branch" do
let(:repository) { mutable_repository }
after do
ensure_seeds
end
it "removes the branch from the repo" do
branch_name = "to-be-deleted-soon"
repository.create_branch(branch_name)
expect(repository_rugged.branches[branch_name]).not_to be_nil
repository.delete_branch(branch_name)
expect(repository_rugged.branches[branch_name]).to be_nil
end
context "when branch does not exist" do
it "raises a DeleteBranchError exception" do
expect { repository.delete_branch("this-branch-does-not-exist") }.to raise_error(Gitlab::Git::Repository::DeleteBranchError)
end
end
end
describe "#create_branch" do
let(:repository) { mutable_repository }
after do
ensure_seeds
end
it "creates a new branch" do
expect(repository.create_branch('new_branch', 'master')).not_to be_nil
end
it "creates a new branch with the right name" do
expect(repository.create_branch('another_branch', 'master').name).to eq('another_branch')
end
it "fails if we create an existing branch" do
repository.create_branch('duplicated_branch', 'master')
expect {repository.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
end
it "fails if we create a branch from a non existing ref" do
expect {repository.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
end
end
describe '#delete_refs' do
let(:repository) { mutable_repository }
@ -506,8 +457,8 @@ describe Gitlab::Git::Repository, :seed_helper do
let(:utf8_branch) { 'branch-é' }
before do
repository.create_branch(new_branch, 'master')
repository.create_branch(utf8_branch, 'master')
repository.create_branch(new_branch)
repository.create_branch(utf8_branch)
end
after do
@ -609,32 +560,30 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '#search_files_by_content' do
let(:repository) { mutable_repository }
let(:repository_rugged) { mutable_repository_rugged }
let(:ref) { 'search-files-by-content-branch' }
let(:content) { 'foobarbazmepmep' }
before do
repository.create_branch('search-files-by-content-branch', 'master')
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
new_commit_edit_new_file_on_branch(repository_rugged, 'anotherfile', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
repository.create_branch(ref)
new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', ref, 'committing something', content)
new_commit_edit_new_file_on_branch(repository_rugged, 'anotherfile', ref, 'committing something', content)
end
after do
ensure_seeds
end
shared_examples 'search files by content' do
it 'has 2 items' do
expect(search_results.size).to eq(2)
end
it 'has the correct matching line' do
expect(search_results).to contain_exactly("search-files-by-content-branch:encoding/CHANGELOG\u00001\u0000search-files-by-content change\n",
"search-files-by-content-branch:anotherfile\u00001\u0000search-files-by-content change\n")
end
subject do
repository.search_files_by_content(content, ref)
end
it_should_behave_like 'search files by content' do
let(:search_results) do
repository.search_files_by_content('search-files-by-content', 'search-files-by-content-branch')
end
it 'has 2 items' do
expect(subject.size).to eq(2)
end
it 'has the correct matching line' do
expect(subject).to contain_exactly("#{ref}:encoding/CHANGELOG\u00001\u0000#{content}\n",
"#{ref}:anotherfile\u00001\u0000#{content}\n")
end
end
@ -1116,7 +1065,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
repository.create_branch('local_branch', 'master')
repository.create_branch('local_branch')
end
after do
@ -1142,7 +1091,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
repository.create_branch('local_branch', 'master')
repository.create_branch('local_branch')
end
after do
@ -1192,7 +1141,7 @@ describe Gitlab::Git::Repository, :seed_helper do
context 'when no branch names are specified' do
before do
repository.create_branch('identical', 'master')
repository.create_branch('identical')
end
after do
@ -1303,7 +1252,7 @@ describe Gitlab::Git::Repository, :seed_helper do
let(:branch_name) { "ʕ•ᴥ•ʔ" }
before do
repository.create_branch(branch_name, "master")
repository.create_branch(branch_name)
end
after do
@ -1447,7 +1396,7 @@ describe Gitlab::Git::Repository, :seed_helper do
before do
create_remote_branch('joe', 'remote_branch', 'master')
repository.create_branch('local_branch', 'master')
repository.create_branch('local_branch')
end
after do

View File

@ -10,9 +10,9 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
describe 'restore group tree' do
before(:context) do
# Using an admin for import, so we can check assignment of existing members
user = create(:admin, username: 'root')
create(:user, username: 'adriene.mcclure')
create(:user, username: 'gwendolyn_robel')
user = create(:admin, email: 'root@gitlabexample.com')
create(:user, email: 'adriene.mcclure@gitlabexample.com')
create(:user, email: 'gwendolyn_robel@gitlabexample.com')
RSpec::Mocks.with_temporary_scope do
@group = create(:group, name: 'group', path: 'group')
@ -56,7 +56,7 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
end
it 'has group members' do
expect(@group.members.map(&:user).map(&:username)).to contain_exactly('root', 'adriene.mcclure', 'gwendolyn_robel')
expect(@group.members.map(&:user).map(&:email)).to contain_exactly('root@gitlabexample.com', 'adriene.mcclure@gitlabexample.com', 'gwendolyn_robel@gitlabexample.com')
end
end
end

View File

@ -13,8 +13,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
# Using an admin for import, so we can check assignment of existing members
@user = create(:admin)
@existing_members = [
create(:user, username: 'bernard_willms'),
create(:user, username: 'saul_will')
create(:user, email: 'bernard_willms@gitlabexample.com'),
create(:user, email: 'saul_will@gitlabexample.com')
]
RSpec::Mocks.with_temporary_scope do

View File

@ -3,6 +3,23 @@
require 'spec_helper'
describe Gitlab::Runtime do
shared_examples "valid runtime" do |runtime, max_threads|
it "identifies itself" do
expect(subject.identify).to eq(runtime)
expect(subject.public_send("#{runtime}?")).to be(true)
end
it "does not identify as others" do
(described_class::AVAILABLE_RUNTIMES - [runtime]).each do |runtime|
expect(subject.public_send("#{runtime}?")).to eq(false)
end
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(max_threads)
end
end
before do
allow(described_class).to receive(:process_name).and_return('ruby')
stub_rails_env('production')
@ -27,117 +44,42 @@ describe Gitlab::Runtime do
context "puma" do
let(:puma_type) { double('::Puma') }
let(:options) do
{
max_threads: 2
}
end
before do
stub_const('::Puma', puma_type)
allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(options)
allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(max_threads: 2)
end
it "identifies itself" do
expect(subject.identify).to eq(:puma)
expect(subject.puma?).to be(true)
end
it "does not identify as others" do
expect(subject.unicorn?).to be(false)
expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(2)
end
it_behaves_like "valid runtime", :puma, 2
end
context "unicorn" do
let(:unicorn_type) { Module.new }
let(:unicorn_server_type) { Class.new }
before do
stub_const('::Unicorn', unicorn_type)
stub_const('::Unicorn::HttpServer', unicorn_server_type)
stub_const('::Unicorn', Module.new)
stub_const('::Unicorn::HttpServer', Class.new)
end
it "identifies itself" do
expect(subject.identify).to eq(:unicorn)
expect(subject.unicorn?).to be(true)
end
it "does not identify as others" do
expect(subject.puma?).to be(false)
expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
it_behaves_like "valid runtime", :unicorn, 1
end
context "sidekiq" do
let(:sidekiq_type) { double('::Sidekiq') }
let(:options) do
{
concurrency: 2
}
end
before do
stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true)
allow(sidekiq_type).to receive(:options).and_return(options)
allow(sidekiq_type).to receive(:options).and_return(concurrency: 2)
end
it "identifies itself" do
expect(subject.identify).to eq(:sidekiq)
expect(subject.sidekiq?).to be(true)
end
it "does not identify as others" do
expect(subject.unicorn?).to be(false)
expect(subject.puma?).to be(false)
expect(subject.console?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(2)
end
it_behaves_like "valid runtime", :sidekiq, 2
end
context "console" do
let(:console_type) { double('::Rails::Console') }
before do
stub_const('::Rails::Console', console_type)
stub_const('::Rails::Console', double('::Rails::Console'))
end
it "identifies itself" do
expect(subject.identify).to eq(:console)
expect(subject.console?).to be(true)
end
it "does not identify as others" do
expect(subject.unicorn?).to be(false)
expect(subject.sidekiq?).to be(false)
expect(subject.puma?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.test_suite?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
it_behaves_like "valid runtime", :console, 1
end
context "test suite" do
@ -145,20 +87,14 @@ describe Gitlab::Runtime do
stub_rails_env('test')
end
it "identifies itself" do
expect(subject.identify).to eq(:test_suite)
expect(subject.test_suite?).to be(true)
it_behaves_like "valid runtime", :test_suite, 1
end
context "geo log cursor" do
before do
stub_const('::GeoLogCursorOptionParser', double('::GeoLogCursorOptionParser'))
end
it "does not identify as others" do
expect(subject.unicorn?).to be(false)
expect(subject.sidekiq?).to be(false)
expect(subject.rake?).to be(false)
expect(subject.puma?).to be(false)
end
it "reports its maximum concurrency" do
expect(subject.max_threads).to eq(1)
end
it_behaves_like "valid runtime", :geo_log_cursor, 1
end
end

View File

@ -14,28 +14,28 @@ describe MigrateIssueTrackersData, :migration do
}
end
let!(:jira_service) do
services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker')
services.create(type: 'JiraService', properties: properties, category: 'issue_tracker')
end
let!(:jira_service_nil) do
services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker')
services.create(type: 'JiraService', properties: nil, category: 'issue_tracker')
end
let!(:bugzilla_service) do
services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker')
services.create(type: 'BugzillaService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service) do
services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker')
services.create(type: 'YoutrackService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service_empty) do
services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker')
services.create(type: 'YoutrackService', properties: '', category: 'issue_tracker')
end
let!(:gitlab_service) do
services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
services.create(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
end
let!(:gitlab_service_empty) do
services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
services.create(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
end
let!(:other_service) do
services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category')
services.create(type: 'OtherService', properties: properties, category: 'other_category')
end
before do

View File

@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200130145430_reschedule_migrate_issue_trackers_data.rb')
describe RescheduleMigrateIssueTrackersData, :migration, :sidekiq do
describe RescheduleMigrateIssueTrackersData, :migration do
let(:services) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData }
let(:migration_name) { migration_class.to_s.demodulize }

View File

@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb')
describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration, :sidekiq do
describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration do
include MigrationHelpers::NamespacesHelpers
let(:migration_class) { described_class::MIGRATION }
let(:migration_name) { migration_class.to_s.demodulize }

View File

@ -4,14 +4,25 @@ require 'spec_helper'
describe Ci::Bridge do
set(:project) { create(:project) }
set(:target_project) { create(:project, name: 'project', namespace: create(:namespace, name: 'my')) }
set(:pipeline) { create(:ci_pipeline, project: project) }
let(:bridge) do
create(:ci_bridge, pipeline: pipeline)
create(:ci_bridge, :variables, status: :created,
options: options,
pipeline: pipeline)
end
let(:options) do
{ trigger: { project: 'my/project', branch: 'master' } }
end
it { is_expected.to include_module(Ci::PipelineDelegator) }
it 'has many sourced pipelines' do
expect(bridge).to have_many(:sourced_pipelines)
end
describe '#tags' do
it 'only has a bridge tag' do
expect(bridge.tags).to eq [:bridge]
@ -41,4 +52,222 @@ describe Ci::Bridge do
expect(bridge.scoped_variables_hash.keys).to include(*variables)
end
end
describe '#inherit_status_from_downstream!' do
let(:downstream_pipeline) { build(:ci_pipeline, status: downstream_status) }
before do
bridge.status = 'pending'
create(:ci_sources_pipeline, pipeline: downstream_pipeline, source_job: bridge)
end
subject { bridge.inherit_status_from_downstream!(downstream_pipeline) }
context 'when status is not supported' do
(::Ci::Pipeline::AVAILABLE_STATUSES - ::Ci::Pipeline::COMPLETED_STATUSES).map(&:to_s).each do |status|
context "when status is #{status}" do
let(:downstream_status) { status }
it 'returns false' do
expect(subject).to eq(false)
end
it 'does not change the bridge status' do
expect { subject }.not_to change { bridge.status }.from('pending')
end
end
end
end
context 'when status is supported' do
using RSpec::Parameterized::TableSyntax
where(:downstream_status, :upstream_status) do
[
%w[success success],
*::Ci::Pipeline.completed_statuses.without(:success).map { |status| [status.to_s, 'failed'] }
]
end
with_them do
it 'inherits the downstream status' do
expect { subject }.to change { bridge.status }.from('pending').to(upstream_status)
end
end
end
end
describe '#dependent?' do
subject { bridge.dependent? }
context 'when bridge has strategy depend' do
let(:options) { { trigger: { project: 'my/project', strategy: 'depend' } } }
it { is_expected.to be true }
end
context 'when bridge does not have strategy depend' do
it { is_expected.to be false }
end
end
describe '#yaml_variables' do
it 'returns YAML variables' do
expect(bridge.yaml_variables)
.to include(key: 'BRIDGE', value: 'cross', public: true)
end
end
describe '#downstream_variables' do
it 'returns variables that are going to be passed downstream' do
expect(bridge.downstream_variables)
.to include(key: 'BRIDGE', value: 'cross')
end
context 'when using variables interpolation' do
let(:yaml_variables) do
[
{
key: 'EXPANDED',
value: '$BRIDGE-bridge',
public: true
},
{
key: 'UPSTREAM_CI_PIPELINE_ID',
value: '$CI_PIPELINE_ID',
public: true
},
{
key: 'UPSTREAM_CI_PIPELINE_URL',
value: '$CI_PIPELINE_URL',
public: true
}
]
end
before do
bridge.yaml_variables.concat(yaml_variables)
end
it 'correctly expands variables with interpolation' do
expanded_values = pipeline
.persisted_variables
.to_hash
.transform_keys { |key| "UPSTREAM_#{key}" }
.map { |key, value| { key: key, value: value } }
.push(key: 'EXPANDED', value: 'cross-bridge')
expect(bridge.downstream_variables)
.to match(a_collection_including(*expanded_values))
end
end
context 'when recursive interpolation has been used' do
before do
bridge.yaml_variables << { key: 'EXPANDED', value: '$EXPANDED', public: true }
end
it 'does not expand variable recursively' do
expect(bridge.downstream_variables)
.to include(key: 'EXPANDED', value: '$EXPANDED')
end
end
end
describe 'metadata support' do
it 'reads YAML variables from metadata' do
expect(bridge.yaml_variables).not_to be_empty
expect(bridge.metadata).to be_a Ci::BuildMetadata
expect(bridge.read_attribute(:yaml_variables)).to be_nil
expect(bridge.metadata.config_variables).to be bridge.yaml_variables
end
it 'reads options from metadata' do
expect(bridge.options).not_to be_empty
expect(bridge.metadata).to be_a Ci::BuildMetadata
expect(bridge.read_attribute(:options)).to be_nil
expect(bridge.metadata.config_options).to be bridge.options
end
end
describe '#triggers_child_pipeline?' do
subject { bridge.triggers_child_pipeline? }
context 'when bridge defines a downstream YAML' do
let(:options) do
{
trigger: {
include: 'path/to/child.yml'
}
}
end
it { is_expected.to be_truthy }
end
context 'when bridge does not define a downstream YAML' do
let(:options) do
{
trigger: {
project: project.full_path
}
}
end
it { is_expected.to be_falsey }
end
end
describe '#yaml_for_downstream' do
subject { bridge.yaml_for_downstream }
context 'when bridge defines a downstream YAML' do
let(:options) do
{
trigger: {
include: 'path/to/child.yml'
}
}
end
let(:yaml) do
<<~EOY
---
include: path/to/child.yml
EOY
end
it { is_expected.to eq yaml }
end
context 'when bridge does not define a downstream YAML' do
let(:options) { {} }
it { is_expected.to be_nil }
end
end
describe '#target_ref' do
context 'when trigger is defined' do
it 'returns a ref name' do
expect(bridge.target_ref).to eq 'master'
end
context 'when using variable expansion' do
let(:options) { { trigger: { project: 'my/project', branch: '$BRIDGE-master' } } }
it 'correctly expands variables' do
expect(bridge.target_ref).to eq('cross-master')
end
end
end
context 'when trigger does not have project defined' do
let(:options) { nil }
it 'returns nil' do
expect(bridge.target_ref).to be_nil
end
end
end
end

View File

@ -0,0 +1,103 @@
# frozen_string_literal: true
require 'spec_helper'
describe PrometheusAlert do
let_it_be(:project) { build(:project) }
let(:metric) { build(:prometheus_metric) }
describe '.distinct_projects' do
let(:project1) { create(:project) }
let(:project2) { create(:project) }
before do
create(:prometheus_alert, project: project1)
create(:prometheus_alert, project: project1)
create(:prometheus_alert, project: project2)
end
subject { described_class.distinct_projects.count }
it 'returns a count of all distinct projects which have an alert' do
expect(subject).to eq(2)
end
end
describe 'operators' do
it 'contains the correct equality operator' do
expect(described_class::OPERATORS_MAP.values).to include('==')
expect(described_class::OPERATORS_MAP.values).not_to include('=')
end
end
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:environment) }
end
describe 'project validations' do
let(:environment) { build(:environment, project: project) }
let(:metric) { build(:prometheus_metric, project: project) }
subject do
build(:prometheus_alert, prometheus_metric: metric, environment: environment, project: project)
end
it { is_expected.to validate_presence_of(:environment) }
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:prometheus_metric) }
context 'when environment and metric belongs same project' do
it { is_expected.to be_valid }
end
context 'when environment belongs to different project' do
let(:environment) { build(:environment) }
it { is_expected.not_to be_valid }
end
context 'when metric belongs to different project' do
let(:metric) { build(:prometheus_metric) }
it { is_expected.not_to be_valid }
end
context 'when metric is common' do
let(:metric) { build(:prometheus_metric, :common) }
it { is_expected.to be_valid }
end
end
describe '#full_query' do
before do
subject.operator = "gt"
subject.threshold = 1
subject.prometheus_metric = metric
end
it 'returns the concatenated query' do
expect(subject.full_query).to eq("#{metric.query} > 1.0")
end
end
describe '#to_param' do
before do
subject.operator = "gt"
subject.threshold = 1
subject.prometheus_metric = metric
end
it 'returns the params of the prometheus alert' do
expect(subject.to_param).to eq(
"alert" => metric.title,
"expr" => "#{metric.query} > 1.0",
"for" => "5m",
"labels" => {
"gitlab" => "hook",
"gitlab_alert_id" => metric.id
})
end
end
end

View File

@ -74,7 +74,7 @@ describe PushEvent do
create(:push_event_payload, event: event4, ref: 'baz', action: :removed)
create(:push_event_payload, event: event5, ref: 'baz', ref_type: :tag)
project.repository.create_branch('bar', 'master')
project.repository.create_branch('bar')
create(
:merge_request,
@ -83,7 +83,7 @@ describe PushEvent do
source_branch: 'bar'
)
project.repository.create_branch('qux', 'master')
project.repository.create_branch('qux')
create(
:merge_request,

View File

@ -17,4 +17,37 @@ describe UserCallout do
it { is_expected.to validate_presence_of(:feature_name) }
it { is_expected.to validate_uniqueness_of(:feature_name).scoped_to(:user_id).ignoring_case_sensitivity }
end
describe 'scopes' do
describe '.with_feature_name' do
let(:second_feature_name) { described_class.feature_names.keys.second }
let(:last_feature_name) { described_class.feature_names.keys.last }
it 'returns callout for requested feature name only' do
callout1 = create(:user_callout, feature_name: second_feature_name )
create(:user_callout, feature_name: last_feature_name )
callouts = described_class.with_feature_name(second_feature_name)
expect(callouts).to match_array([callout1])
end
end
describe '.with_dismissed_after' do
let(:some_feature_name) { described_class.feature_names.keys.second }
let(:callout_dismissed_month_ago) { create(:user_callout, feature_name: some_feature_name, dismissed_at: 1.month.ago )}
it 'does not return callouts dismissed before specified date' do
callouts = described_class.with_dismissed_after(15.days.ago)
expect(callouts).to match_array([])
end
it 'returns callouts dismissed after specified date' do
callouts = described_class.with_dismissed_after(2.months.ago)
expect(callouts).to match_array([callout_dismissed_month_ago])
end
end
end
end

View File

@ -4157,6 +4157,40 @@ describe User, :do_not_mock_admin_mode do
end
end
describe '#dismissed_callout?' do
subject(:user) { create(:user) }
let(:feature_name) { UserCallout.feature_names.keys.first }
context 'when no callout dismissal record exists' do
it 'returns false when no ignore_dismissal_earlier_than provided' do
expect(user.dismissed_callout?(feature_name: feature_name)).to eq false
end
it 'returns false when ignore_dismissal_earlier_than provided' do
expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 3.months.ago)).to eq false
end
end
context 'when dismissed callout exists' do
before do
create(:user_callout, user: user, feature_name: feature_name, dismissed_at: 4.months.ago)
end
it 'returns true when no ignore_dismissal_earlier_than provided' do
expect(user.dismissed_callout?(feature_name: feature_name)).to eq true
end
it 'returns true when ignore_dismissal_earlier_than is earlier than dismissed_at' do
expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 6.months.ago)).to eq true
end
it 'returns false when ignore_dismissal_earlier_than is later than dismissed_at' do
expect(user.dismissed_callout?(feature_name: feature_name, ignore_dismissal_earlier_than: 3.months.ago)).to eq false
end
end
end
describe 'bots & humans' do
it 'returns corresponding users' do
human = create(:user)

View File

@ -16,7 +16,7 @@ shared_examples 'project import rate limiter' do
post :create, params: {}
expect(flash[:alert]).to eq('This endpoint has been requested too many times. Try again later.')
expect(response).to have_gitlab_http_status(302)
expect(response).to have_gitlab_http_status(:found)
end
end
end

View File

@ -41,7 +41,7 @@ module ApiHelpers
end
def expect_paginated_array_response(items)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.map { |item| item['id'] }).to eq(Array(items))

View File

@ -28,6 +28,6 @@ module RackAttackSpecHelpers
def expect_rejection(&block)
yield
expect(response).to have_http_status(429)
expect(response).to have_gitlab_http_status(:too_many_requests)
end
end

View File

@ -2,7 +2,7 @@
require 'rake_helper'
describe 'gitlab:seed:group_seed rake task', :sidekiq do
describe 'gitlab:seed:group_seed rake task' do
let(:username) { 'group_seed' }
let!(:user) { create(:user, username: username) }
let(:task_params) { [2, username] }