Commit c77fda90 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent e0fa0638
...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus: ...@@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*' - 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb' - 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb' - 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-o]*.rb' - 'spec/requests/api/[a-p]*.rb'
- 'ee/spec/requests/api/[a-o]*.rb' - 'ee/spec/requests/api/[a-p]*.rb'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
......
---
title: Add package_type as a filter option to the packages list API endpoint
merge_request: 25816
author:
type: added
---
title: Allow 0 to be set for pages maximum size per project/group to indicate unlimited
size
merge_request: 25677
author:
type: fixed
...@@ -20,38 +20,6 @@ unless Gitlab::Runtime.sidekiq? ...@@ -20,38 +20,6 @@ unless Gitlab::Runtime.sidekiq?
config.lograge.ignore_actions = ['Gitlab::RequestForgeryProtection::Controller#index'] config.lograge.ignore_actions = ['Gitlab::RequestForgeryProtection::Controller#index']
# Add request parameters to log output # Add request parameters to log output
config.lograge.custom_options = lambda do |event| config.lograge.custom_options = Gitlab::Lograge::CustomOptions
params = event.payload[:params]
.except(*%w(controller action format))
.each_pair
.map { |k, v| { key: k, value: v } }
payload = {
time: Time.now.utc.iso8601(3),
params: Gitlab::Utils::LogLimitedArray.log_limited_array(params, sentinel: { key: 'truncated', value: '...' }),
remote_ip: event.payload[:remote_ip],
user_id: event.payload[:user_id],
username: event.payload[:username],
ua: event.payload[:ua],
queue_duration: event.payload[:queue_duration]
}
::Gitlab::InstrumentationHelper.add_instrumentation_data(payload)
payload[:response] = event.payload[:response] if event.payload[:response]
payload[:etag_route] = event.payload[:etag_route] if event.payload[:etag_route]
payload[Labkit::Correlation::CorrelationId::LOG_KEY] = Labkit::Correlation::CorrelationId.current_id
if cpu_s = Gitlab::Metrics::System.thread_cpu_duration(::Gitlab::RequestContext.instance.start_thread_cpu_time)
payload[:cpu_s] = cpu_s
end
# https://github.com/roidrage/lograge#logging-errors--exceptions
exception = event.payload[:exception_object]
::Gitlab::ExceptionLogFormatter.format!(exception, payload)
payload
end
end end
end end
...@@ -9,7 +9,7 @@ class AddPrivilegedToRunner < ActiveRecord::Migration[4.2] ...@@ -9,7 +9,7 @@ class AddPrivilegedToRunner < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :clusters_applications_runners, :privileged, :boolean, default: true, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :clusters_applications_runners, :privileged, :boolean, default: true, allow_null: false
end end
def down def down
......
...@@ -5,7 +5,7 @@ class AddPagesAccessLevelToProjectFeature < ActiveRecord::Migration[4.2] ...@@ -5,7 +5,7 @@ class AddPagesAccessLevelToProjectFeature < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default(:project_features, :pages_access_level, :integer, default: ProjectFeature::PUBLIC, allow_null: false) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:project_features, :pages_access_level, :integer, default: ProjectFeature::PUBLIC, allow_null: false)
change_column_default(:project_features, :pages_access_level, ProjectFeature::ENABLED) change_column_default(:project_features, :pages_access_level, ProjectFeature::ENABLED)
end end
......
...@@ -11,7 +11,7 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2] ...@@ -11,7 +11,7 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2]
add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name) # rubocop:disable Migration/AddLimitToStringColumns add_column :remote_mirrors, :remote_name, :string unless column_exists?(:remote_mirrors, :remote_name) # rubocop:disable Migration/AddLimitToStringColumns
unless column_exists?(:remote_mirrors, :only_protected_branches) unless column_exists?(:remote_mirrors, :only_protected_branches)
add_column_with_default(:remote_mirrors, # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:remote_mirrors,
:only_protected_branches, :only_protected_branches,
:boolean, :boolean,
default: false, default: false,
......
...@@ -10,7 +10,7 @@ class AddDeployStrategyToProjectAutoDevops < ActiveRecord::Migration[4.2] ...@@ -10,7 +10,7 @@ class AddDeployStrategyToProjectAutoDevops < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :project_auto_devops, :deploy_strategy, :integer, default: 0, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :project_auto_devops, :deploy_strategy, :integer, default: 0, allow_null: false
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddCommonToPrometheusMetrics < ActiveRecord::Migration[4.2] ...@@ -8,7 +8,7 @@ class AddCommonToPrometheusMetrics < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:prometheus_metrics, :common, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:prometheus_metrics, :common, :boolean, default: false)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddLegacyAbacToClusterProvidersGcp < ActiveRecord::Migration[4.2] ...@@ -8,7 +8,7 @@ class AddLegacyAbacToClusterProvidersGcp < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:cluster_providers_gcp, :legacy_abac, :boolean, default: true) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:cluster_providers_gcp, :legacy_abac, :boolean, default: true)
end end
def down def down
......
...@@ -9,7 +9,7 @@ class AddClusterTypeToClusters < ActiveRecord::Migration[4.2] ...@@ -9,7 +9,7 @@ class AddClusterTypeToClusters < ActiveRecord::Migration[4.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:clusters, :cluster_type, :smallint, default: PROJECT_CLUSTER_TYPE) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:clusters, :cluster_type, :smallint, default: PROJECT_CLUSTER_TYPE)
end end
def down def down
......
...@@ -12,7 +12,7 @@ class AddMaskedToCiVariables < ActiveRecord::Migration[5.0] ...@@ -12,7 +12,7 @@ class AddMaskedToCiVariables < ActiveRecord::Migration[5.0]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false
end end
def down def down
......
...@@ -12,7 +12,7 @@ class AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0] ...@@ -12,7 +12,7 @@ class AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddEmailHeaderAndFooterEnabledFlagToAppearancesTable < ActiveRecord::Migra ...@@ -8,7 +8,7 @@ class AddEmailHeaderAndFooterEnabledFlagToAppearancesTable < ActiveRecord::Migra
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default(:appearances, :email_header_and_footer_enabled, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:appearances, :email_header_and_footer_enabled, :boolean, default: false)
end end
def down def down
......
...@@ -8,11 +8,9 @@ class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0] ...@@ -8,11 +8,9 @@ class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false
add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false
add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false
# rubocop:enable Migration/AddColumnWithDefault
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddAutoSslEnabledToPagesDomain < ActiveRecord::Migration[5.0] ...@@ -8,7 +8,7 @@ class AddAutoSslEnabledToPagesDomain < ActiveRecord::Migration[5.0]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :pages_domains, :auto_ssl_enabled, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :pages_domains, :auto_ssl_enabled, :boolean, default: false
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddManagedToCluster < ActiveRecord::Migration[5.0] ...@@ -8,7 +8,7 @@ class AddManagedToCluster < ActiveRecord::Migration[5.0]
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default(:clusters, :managed, :boolean, default: true) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:clusters, :managed, :boolean, default: true)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddVariableTypeToCiVariables < ActiveRecord::Migration[5.0] ...@@ -8,7 +8,7 @@ class AddVariableTypeToCiVariables < ActiveRecord::Migration[5.0]
ENV_VAR_VARIABLE_TYPE = 1 ENV_VAR_VARIABLE_TYPE = 1
def up def up
add_column_with_default(:ci_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:ci_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE)
end end
def down def down
......
...@@ -8,12 +8,10 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1] ...@@ -8,12 +8,10 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
# rubocop:disable Migration/UpdateLargeTable # rubocop:disable Migration/UpdateLargeTable
# rubocop:disable Migration/AddColumnWithDefault
def up def up
add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false
end end
# rubocop:enable Migration/UpdateLargeTable # rubocop:enable Migration/UpdateLargeTable
# rubocop:enable Migration/AddColumnWithDefault
def down def down
remove_column :project_ci_cd_settings, :merge_trains_enabled remove_column :project_ci_cd_settings, :merge_trains_enabled
......
...@@ -8,7 +8,7 @@ class AddVariableTypeToCiGroupVariables < ActiveRecord::Migration[5.0] ...@@ -8,7 +8,7 @@ class AddVariableTypeToCiGroupVariables < ActiveRecord::Migration[5.0]
ENV_VAR_VARIABLE_TYPE = 1 ENV_VAR_VARIABLE_TYPE = 1
def up def up
add_column_with_default(:ci_group_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:ci_group_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddVariableTypeToCiPipelineScheduleVariables < ActiveRecord::Migration[5.0 ...@@ -8,7 +8,7 @@ class AddVariableTypeToCiPipelineScheduleVariables < ActiveRecord::Migration[5.0
ENV_VAR_VARIABLE_TYPE = 1 ENV_VAR_VARIABLE_TYPE = 1
def up def up
add_column_with_default(:ci_pipeline_schedule_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:ci_pipeline_schedule_variables, :variable_type, :smallint, default: ENV_VAR_VARIABLE_TYPE)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0] ...@@ -8,7 +8,7 @@ class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:services, :deployment_events, :boolean, default: false, allow_null: false) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:services, :deployment_events, :boolean, default: false, allow_null: false)
end end
def down def down
......
...@@ -12,7 +12,7 @@ class AddRuleTypeToApprovalMergeRequestApprovalRules < ActiveRecord::Migration[5 ...@@ -12,7 +12,7 @@ class AddRuleTypeToApprovalMergeRequestApprovalRules < ActiveRecord::Migration[5
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:approval_merge_request_rules, :rule_type, :integer, limit: 2, default: 1) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:approval_merge_request_rules, :rule_type, :integer, limit: 2, default: 1)
end end
def down def down
......
...@@ -12,7 +12,7 @@ class AddSourceToPagesDomains < ActiveRecord::Migration[5.1] ...@@ -12,7 +12,7 @@ class AddSourceToPagesDomains < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:pages_domains, :certificate_source, :smallint, default: 0) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:pages_domains, :certificate_source, :smallint, default: 0)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddStrategiesToOperationsFeatureFlagScopes < ActiveRecord::Migration[5.1] ...@@ -8,7 +8,7 @@ class AddStrategiesToOperationsFeatureFlagScopes < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :operations_feature_flag_scopes, :strategies, :jsonb, default: [{ name: "default", parameters: {} }] # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :operations_feature_flag_scopes, :strategies, :jsonb, default: [{ name: "default", parameters: {} }]
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddRuleTypeToApprovalProjectRules < ActiveRecord::Migration[5.1] ...@@ -8,7 +8,7 @@ class AddRuleTypeToApprovalProjectRules < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :approval_project_rules, :rule_type, :integer, limit: 2, default: 0, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :approval_project_rules, :rule_type, :integer, limit: 2, default: 0, allow_null: false
end end
def down def down
......
...@@ -11,7 +11,7 @@ class AddNamespacePerEnvironmentFlagToClusters < ActiveRecord::Migration[5.1] ...@@ -11,7 +11,7 @@ class AddNamespacePerEnvironmentFlagToClusters < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :clusters, :namespace_per_environment, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :clusters, :namespace_per_environment, :boolean, default: false
end end
def down def down
......
...@@ -12,7 +12,7 @@ class AddObjectStorageFlagToGeoNode < ActiveRecord::Migration[5.2] ...@@ -12,7 +12,7 @@ class AddObjectStorageFlagToGeoNode < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :geo_nodes, :sync_object_storage, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :geo_nodes, :sync_object_storage, :boolean, default: false
end end
def down def down
......
...@@ -9,7 +9,7 @@ class AddMergeRequestsRequireCodeOwnerApprovalToProtectedBranches < ActiveRecord ...@@ -9,7 +9,7 @@ class AddMergeRequestsRequireCodeOwnerApprovalToProtectedBranches < ActiveRecord
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:protected_branches, :protected_branches,
:code_owner_approval_required, :code_owner_approval_required,
:boolean, :boolean,
......
...@@ -8,7 +8,7 @@ class AddActiveJobsLimitToPlans < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddActiveJobsLimitToPlans < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :plans, :active_jobs_limit, :integer, default: 0 # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :plans, :active_jobs_limit, :integer, default: 0
end end
def down def down
......
...@@ -7,7 +7,7 @@ class AddMaxIssueCountToList < ActiveRecord::Migration[4.2] ...@@ -7,7 +7,7 @@ class AddMaxIssueCountToList < ActiveRecord::Migration[4.2]
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default :lists, :max_issue_count, :integer, default: 0 # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :lists, :max_issue_count, :integer, default: 0
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddCloudRunToClustersProvidersGcp < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddCloudRunToClustersProvidersGcp < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:cluster_providers_gcp, :cloud_run, :boolean, default: false) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:cluster_providers_gcp, :cloud_run, :boolean, default: false)
end end
def down def down
......
...@@ -11,7 +11,7 @@ class AddShowWhitespaceInDiffsToUserPreferences < ActiveRecord::Migration[5.2] ...@@ -11,7 +11,7 @@ class AddShowWhitespaceInDiffsToUserPreferences < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :user_preferences, :show_whitespace_in_diffs, :boolean, default: true, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :user_preferences, :show_whitespace_in_diffs, :boolean, default: true, allow_null: false
end end
def down def down
......
...@@ -9,7 +9,7 @@ class AddCleanupStatusToCluster < ActiveRecord::Migration[5.2] ...@@ -9,7 +9,7 @@ class AddCleanupStatusToCluster < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:clusters, :cleanup_status, # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:clusters, :cleanup_status,
:smallint, :smallint,
default: 1, default: 1,
allow_null: false) allow_null: false)
......
...@@ -8,7 +8,7 @@ class AddExpireNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migra ...@@ -8,7 +8,7 @@ class AddExpireNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migra
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :personal_access_tokens, :expire_notification_delivered, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :personal_access_tokens, :expire_notification_delivered, :boolean, default: false
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddCommentActionsToServices < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddCommentActionsToServices < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:services, :comment_on_event_enabled, :boolean, default: true) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:services, :comment_on_event_enabled, :boolean, default: true)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddMaxIssueWeightToList < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddMaxIssueWeightToList < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default :lists, :max_issue_weight, :integer, default: 0 # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :lists, :max_issue_weight, :integer, default: 0
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddEnabledToGrafanaIntegrations < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddEnabledToGrafanaIntegrations < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:grafana_integrations, :grafana_integrations,
:enabled, :enabled,
:boolean, :boolean,
......
...@@ -9,7 +9,7 @@ class AddSecretToSnippet < ActiveRecord::Migration[5.2] ...@@ -9,7 +9,7 @@ class AddSecretToSnippet < ActiveRecord::Migration[5.2]
def up def up
unless column_exists?(:snippets, :secret) unless column_exists?(:snippets, :secret)
add_column_with_default :snippets, :secret, :boolean, default: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :snippets, :secret, :boolean, default: false
end end
add_concurrent_index :snippets, [:visibility_level, :secret] add_concurrent_index :snippets, [:visibility_level, :secret]
......
...@@ -9,7 +9,7 @@ class AddStateToMergeTrains < ActiveRecord::Migration[5.2] ...@@ -9,7 +9,7 @@ class AddStateToMergeTrains < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :merge_trains, :status, :integer, limit: 2, default: MERGE_TRAIN_STATUS_CREATED # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :merge_trains, :status, :integer, limit: 2, default: MERGE_TRAIN_STATUS_CREATED
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddArtifactsToCiBuildNeed < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddArtifactsToCiBuildNeed < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:ci_build_needs, :artifacts, # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:ci_build_needs, :artifacts,
:boolean, :boolean,
default: true, default: true,
allow_null: false) allow_null: false)
......
...@@ -8,7 +8,7 @@ class AddIssueLinksType < ActiveRecord::Migration[5.1] ...@@ -8,7 +8,7 @@ class AddIssueLinksType < ActiveRecord::Migration[5.1]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :issue_links, :link_type, :integer, default: 0, limit: 2 # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :issue_links, :link_type, :integer, default: 0, limit: 2
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:oauth_applications, :oauth_applications,
:confidential, :confidential,
:boolean, :boolean,
......
...@@ -9,10 +9,8 @@ class AddWildcardAndDomainTypeToPagesDomains < ActiveRecord::Migration[5.2] ...@@ -9,10 +9,8 @@ class AddWildcardAndDomainTypeToPagesDomains < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
# rubocop:disable Migration/AddColumnWithDefault
add_column_with_default :pages_domains, :wildcard, :boolean, default: false add_column_with_default :pages_domains, :wildcard, :boolean, default: false
add_column_with_default :pages_domains, :domain_type, :integer, limit: 2, default: PROJECT_TYPE add_column_with_default :pages_domains, :domain_type, :integer, limit: 2, default: PROJECT_TYPE
# rubocop:enable Migration/AddColumnWithDefault
end end
def down def down
......
...@@ -10,7 +10,7 @@ class AddBroadcastTypeToBroadcastMessage < ActiveRecord::Migration[5.2] ...@@ -10,7 +10,7 @@ class AddBroadcastTypeToBroadcastMessage < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default(:broadcast_messages, :broadcast_type, :smallint, default: BROADCAST_MESSAGE_BANNER_TYPE) # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(:broadcast_messages, :broadcast_type, :smallint, default: BROADCAST_MESSAGE_BANNER_TYPE)
end end
def down def down
......
...@@ -8,7 +8,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:snippets, :snippets,
:repository_storage, :repository_storage,
:string, :string,
......
...@@ -8,7 +8,7 @@ class AddStorageVersionToSnippets < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddStorageVersionToSnippets < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:snippets, :snippets,
:storage_version, :storage_version,
:integer, :integer,
......
...@@ -8,7 +8,7 @@ class AddDeployTokenTypeToDeployTokens < ActiveRecord::Migration[5.2] ...@@ -8,7 +8,7 @@ class AddDeployTokenTypeToDeployTokens < ActiveRecord::Migration[5.2]
DOWNTIME = false DOWNTIME = false
def up def up
add_column_with_default :deploy_tokens, :deploy_token_type, :integer, default: 2, limit: 2, allow_null: false # rubocop: disable Migration/AddColumnWithDefault add_column_with_default :deploy_tokens, :deploy_token_type, :integer, default: 2, limit: 2, allow_null: false
end end
def down def down
......
...@@ -9,7 +9,7 @@ class AddUsageToPagesDomains < ActiveRecord::Migration[5.2] ...@@ -9,7 +9,7 @@ class AddUsageToPagesDomains < ActiveRecord::Migration[5.2]
disable_ddl_transaction! disable_ddl_transaction!
def up def up
add_column_with_default :pages_domains, :usage, :integer, limit: 2, default: PAGES_USAGE, allow_null: false # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :pages_domains, :usage, :integer, limit: 2, default: PAGES_USAGE, allow_null: false
end end
def down def down
......
...@@ -12,9 +12,7 @@ class AddVersionToFeatureFlagsTable < ActiveRecord::Migration[6.0] ...@@ -12,9 +12,7 @@ class AddVersionToFeatureFlagsTable < ActiveRecord::Migration[6.0]
def up def up
# The operations_feature_flags table is small enough that we can disable this cop. # The operations_feature_flags table is small enough that we can disable this cop.
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25552#note_291202882 # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25552#note_291202882
# rubocop: disable Migration/AddColumnWithDefault
add_column_with_default(:operations_feature_flags, :version, :smallint, default: FEATURE_FLAG_LEGACY_VERSION, allow_null: false) add_column_with_default(:operations_feature_flags, :version, :smallint, default: FEATURE_FLAG_LEGACY_VERSION, allow_null: false)
# rubocop: enable Migration/AddColumnWithDefault
end end
def down def down
......
...@@ -19,7 +19,7 @@ class RemoveStorageVersionColumnFromSnippets < ActiveRecord::Migration[5.2] ...@@ -19,7 +19,7 @@ class RemoveStorageVersionColumnFromSnippets < ActiveRecord::Migration[5.2]
def down def down
return if column_exists?(:snippets, :storage_version) return if column_exists?(:snippets, :storage_version)
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:snippets, :snippets,
:storage_version, :storage_version,
:integer, :integer,
......
...@@ -16,7 +16,7 @@ class RemoveRepositoryStorageFromSnippets < ActiveRecord::Migration[6.0] ...@@ -16,7 +16,7 @@ class RemoveRepositoryStorageFromSnippets < ActiveRecord::Migration[6.0]
def down def down
return if column_exists?(:snippets, :repository_storage) return if column_exists?(:snippets, :repository_storage)
add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault add_column_with_default(
:snippets, :snippets,
:repository_storage, :repository_storage,
:string, :string,
......
# GitLab self monitoring project # GitLab self monitoring project
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/32351) behind a disabled feature flag (`self_monitoring_project`) in GitLab 12.7. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/32351) in GitLab 12.7, behind a disabled feature flag (`self_monitoring_project`).
> - The feature flag was removed and the Self Monitoring Project was [made generally available](https://gitlab.com/gitlab-org/gitlab/issues/198511) in GitLab 12.8. > - The feature flag was removed and the Self Monitoring Project was [made generally available](https://gitlab.com/gitlab-org/gitlab/issues/198511) in GitLab 12.8.
GitLab has been adding the ability for administrators to see insights into the health of GitLab has been adding the ability for administrators to see insights into the health of
......
...@@ -8,8 +8,8 @@ This is the API docs of [GitLab Packages](../administration/packages/index.md). ...@@ -8,8 +8,8 @@ This is the API docs of [GitLab Packages](../administration/packages/index.md).
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/9259) in GitLab 11.8. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/9259) in GitLab 11.8.
Get a list of project packages. Both Maven and NPM packages are included in results. Get a list of project packages. All package types are included in results. When
When accessed without authentication, only packages of public projects are returned. accessed without authentication, only packages of public projects are returned.
``` ```
GET /projects/:id/packages GET /projects/:id/packages
...@@ -20,6 +20,7 @@ GET /projects/:id/packages ...@@ -20,6 +20,7 @@ GET /projects/:id/packages
| `id` | integer/string | yes | ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) | | `id` | integer/string | yes | ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) |
| `order_by`| string | no | The field to use as order. One of `created_at` (default), `name`, `version`, or `type`. | | `order_by`| string | no | The field to use as order. One of `created_at` (default), `name`, `version`, or `type`. |
| `sort` | string | no | The direction of the order, either `asc` (default) for ascending order or `desc` for descending order. | | `sort` | string | no | The direction of the order, either `asc` (default) for ascending order or `desc` for descending order. |
| `package_type` | string | no | Filter the returned packages by type. One of `conan`, `maven`, `npm` or `nuget`. (_Introduced in GitLab 12.9_)
```shell ```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/packages curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/packages
......
This diff is collapsed.
...@@ -89,6 +89,21 @@ be possible to downgrade in case of a vulnerability or bugs. ...@@ -89,6 +89,21 @@ be possible to downgrade in case of a vulnerability or bugs.
In your migration, add a comment describing how the reversibility of the In your migration, add a comment describing how the reversibility of the
migration was tested. migration was tested.
Some migrations cannot be reversed. For example, some data migrations can't be
reversed because we lose information about the state of the database before the migration.
You should still create a `down` method with a comment, explaining why
the changes performed by the `up` method can't be reversed, so that the
migration itself can be reversed, even if the changes performed during the migration
can't be reversed:
```ruby
def down
# no-op
# comment explaining why changes performed by `up` cannot be reversed.
end
```
## Atomicity ## Atomicity
By default, migrations are single transaction. That is, a transaction is opened By default, migrations are single transaction. That is, a transaction is opened
......
...@@ -71,8 +71,8 @@ in the table below. ...@@ -71,8 +71,8 @@ in the table below.
| Field | Description | | Field | Description |
| ----- | ----------- | | ----- | ----------- |
| `Web URL` | The base URL to the Jira instance web interface which is being linked to this GitLab project. E.g., `https://Jira.example.com`. | | `Web URL` | The base URL to the Jira instance web interface which is being linked to this GitLab project. E.g., `https://jira.example.com`. |
| `Jira API URL` | The base URL to the Jira instance API. Web URL value will be used if not set. E.g., `https://jira-api.example.com`. | | `Jira API URL` | The base URL to the Jira instance API. Web URL value will be used if not set. E.g., `https://jira-api.example.com`. Leave this field blank (or use the same value of `Web URL`) if using **Jira Cloud**. |
| `Username/Email` | Created when [configuring Jira step](#configuring-jira). Use `username` for **Jira Server** or `email` for **Jira Cloud**. | | `Username/Email` | Created when [configuring Jira step](#configuring-jira). Use `username` for **Jira Server** or `email` for **Jira Cloud**. |
| `Password/API token` |Created in [configuring Jira step](#configuring-jira). Use `password` for **Jira Server** or `API token` for **Jira Cloud**. | | `Password/API token` |Created in [configuring Jira step](#configuring-jira). Use `password` for **Jira Server** or `API token` for **Jira Cloud**. |
| `Transition ID` | This is the ID of a transition that moves issues to the desired state. It is possible to insert transition ids separated by `,` or `;` which means the issue will be moved to each state after another using the given order. **Closing Jira issues via commits or Merge Requests won't work if you don't set the ID correctly.** | | `Transition ID` | This is the ID of a transition that moves issues to the desired state. It is possible to insert transition ids separated by `,` or `;` which means the issue will be moved to each state after another using the given order. **Closing Jira issues via commits or Merge Requests won't work if you don't set the ID correctly.** |
......
...@@ -191,7 +191,7 @@ For example: ...@@ -191,7 +191,7 @@ For example:
metrics: metrics:
- id: metric_of_ages - id: metric_of_ages
query_range: 'http_requests_total' query_range: 'http_requests_total'
label: "Metric of Ages" label: "Instance: {{instance}}, method: {{method}}"
unit: "count" unit: "count"
``` ```
...@@ -267,10 +267,56 @@ The following tables outline the details of expected properties. ...@@ -267,10 +267,56 @@ The following tables outline the details of expected properties.
| ------ | ------ | ------ | ------ | | ------ | ------ | ------ | ------ |
| `id` | string | no | Used for associating dashboard metrics with database records. Must be unique across dashboard configuration files. Required for [alerting](#setting-up-alerts-for-prometheus-metrics-ultimate) (support not yet enabled, see [relevant issue](https://gitlab.com/gitlab-org/gitlab-foss/issues/60319)). | | `id` | string | no | Used for associating dashboard metrics with database records. Must be unique across dashboard configuration files. Required for [alerting](#setting-up-alerts-for-prometheus-metrics-ultimate) (support not yet enabled, see [relevant issue](https://gitlab.com/gitlab-org/gitlab-foss/issues/60319)). |
| `unit` | string | yes | Defines the unit of the query's return data. | | `unit` | string | yes | Defines the unit of the query's return data. |
| `label` | string | no, but highly encouraged | Defines the legend-label for the query. Should be unique within the panel's metrics. | | `label` | string | no, but highly encouraged | Defines the legend-label for the query. Should be unique within the panel's metrics. Can contain time series labels as interpolated variables. |
| `query` | string | yes if `query_range` is not defined | Defines the Prometheus query to be used to populate the chart/panel. If defined, the `query` endpoint of the [Prometheus API](https://prometheus.io/docs/prometheus/latest/querying/api/) will be utilized. | | `query` | string | yes if `query_range` is not defined | Defines the Prometheus query to be used to populate the chart/panel. If defined, the `query` endpoint of the [Prometheus API](https://prometheus.io/docs/prometheus/latest/querying/api/) will be utilized. |
| `query_range` | string | yes if `query` is not defined | Defines the Prometheus query to be used to populate the chart/panel. If defined, the `query_range` endpoint of the [Prometheus API](https://prometheus.io/docs/prometheus/latest/querying/api/) will be utilized. | | `query_range` | string | yes if `query` is not defined | Defines the Prometheus query to be used to populate the chart/panel. If defined, the `query_range` endpoint of the [Prometheus API](https://prometheus.io/docs/prometheus/latest/querying/api/) will be utilized. |
##### Dynamic labels
Dynamic labels are useful when multiple time series are returned from a Prometheus query.
When a static label is used and a query returns multiple time series, then all the legend items will be labeled the same, which makes identifying each time series difficult:
```yaml
metrics:
- id: metric_of_ages
query_range: 'http_requests_total'
label: "Time Series"
unit: "count"
```
This may render a legend like this:
![repeated legend label chart](img/prometheus_dashboard_repeated_label.png)
For labels to be more explicit, using variables that reflect time series labels is a good practice. The variables will be replaced by the values of the time series labels when the legend is rendered:
```yaml
metrics:
- id: metric_of_ages
query_range: 'http_requests_total'
label: "Instance: {{instance}}, method: {{method}}"
unit: "count"
```
The resulting rendered legend will look like this:
![legend with label variables](img/prometheus_dashboard_label_variables.png)
There is also a shorthand value for dynamic dashboard labels that make use of only one time series label:
```yaml
metrics:
- id: metric_of_ages
query_range: 'http_requests_total'
label: "Method"
unit: "count"
```
This will render into:
![legend with label shorthand variable](img/prometheus_dashboard_label_variable_shorthand.png)
#### Panel types for dashboards #### Panel types for dashboards
The below panel types are supported in monitoring dashboards. The below panel types are supported in monitoring dashboards.
...@@ -290,7 +336,7 @@ panel_groups: ...@@ -290,7 +336,7 @@ panel_groups:
metrics: metrics:
- id: area_http_requests_total - id: area_http_requests_total
query_range: 'http_requests_total' query_range: 'http_requests_total'
label: "Metric of Ages" label: "Instance: {{instance}}, Method: {{method}}"
unit: "count" unit: "count"
``` ```
......
...@@ -70,7 +70,7 @@ module Gitlab ...@@ -70,7 +70,7 @@ module Gitlab
# Lookup for rugged object by oid or ref name # Lookup for rugged object by oid or ref name
def lookup(oid_or_ref_name) def lookup(oid_or_ref_name)
rugged.rev_parse(oid_or_ref_name) rev_parse_target(oid_or_ref_name)
end end
end end
end end
......
...@@ -6,6 +6,8 @@ module Gitlab ...@@ -6,6 +6,8 @@ module Gitlab
class LogrageWithTimestamp class LogrageWithTimestamp
include Gitlab::EncodingHelper include Gitlab::EncodingHelper
EMPTY_ARRAY = [].freeze
def call(severity, datetime, _, data) def call(severity, datetime, _, data)
time = data.delete :time time = data.delete :time
data[:params] = process_params(data) data[:params] = process_params(data)
...@@ -16,30 +18,27 @@ module Gitlab ...@@ -16,30 +18,27 @@ module Gitlab
duration: time[:total], duration: time[:total],
db: time[:db], db: time[:db],
view: time[:view] view: time[:view]
}.merge(data) }.merge!(data)
::Lograge.formatter.call(attributes) + "\n"
::Lograge.formatter.call(attributes) << "\n"
end end
private private
def process_params(data) def process_params(data)
return [] unless data.has_key?(:params) return EMPTY_ARRAY unless data.has_key?(:params)
params_array = params_array = data[:params].map { |k, v| { key: k, value: utf8_encode_values(v) } }
data[:params]
.each_pair
.map { |k, v| { key: k, value: utf8_encode_values(v) } }
Gitlab::Utils::LogLimitedArray.log_limited_array(params_array, Gitlab::Utils::LogLimitedArray.log_limited_array(params_array, sentinel: Gitlab::Lograge::CustomOptions::LIMITED_ARRAY_SENTINEL)
sentinel: { key: 'truncated', value: '...' })
end end
def utf8_encode_values(data) def utf8_encode_values(data)
case data case data
when Hash when Hash
data.merge(data) { |k, v| utf8_encode_values(v) } data.merge!(data) { |k, v| utf8_encode_values(v) }
when Array when Array
data.map { |v| utf8_encode_values(v) } data.map! { |v| utf8_encode_values(v) }
when String when String
encode_utf8(data) encode_utf8(data)
end end
......
# frozen_string_literal: true
module Gitlab
module Lograge
module CustomOptions
LIMITED_ARRAY_SENTINEL = { key: 'truncated', value: '...' }.freeze
IGNORE_PARAMS = Set.new(%w(controller action format)).freeze
def self.call(event)
params = event
.payload[:params]
.each_with_object([]) { |(k, v), array| array << { key: k, value: v } unless IGNORE_PARAMS.include?(k) }
payload = {
time: Time.now.utc.iso8601(3),
params: Gitlab::Utils::LogLimitedArray.log_limited_array(params, sentinel: LIMITED_ARRAY_SENTINEL),
remote_ip: event.payload[:remote_ip],
user_id: event.payload[:user_id],
username: event.payload[:username],
ua: event.payload[:ua],
queue_duration: event.payload[:queue_duration]
}
::Gitlab::InstrumentationHelper.add_instrumentation_data(payload)
payload[:response] = event.payload[:response] if event.payload[:response]
payload[:etag_route] = event.payload[:etag_route] if event.payload[:etag_route]
payload[Labkit::Correlation::CorrelationId::LOG_KEY] = Labkit::Correlation::CorrelationId.current_id
if cpu_s = Gitlab::Metrics::System.thread_cpu_duration(::Gitlab::RequestContext.instance.start_thread_cpu_time)
payload[:cpu_s] = cpu_s
end
# https://github.com/roidrage/lograge#logging-errors--exceptions
exception = event.payload[:exception_object]
::Gitlab::ExceptionLogFormatter.format!(exception, payload)
payload
end
end
end
end
...@@ -10,7 +10,37 @@ module RuboCop ...@@ -10,7 +10,37 @@ module RuboCop
class AddColumnWithDefault < RuboCop::Cop::Cop class AddColumnWithDefault < RuboCop::Cop::Cop
include MigrationHelpers include MigrationHelpers
WHITELISTED_TABLES = [:application_settings].freeze # Tables >= 10 GB on GitLab.com as of 02/2020
BLACKLISTED_TABLES = %i[
audit_events
ci_build_trace_sections
ci_builds
ci_builds_metadata
ci_job_artifacts
ci_pipeline_variables
ci_pipelines
ci_stages
deployments
events
issues
merge_request_diff_commits
merge_request_diff_files
merge_request_diffs
merge_request_metrics
merge_requests
note_diff_files
notes
project_authorizations
projects
push_event_payloads
resource_label_events
sent_notifications
system_note_metadata
taggings
todos
users
web_hook_logs
].freeze
MSG = '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, ' \ MSG = '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, ' \
'see https://gitlab.com/gitlab-org/gitlab/issues/38060'.freeze 'see https://gitlab.com/gitlab-org/gitlab/issues/38060'.freeze
...@@ -23,21 +53,23 @@ module RuboCop ...@@ -23,21 +53,23 @@ module RuboCop
return unless in_migration?(node) return unless in_migration?(node)
add_column_with_default?(node) do |table, options| add_column_with_default?(node) do |table, options|
break if table_whitelisted?(table) || nulls_allowed?(options) add_offense(node, location: :selector) if offensive?(table, options)
add_offense(node, location: :selector)
end end
end end
private private
def offensive?(table, options)
table_blacklisted?(table) && !nulls_allowed?(options)
end
def nulls_allowed?(options) def nulls_allowed?(options)
options.find { |opt| opt.key.value == :allow_null && opt.value.true_type? } options.find { |opt| opt.key.value == :allow_null && opt.value.true_type? }
end end
def table_whitelisted?(symbol) def table_blacklisted?(symbol)
symbol && symbol.type == :sym && symbol && symbol.type == :sym &&
WHITELISTED_TABLES.include?(symbol.children[0]) BLACKLISTED_TABLES.include?(symbol.children[0])
end end
end end
end end
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do
let(:log_entry) do
{
status: 200,
time: {
total: 758.58,
db: 77.06,
view: 681.52
},
method: 'PUT',
path: '/api/v4/projects/1',
params: {
'description': '[FILTERED]',
'name': 'gitlab test'
},
host: 'localhost',
remote_ip: '127.0.0.1',
ua: 'curl/7.66.0',
route: '/api/:version/projects/:id',
user_id: 1,
username: 'root',
queue_duration: 1764.06,
gitaly_calls: 6,
gitaly_duration: 20.0,
correlation_id: 'WMefXn60429'
}
end
let(:time) { Time.now }
let(:result) { JSON.parse(subject) }
subject { described_class.new.call(:info, time, nil, log_entry) }
it 'turns the log entry to valid JSON' do
expect(result['status']).to eq(200)
end
it 're-formats the params hash' do
params = result['params']
expect(params).to eq([
{ 'key' => 'description', 'value' => '[FILTERED]' },
{ 'key' => 'name', 'value' => 'gitlab test' }
])
end
end
...@@ -2381,7 +2381,7 @@ describe Repository do ...@@ -2381,7 +2381,7 @@ describe Repository do
end end
end end
describe '#tree' do shared_examples '#tree' do
context 'using a non-existing repository' do context 'using a non-existing repository' do
before do before do
allow(repository).to receive(:head_commit).and_return(nil) allow(repository).to receive(:head_commit).and_return(nil)
...@@ -2399,10 +2399,17 @@ describe Repository do ...@@ -2399,10 +2399,17 @@ describe Repository do
context 'using an existing repository' do context 'using an existing repository' do
it 'returns a Tree' do it 'returns a Tree' do
expect(repository.tree(:head)).to be_an_instance_of(Tree) expect(repository.tree(:head)).to be_an_instance_of(Tree)
expect(repository.tree('v1.1.1')).to be_an_instance_of(Tree)
end end
end end
end end
it_behaves_like '#tree'
describe '#tree? with Rugged enabled', :enable_rugged do
it_behaves_like '#tree'
end
describe '#size' do describe '#size' do
context 'with a non-existing repository' do context 'with a non-existing repository' do
it 'returns 0' do it 'returns 0' do
......
This diff is collapsed.
...@@ -289,7 +289,7 @@ describe API::PipelineSchedules do ...@@ -289,7 +289,7 @@ describe API::PipelineSchedules do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer) delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer)
end.to change { project.pipeline_schedules.count }.by(-1) end.to change { project.pipeline_schedules.count }.by(-1)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ describe API::ProjectClusters do ...@@ -26,7 +26,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/projects/#{project.id}/clusters", developer_user) get api("/projects/#{project.id}/clusters", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -36,7 +36,7 @@ describe API::ProjectClusters do ...@@ -36,7 +36,7 @@ describe API::ProjectClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'includes pagination headers' do it 'includes pagination headers' do
...@@ -71,7 +71,7 @@ describe API::ProjectClusters do ...@@ -71,7 +71,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
get api("/projects/#{project.id}/clusters/#{cluster_id}", developer_user) get api("/projects/#{project.id}/clusters/#{cluster_id}", developer_user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -142,7 +142,7 @@ describe API::ProjectClusters do ...@@ -142,7 +142,7 @@ describe API::ProjectClusters do
let(:cluster_id) { 123 } let(:cluster_id) { 123 }
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -175,7 +175,7 @@ describe API::ProjectClusters do ...@@ -175,7 +175,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
post api("/projects/#{project.id}/clusters/user", developer_user), params: cluster_params post api("/projects/#{project.id}/clusters/user", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -186,7 +186,7 @@ describe API::ProjectClusters do ...@@ -186,7 +186,7 @@ describe API::ProjectClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 201' do it 'responds with 201' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'creates a new Cluster::Cluster' do it 'creates a new Cluster::Cluster' do
...@@ -236,7 +236,7 @@ describe API::ProjectClusters do ...@@ -236,7 +236,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' } let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not create a new Clusters::Cluster' do it 'does not create a new Clusters::Cluster' do
...@@ -258,7 +258,7 @@ describe API::ProjectClusters do ...@@ -258,7 +258,7 @@ describe API::ProjectClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters')) expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters'))
end end
...@@ -270,7 +270,7 @@ describe API::ProjectClusters do ...@@ -270,7 +270,7 @@ describe API::ProjectClusters do
end end
it 'responds with 403' do it 'responds with 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -307,7 +307,7 @@ describe API::ProjectClusters do ...@@ -307,7 +307,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
put api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: update_params put api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: update_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -322,7 +322,7 @@ describe API::ProjectClusters do ...@@ -322,7 +322,7 @@ describe API::ProjectClusters do
context 'with valid params' do context 'with valid params' do
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates cluster attributes' do it 'updates cluster attributes' do
...@@ -336,7 +336,7 @@ describe API::ProjectClusters do ...@@ -336,7 +336,7 @@ describe API::ProjectClusters do
let(:namespace) { 'invalid_namespace' } let(:namespace) { 'invalid_namespace' }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'does not update cluster attributes' do it 'does not update cluster attributes' do
...@@ -354,7 +354,7 @@ describe API::ProjectClusters do ...@@ -354,7 +354,7 @@ describe API::ProjectClusters do
let(:management_project_id) { create(:project).id } let(:management_project_id) { create(:project).id }
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation errors' do it 'returns validation errors' do
...@@ -372,7 +372,7 @@ describe API::ProjectClusters do ...@@ -372,7 +372,7 @@ describe API::ProjectClusters do
end end
it 'responds with 400' do it 'responds with 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns validation error' do it 'returns validation error' do
...@@ -384,7 +384,7 @@ describe API::ProjectClusters do ...@@ -384,7 +384,7 @@ describe API::ProjectClusters do
let(:namespace) { 'new-namespace' } let(:namespace) { 'new-namespace' }
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -413,7 +413,7 @@ describe API::ProjectClusters do ...@@ -413,7 +413,7 @@ describe API::ProjectClusters do
end end
it 'responds with 200' do it 'responds with 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'updates platform kubernetes attributes' do it 'updates platform kubernetes attributes' do
...@@ -430,7 +430,7 @@ describe API::ProjectClusters do ...@@ -430,7 +430,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) } let(:cluster) { create(:cluster, :project, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -448,7 +448,7 @@ describe API::ProjectClusters do ...@@ -448,7 +448,7 @@ describe API::ProjectClusters do
it 'responds with 403' do it 'responds with 403' do
delete api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: cluster_params delete api("/projects/#{project.id}/clusters/#{cluster.id}", developer_user), params: cluster_params
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -458,7 +458,7 @@ describe API::ProjectClusters do ...@@ -458,7 +458,7 @@ describe API::ProjectClusters do
end end
it 'responds with 204' do it 'responds with 204' do
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'deletes the cluster' do it 'deletes the cluster' do
...@@ -469,7 +469,7 @@ describe API::ProjectClusters do ...@@ -469,7 +469,7 @@ describe API::ProjectClusters do
let(:cluster) { create(:cluster, :project, :provided_by_user) } let(:cluster) { create(:cluster, :project, :provided_by_user) }
it 'responds with 404' do it 'responds with 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do ...@@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do
stub_exclusive_lease_taken(lease_key, timeout: 1.hour) stub_exclusive_lease_taken(lease_key, timeout: 1.hour)
subject subject
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(response.body).to include('This request has already been made.') expect(response.body).to include('This request has already been made.')
end end
......
...@@ -14,7 +14,7 @@ describe API::ProjectEvents do ...@@ -14,7 +14,7 @@ describe API::ProjectEvents do
it 'returns 404 for private project' do it 'returns 404 for private project' do
get api("/projects/#{private_project.id}/events") get api("/projects/#{private_project.id}/events")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 200 status for a public project' do it 'returns 200 status for a public project' do
...@@ -22,7 +22,7 @@ describe API::ProjectEvents do ...@@ -22,7 +22,7 @@ describe API::ProjectEvents do
get api("/projects/#{public_project.id}/events") get api("/projects/#{public_project.id}/events")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -36,14 +36,14 @@ describe API::ProjectEvents do ...@@ -36,14 +36,14 @@ describe API::ProjectEvents do
it 'returns only accessible events' do it 'returns only accessible events' do
get api("/projects/#{public_project.id}/events", non_member) get api("/projects/#{public_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
end end
it 'returns all events when the user has access' do it 'returns all events when the user has access' do
get api("/projects/#{public_project.id}/events", user) get api("/projects/#{public_project.id}/events", user)
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.size).to eq(2)
end end
end end
...@@ -92,7 +92,7 @@ describe API::ProjectEvents do ...@@ -92,7 +92,7 @@ describe API::ProjectEvents do
it 'returns 404' do it 'returns 404' do
get api("/projects/#{private_project.id}/events", non_member) get api("/projects/#{private_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -100,7 +100,7 @@ describe API::ProjectEvents do ...@@ -100,7 +100,7 @@ describe API::ProjectEvents do
it 'returns project events' do it 'returns project events' do
get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user) get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
...@@ -109,7 +109,7 @@ describe API::ProjectEvents do ...@@ -109,7 +109,7 @@ describe API::ProjectEvents do
it 'returns 404 if project does not exist' do it 'returns 404 if project does not exist' do
get api("/projects/1234/events", user) get api("/projects/1234/events", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when the requesting token does not have "api" scope' do context 'when the requesting token does not have "api" scope' do
...@@ -118,7 +118,7 @@ describe API::ProjectEvents do ...@@ -118,7 +118,7 @@ describe API::ProjectEvents do
it 'returns a "403" response' do it 'returns a "403" response' do
get api("/projects/#{private_project.id}/events", personal_access_token: token) get api("/projects/#{private_project.id}/events", personal_access_token: token)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -142,7 +142,7 @@ describe API::ProjectEvents do ...@@ -142,7 +142,7 @@ describe API::ProjectEvents do
get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request } get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request }
end.not_to exceed_all_query_limit(control_count) end.not_to exceed_all_query_limit(control_count)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.size).to eq(2) expect(json_response.size).to eq(2)
expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id]) expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id])
......
...@@ -55,7 +55,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -55,7 +55,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'prevents requesting project export' do it 'prevents requesting project export' do
request request
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.') expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
end end
end end
...@@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is none' do it 'is none' do
get api(path_none, user) get api(path_none, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('none') expect(json_response['export_status']).to eq('none')
end end
...@@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is started' do it 'is started' do
get api(path_started, user) get api(path_started, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('started') expect(json_response['export_status']).to eq('started')
end end
...@@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is after_export' do it 'is after_export' do
get api(path_after_export, user) get api(path_after_export, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('after_export_action') expect(json_response['export_status']).to eq('after_export_action')
end end
...@@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'is finished' do it 'is finished' do
get api(path_finished, user) get api(path_finished, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/project/export_status') expect(response).to match_response_schema('public_api/v4/project/export_status')
expect(json_response['export_status']).to eq('finished') expect(json_response['export_status']).to eq('finished')
end end
...@@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do it 'downloads' do
get api(download_path_finished, user) get api(download_path_finished, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
it 'downloads' do it 'downloads' do
get api(download_path_export_action, user) get api(download_path_export_action, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' }) post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' })
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
...@@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
end end
...@@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do ...@@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do
expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute) expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute)
post api(path, project.owner), params: params post api(path, project.owner), params: params
expect(response).to have_gitlab_http_status(202) expect(response).to have_gitlab_http_status(:accepted)
end end
end end
end end
......
...@@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns project hooks" do it "returns project hooks" do
get api("/projects/#{project.id}/hooks", user) get api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
...@@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "does not access project hooks" do it "does not access project hooks" do
get api("/projects/#{project.id}/hooks", user3) get api("/projects/#{project.id}/hooks", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a project hook" do it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user) get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['url']).to eq(hook.url) expect(json_response['url']).to eq(hook.url)
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
...@@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 404 error if hook id is not available" do it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user) get api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
context "unauthorized user" do context "unauthorized user" do
it "does not access an existing hook" do it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3) get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -96,7 +96,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -96,7 +96,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' } params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' }
end.to change {project.hooks.count}.by(1) end.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['url']).to eq('http://example.com') expect(json_response['url']).to eq('http://example.com')
expect(json_response['issues_events']).to eq(true) expect(json_response['issues_events']).to eq(true)
expect(json_response['confidential_issues_events']).to eq(true) expect(json_response['confidential_issues_events']).to eq(true)
...@@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token } post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token }
end.to change {project.hooks.count}.by(1) end.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response["url"]).to eq("http://example.com") expect(json_response["url"]).to eq("http://example.com")
expect(json_response).not_to include("token") expect(json_response).not_to include("token")
...@@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns a 400 error if url not given" do it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user) post api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 422 error if url not valid" do it "returns a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" } post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
it "returns a 422 error if branch filter is not valid" do it "returns a 422 error if branch filter is not valid" do
post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' } post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), put api("/projects/#{project.id}/hooks/#{hook.id}", user),
params: { url: 'http://example.org', push_events: false, job_events: true } params: { url: 'http://example.org', push_events: false, job_events: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['url']).to eq('http://example.org') expect(json_response['url']).to eq('http://example.org')
expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['issues_events']).to eq(hook.issues_events)
expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
...@@ -171,7 +171,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -171,7 +171,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token } put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response["url"]).to eq("http://example.org") expect(json_response["url"]).to eq("http://example.org")
expect(json_response).not_to include("token") expect(json_response).not_to include("token")
...@@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do
it "returns 404 error if hook id not found" do it "returns 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' } put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 400 error if url is not given" do it "returns 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user) put api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 422 error if url is not valid" do it "returns a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' } put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect do expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.hooks.count}.by(-1) end.to change {project.hooks.count}.by(-1)
end end
it "returns a 404 error when deleting non existent hook" do it "returns a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user) delete api("/projects/#{project.id}/hooks/42", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 error if hook id not given" do it "returns a 404 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user) delete api("/projects/#{project.id}/hooks", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 if a user attempts to delete project hooks they do not own" do it "returns a 404 if a user attempts to delete project hooks they do not own" do
...@@ -221,7 +221,7 @@ describe API::ProjectHooks, 'ProjectHooks' do ...@@ -221,7 +221,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
other_project.add_maintainer(test_user) other_project.add_maintainer(test_user)
delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(WebHook.exists?(hook.id)).to be_truthy expect(WebHook.exists?(hook.id)).to be_truthy
end end
......
...@@ -30,7 +30,7 @@ describe API::ProjectImport do ...@@ -30,7 +30,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'schedules an import using the namespace path' do it 'schedules an import using the namespace path' do
...@@ -38,7 +38,7 @@ describe API::ProjectImport do ...@@ -38,7 +38,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
context 'when a name is explicitly set' do context 'when a name is explicitly set' do
...@@ -49,7 +49,7 @@ describe API::ProjectImport do ...@@ -49,7 +49,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id, name: expected_name } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id, name: expected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'schedules an import using the namespace path and a different name' do it 'schedules an import using the namespace path and a different name' do
...@@ -57,7 +57,7 @@ describe API::ProjectImport do ...@@ -57,7 +57,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path, name: expected_name } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path, name: expected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'sets name correctly' do it 'sets name correctly' do
...@@ -93,7 +93,7 @@ describe API::ProjectImport do ...@@ -93,7 +93,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) } post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
it 'does not schedule an import for a namespace that does not exist' do it 'does not schedule an import for a namespace that does not exist' do
...@@ -102,7 +102,7 @@ describe API::ProjectImport do ...@@ -102,7 +102,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) } post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Namespace Not Found') expect(json_response['message']).to eq('404 Namespace Not Found')
end end
...@@ -116,7 +116,7 @@ describe API::ProjectImport do ...@@ -116,7 +116,7 @@ describe API::ProjectImport do
namespace: namespace.full_path namespace: namespace.full_path
}) })
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Namespace Not Found') expect(json_response['message']).to eq('404 Namespace Not Found')
end end
...@@ -125,7 +125,7 @@ describe API::ProjectImport do ...@@ -125,7 +125,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' } post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('file is invalid') expect(json_response['error']).to eq('file is invalid')
end end
...@@ -186,7 +186,7 @@ describe API::ProjectImport do ...@@ -186,7 +186,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) } post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Name has already been taken') expect(json_response['message']).to eq('Name has already been taken')
end end
...@@ -196,7 +196,7 @@ describe API::ProjectImport do ...@@ -196,7 +196,7 @@ describe API::ProjectImport do
post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true } post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
end end
end end
end end
...@@ -209,7 +209,7 @@ describe API::ProjectImport do ...@@ -209,7 +209,7 @@ describe API::ProjectImport do
it 'prevents users from importing projects' do it 'prevents users from importing projects' do
post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id } post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.') expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
end end
end end
...@@ -276,7 +276,7 @@ describe API::ProjectImport do ...@@ -276,7 +276,7 @@ describe API::ProjectImport do
get api("/projects/#{project.id}/import", user) get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('import_status' => 'started') expect(json_response).to include('import_status' => 'started')
end end
...@@ -287,7 +287,7 @@ describe API::ProjectImport do ...@@ -287,7 +287,7 @@ describe API::ProjectImport do
get api("/projects/#{project.id}/import", user) get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('import_status' => 'failed', expect(json_response).to include('import_status' => 'failed',
'import_error' => 'error') 'import_error' => 'error')
end end
......
...@@ -27,19 +27,19 @@ describe API::ProjectMilestones do ...@@ -27,19 +27,19 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exists' do it 'returns 404 response when the project does not exists' do
delete api("/projects/0/milestones/#{milestone.id}", user) delete api("/projects/0/milestones/#{milestone.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 response when the milestone does not exists' do it 'returns 404 response when the milestone does not exists' do
delete api("/projects/#{project.id}/milestones/0", user) delete api("/projects/#{project.id}/milestones/0", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 404 from guest user deleting a milestone" do it "returns 404 from guest user deleting a milestone" do
delete api("/projects/#{project.id}/milestones/#{milestone.id}", guest) delete api("/projects/#{project.id}/milestones/#{milestone.id}", guest)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -67,7 +67,7 @@ describe API::ProjectMilestones do ...@@ -67,7 +67,7 @@ describe API::ProjectMilestones do
it 'returns 403' do it 'returns 403' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -79,14 +79,14 @@ describe API::ProjectMilestones do ...@@ -79,14 +79,14 @@ describe API::ProjectMilestones do
it 'returns 200' do it 'returns 200' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(group.milestones.first.title).to eq(milestone.title) expect(group.milestones.first.title).to eq(milestone.title)
end end
it 'returns 200 for closed milestone' do it 'returns 200 for closed milestone' do
post api("/projects/#{project.id}/milestones/#{closed_milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{closed_milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(group.milestones.first.title).to eq(closed_milestone.title) expect(group.milestones.first.title).to eq(closed_milestone.title)
end end
end end
...@@ -99,13 +99,13 @@ describe API::ProjectMilestones do ...@@ -99,13 +99,13 @@ describe API::ProjectMilestones do
it 'returns 404 response when the project does not exist' do it 'returns 404 response when the project does not exist' do
post api("/projects/0/milestones/#{milestone.id}/promote", user) post api("/projects/0/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns 404 response when the milestone does not exist' do it 'returns 404 response when the milestone does not exist' do
post api("/projects/#{project.id}/milestones/0/promote", user) post api("/projects/#{project.id}/milestones/0/promote", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -117,7 +117,7 @@ describe API::ProjectMilestones do ...@@ -117,7 +117,7 @@ describe API::ProjectMilestones do
it 'returns 403' do it 'returns 403' do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user) post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
......
...@@ -34,26 +34,26 @@ describe API::ProjectSnapshots do ...@@ -34,26 +34,26 @@ describe API::ProjectSnapshots do
it 'returns authentication error as project owner' do it 'returns authentication error as project owner' do
get api("/projects/#{project.id}/snapshot", project.owner) get api("/projects/#{project.id}/snapshot", project.owner)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
it 'returns authentication error as unauthenticated user' do it 'returns authentication error as unauthenticated user' do
get api("/projects/#{project.id}/snapshot", nil) get api("/projects/#{project.id}/snapshot", nil)
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'requests project repository raw archive as administrator' do it 'requests project repository raw archive as administrator' do
get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' } get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect_snapshot_response_for(project.repository) expect_snapshot_response_for(project.repository)
end end
it 'requests wiki repository raw archive as administrator' do it 'requests wiki repository raw archive as administrator' do
get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' } get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect_snapshot_response_for(project.wiki.repository) expect_snapshot_response_for(project.wiki.repository)
end end
end end
......
...@@ -14,7 +14,7 @@ describe API::ProjectSnippets do ...@@ -14,7 +14,7 @@ describe API::ProjectSnippets do
it 'exposes known attributes' do it 'exposes known attributes' do
get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin) get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
...@@ -24,13 +24,13 @@ describe API::ProjectSnippets do ...@@ -24,13 +24,13 @@ describe API::ProjectSnippets do
other_project = create(:project) other_project = create(:project)
get api("/projects/#{other_project.id}/snippets/#{snippet.id}/user_agent_detail", admin) get api("/projects/#{other_project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns unauthorized for non-admin users" do it "returns unauthorized for non-admin users" do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user) get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -45,7 +45,7 @@ describe API::ProjectSnippets do ...@@ -45,7 +45,7 @@ describe API::ProjectSnippets do
get api("/projects/#{project.id}/snippets", user) get api("/projects/#{project.id}/snippets", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
...@@ -58,7 +58,7 @@ describe API::ProjectSnippets do ...@@ -58,7 +58,7 @@ describe API::ProjectSnippets do
get api("/projects/#{project.id}/snippets/", user) get api("/projects/#{project.id}/snippets/", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(0) expect(json_response.size).to eq(0)
...@@ -72,7 +72,7 @@ describe API::ProjectSnippets do ...@@ -72,7 +72,7 @@ describe API::ProjectSnippets do
it 'returns snippet json' do it 'returns snippet json' do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user) get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(snippet.title) expect(json_response['title']).to eq(snippet.title)
expect(json_response['description']).to eq(snippet.description) expect(json_response['description']).to eq(snippet.description)
...@@ -82,7 +82,7 @@ describe API::ProjectSnippets do ...@@ -82,7 +82,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
get api("/projects/#{project.id}/snippets/1234", user) get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
end end
...@@ -110,7 +110,7 @@ describe API::ProjectSnippets do ...@@ -110,7 +110,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do it 'creates a new snippet' do
post api("/projects/#{project.id}/snippets/", user), params: params post api("/projects/#{project.id}/snippets/", user), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:code]) expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -123,7 +123,7 @@ describe API::ProjectSnippets do ...@@ -123,7 +123,7 @@ describe API::ProjectSnippets do
it 'creates a new snippet' do it 'creates a new snippet' do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:code]) expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -137,7 +137,7 @@ describe API::ProjectSnippets do ...@@ -137,7 +137,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
snippet = ProjectSnippet.find(json_response['id']) snippet = ProjectSnippet.find(json_response['id'])
expect(snippet.content).to eq(params[:content]) expect(snippet.content).to eq(params[:content])
expect(snippet.description).to eq(params[:description]) expect(snippet.description).to eq(params[:description])
...@@ -151,7 +151,7 @@ describe API::ProjectSnippets do ...@@ -151,7 +151,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('code, content are mutually exclusive') expect(json_response['error']).to eq('code, content are mutually exclusive')
end end
...@@ -160,7 +160,7 @@ describe API::ProjectSnippets do ...@@ -160,7 +160,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 for empty code field' do it 'returns 400 for empty code field' do
...@@ -168,7 +168,7 @@ describe API::ProjectSnippets do ...@@ -168,7 +168,7 @@ describe API::ProjectSnippets do
post api("/projects/#{project.id}/snippets/", admin), params: params post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -196,7 +196,7 @@ describe API::ProjectSnippets do ...@@ -196,7 +196,7 @@ describe API::ProjectSnippets do
expect { create_snippet(project, visibility: 'public') } expect { create_snippet(project, visibility: 'public') }
.not_to change { Snippet.count } .not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -218,7 +218,7 @@ describe API::ProjectSnippets do ...@@ -218,7 +218,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description, visibility: 'private' } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description, visibility: 'private' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description) expect(snippet.description).to eq(new_description)
...@@ -231,7 +231,7 @@ describe API::ProjectSnippets do ...@@ -231,7 +231,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { content: new_content, description: new_description } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { content: new_content, description: new_description }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
snippet.reload snippet.reload
expect(snippet.content).to eq(new_content) expect(snippet.content).to eq(new_content)
expect(snippet.description).to eq(new_description) expect(snippet.description).to eq(new_description)
...@@ -240,21 +240,21 @@ describe API::ProjectSnippets do ...@@ -240,21 +240,21 @@ describe API::ProjectSnippets do
it 'returns 400 when both code and content parameters specified' do it 'returns 400 when both code and content parameters specified' do
put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { code: 'some content', content: 'other content' } put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { code: 'some content', content: 'other content' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('code, content are mutually exclusive') expect(json_response['error']).to eq('code, content are mutually exclusive')
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' } put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
it 'returns 400 for missing parameters' do it 'returns 400 for missing parameters' do
put api("/projects/#{project.id}/snippets/1234", admin) put api("/projects/#{project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'returns 400 for empty code field' do it 'returns 400 for empty code field' do
...@@ -262,7 +262,7 @@ describe API::ProjectSnippets do ...@@ -262,7 +262,7 @@ describe API::ProjectSnippets do
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content } put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the snippet is spam' do context 'when the snippet is spam' do
...@@ -306,7 +306,7 @@ describe API::ProjectSnippets do ...@@ -306,7 +306,7 @@ describe API::ProjectSnippets do
expect { update_snippet(title: 'Foo', visibility: 'public') } expect { update_snippet(title: 'Foo', visibility: 'public') }
.not_to change { snippet.reload.title } .not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq({ "error" => "Spam detected" }) expect(json_response['message']).to eq({ "error" => "Spam detected" })
end end
...@@ -324,13 +324,13 @@ describe API::ProjectSnippets do ...@@ -324,13 +324,13 @@ describe API::ProjectSnippets do
it 'deletes snippet' do it 'deletes snippet' do
delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
delete api("/projects/#{snippet.project.id}/snippets/1234", admin) delete api("/projects/#{snippet.project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
...@@ -345,7 +345,7 @@ describe API::ProjectSnippets do ...@@ -345,7 +345,7 @@ describe API::ProjectSnippets do
it 'returns raw text' do it 'returns raw text' do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to eq(snippet.content) expect(response.body).to eq(snippet.content)
end end
...@@ -353,7 +353,7 @@ describe API::ProjectSnippets do ...@@ -353,7 +353,7 @@ describe API::ProjectSnippets do
it 'returns 404 for invalid snippet id' do it 'returns 404 for invalid snippet id' do
get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin) get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Snippet Not Found') expect(json_response['message']).to eq('404 Snippet Not Found')
end end
end end
......
...@@ -21,7 +21,7 @@ describe API::ProjectStatistics do ...@@ -21,7 +21,7 @@ describe API::ProjectStatistics do
it 'returns the fetch statistics of the last 30 days' do it 'returns the fetch statistics of the last 30 days' do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
fetches = json_response['fetches'] fetches = json_response['fetches']
expect(fetches['total']).to eq(40) expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5) expect(fetches['days'].length).to eq(5)
...@@ -34,7 +34,7 @@ describe API::ProjectStatistics do ...@@ -34,7 +34,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
fetches = json_response['fetches'] fetches = json_response['fetches']
expect(fetches['total']).to eq(40) expect(fetches['total']).to eq(40)
expect(fetches['days'].length).to eq(5) expect(fetches['days'].length).to eq(5)
...@@ -47,7 +47,7 @@ describe API::ProjectStatistics do ...@@ -47,7 +47,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", developer) get api("/projects/#{public_project.id}/statistics", developer)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -56,7 +56,7 @@ describe API::ProjectStatistics do ...@@ -56,7 +56,7 @@ describe API::ProjectStatistics do
get api("/projects/#{public_project.id}/statistics", maintainer) get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -15,7 +15,7 @@ describe API::ProjectTemplates do ...@@ -15,7 +15,7 @@ describe API::ProjectTemplates do
it 'returns dockerfiles' do it 'returns dockerfiles' do
get api("/projects/#{public_project.id}/templates/dockerfiles") get api("/projects/#{public_project.id}/templates/dockerfiles")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' } expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' }
...@@ -24,7 +24,7 @@ describe API::ProjectTemplates do ...@@ -24,7 +24,7 @@ describe API::ProjectTemplates do
it 'returns gitignores' do it 'returns gitignores' do
get api("/projects/#{public_project.id}/templates/gitignores") get api("/projects/#{public_project.id}/templates/gitignores")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' } expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' }
...@@ -33,7 +33,7 @@ describe API::ProjectTemplates do ...@@ -33,7 +33,7 @@ describe API::ProjectTemplates do
it 'returns gitlab_ci_ymls' do it 'returns gitlab_ci_ymls' do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls") get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'Android' } expect(json_response).to satisfy_one { |template| template['key'] == 'Android' }
...@@ -42,7 +42,7 @@ describe API::ProjectTemplates do ...@@ -42,7 +42,7 @@ describe API::ProjectTemplates do
it 'returns licenses' do it 'returns licenses' do
get api("/projects/#{public_project.id}/templates/licenses") get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
expect(json_response).to satisfy_one { |template| template['key'] == 'mit' } expect(json_response).to satisfy_one { |template| template['key'] == 'mit' }
...@@ -51,19 +51,19 @@ describe API::ProjectTemplates do ...@@ -51,19 +51,19 @@ describe API::ProjectTemplates do
it 'returns 400 for an unknown template type' do it 'returns 400 for an unknown template type' do
get api("/projects/#{public_project.id}/templates/unknown") get api("/projects/#{public_project.id}/templates/unknown")
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it 'denies access to an anonymous user on a private project' do it 'denies access to an anonymous user on a private project' do
get api("/projects/#{private_project.id}/templates/licenses") get api("/projects/#{private_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'permits access to a developer on a private project' do it 'permits access to a developer on a private project' do
get api("/projects/#{private_project.id}/templates/licenses", developer) get api("/projects/#{private_project.id}/templates/licenses", developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
end end
end end
...@@ -72,7 +72,7 @@ describe API::ProjectTemplates do ...@@ -72,7 +72,7 @@ describe API::ProjectTemplates do
it 'returns key and name for the listed licenses' do it 'returns key and name for the listed licenses' do
get api("/projects/#{public_project.id}/templates/licenses") get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template_list') expect(response).to match_response_schema('public_api/v4/template_list')
end end
end end
...@@ -81,7 +81,7 @@ describe API::ProjectTemplates do ...@@ -81,7 +81,7 @@ describe API::ProjectTemplates do
it 'returns a specific dockerfile' do it 'returns a specific dockerfile' do
get api("/projects/#{public_project.id}/templates/dockerfiles/Binary") get api("/projects/#{public_project.id}/templates/dockerfiles/Binary")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Binary') expect(json_response['name']).to eq('Binary')
end end
...@@ -89,7 +89,7 @@ describe API::ProjectTemplates do ...@@ -89,7 +89,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitignore' do it 'returns a specific gitignore' do
get api("/projects/#{public_project.id}/templates/gitignores/Actionscript") get api("/projects/#{public_project.id}/templates/gitignores/Actionscript")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Actionscript') expect(json_response['name']).to eq('Actionscript')
end end
...@@ -97,7 +97,7 @@ describe API::ProjectTemplates do ...@@ -97,7 +97,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore' do it 'returns C++ gitignore' do
get api("/projects/#{public_project.id}/templates/gitignores/C++") get api("/projects/#{public_project.id}/templates/gitignores/C++")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('C++') expect(json_response['name']).to eq('C++')
end end
...@@ -105,7 +105,7 @@ describe API::ProjectTemplates do ...@@ -105,7 +105,7 @@ describe API::ProjectTemplates do
it 'returns C++ gitignore for URL-encoded names' do it 'returns C++ gitignore for URL-encoded names' do
get api("/projects/#{public_project.id}/templates/gitignores/C%2B%2B") get api("/projects/#{public_project.id}/templates/gitignores/C%2B%2B")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('C++') expect(json_response['name']).to eq('C++')
end end
...@@ -113,7 +113,7 @@ describe API::ProjectTemplates do ...@@ -113,7 +113,7 @@ describe API::ProjectTemplates do
it 'returns a specific gitlab_ci_yml' do it 'returns a specific gitlab_ci_yml' do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls/Android") get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls/Android")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/template') expect(response).to match_response_schema('public_api/v4/template')
expect(json_response['name']).to eq('Android') expect(json_response['name']).to eq('Android')
end end
...@@ -121,26 +121,26 @@ describe API::ProjectTemplates do ...@@ -121,26 +121,26 @@ describe API::ProjectTemplates do
it 'returns a specific license' do it 'returns a specific license' do
get api("/projects/#{public_project.id}/templates/licenses/mit") get api("/projects/#{public_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
end end
it 'returns 404 for an unknown specific template' do it 'returns 404 for an unknown specific template' do
get api("/projects/#{public_project.id}/templates/licenses/unknown") get api("/projects/#{public_project.id}/templates/licenses/unknown")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'denies access to an anonymous user on a private project' do it 'denies access to an anonymous user on a private project' do
get api("/projects/#{private_project.id}/templates/licenses/mit") get api("/projects/#{private_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'permits access to a developer on a private project' do it 'permits access to a developer on a private project' do
get api("/projects/#{private_project.id}/templates/licenses/mit", developer) get api("/projects/#{private_project.id}/templates/licenses/mit", developer)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
end end
...@@ -148,7 +148,7 @@ describe API::ProjectTemplates do ...@@ -148,7 +148,7 @@ describe API::ProjectTemplates do
it 'rejects invalid filenames' do it 'rejects invalid filenames' do
get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea") get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea")
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
end end
end end
...@@ -165,7 +165,7 @@ describe API::ProjectTemplates do ...@@ -165,7 +165,7 @@ describe API::ProjectTemplates do
fullname: 'Fullname Placeholder' fullname: 'Fullname Placeholder'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/license') expect(response).to match_response_schema('public_api/v4/license')
content = json_response['content'] content = json_response['content']
......
This diff is collapsed.
...@@ -19,7 +19,7 @@ describe API::ProtectedBranches do ...@@ -19,7 +19,7 @@ describe API::ProtectedBranches do
it 'returns the protected branches' do it 'returns the protected branches' do
get api(route, user), params: params.merge(per_page: 100) get api(route, user), params: params.merge(per_page: 100)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -66,7 +66,7 @@ describe API::ProtectedBranches do ...@@ -66,7 +66,7 @@ describe API::ProtectedBranches do
it 'returns the protected branch' do it 'returns the protected branch' do
get api(route, user) get api(route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
...@@ -118,7 +118,7 @@ describe API::ProtectedBranches do ...@@ -118,7 +118,7 @@ describe API::ProtectedBranches do
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) } let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
def expect_protection_to_be_successful def expect_protection_to_be_successful
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
end end
...@@ -130,7 +130,7 @@ describe API::ProtectedBranches do ...@@ -130,7 +130,7 @@ describe API::ProtectedBranches do
it 'protects a single branch' do it 'protects a single branch' do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -139,7 +139,7 @@ describe API::ProtectedBranches do ...@@ -139,7 +139,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can push' do it 'protects a single branch and developers can push' do
post post_endpoint, params: { name: branch_name, push_access_level: 30 } post post_endpoint, params: { name: branch_name, push_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -148,7 +148,7 @@ describe API::ProtectedBranches do ...@@ -148,7 +148,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can merge' do it 'protects a single branch and developers can merge' do
post post_endpoint, params: { name: branch_name, merge_access_level: 30 } post post_endpoint, params: { name: branch_name, merge_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
...@@ -157,7 +157,7 @@ describe API::ProtectedBranches do ...@@ -157,7 +157,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and developers can push and merge' do it 'protects a single branch and developers can push and merge' do
post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 } post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
...@@ -166,7 +166,7 @@ describe API::ProtectedBranches do ...@@ -166,7 +166,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can push' do it 'protects a single branch and no one can push' do
post post_endpoint, params: { name: branch_name, push_access_level: 0 } post post_endpoint, params: { name: branch_name, push_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do ...@@ -175,7 +175,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can merge' do it 'protects a single branch and no one can merge' do
post post_endpoint, params: { name: branch_name, merge_access_level: 0 } post post_endpoint, params: { name: branch_name, merge_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
...@@ -184,7 +184,7 @@ describe API::ProtectedBranches do ...@@ -184,7 +184,7 @@ describe API::ProtectedBranches do
it 'protects a single branch and no one can push or merge' do it 'protects a single branch and no one can push or merge' do
post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 } post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(branch_name) expect(json_response['name']).to eq(branch_name)
expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
...@@ -193,7 +193,7 @@ describe API::ProtectedBranches do ...@@ -193,7 +193,7 @@ describe API::ProtectedBranches do
it 'returns a 409 error if the same branch is protected twice' do it 'returns a 409 error if the same branch is protected twice' do
post post_endpoint, params: { name: protected_name } post post_endpoint, params: { name: protected_name }
expect(response).to have_gitlab_http_status(409) expect(response).to have_gitlab_http_status(:conflict)
end end
context 'when branch has a wildcard in its name' do context 'when branch has a wildcard in its name' do
...@@ -217,7 +217,7 @@ describe API::ProtectedBranches do ...@@ -217,7 +217,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do it "prevents deletion of the protected branch rule" do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -230,7 +230,7 @@ describe API::ProtectedBranches do ...@@ -230,7 +230,7 @@ describe API::ProtectedBranches do
it "returns a 403 error if guest" do it "returns a 403 error if guest" do
post post_endpoint, params: { name: branch_name } post post_endpoint, params: { name: branch_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -245,7 +245,7 @@ describe API::ProtectedBranches do ...@@ -245,7 +245,7 @@ describe API::ProtectedBranches do
it "unprotects a single branch" do it "unprotects a single branch" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -255,7 +255,7 @@ describe API::ProtectedBranches do ...@@ -255,7 +255,7 @@ describe API::ProtectedBranches do
it "returns 404 if branch does not exist" do it "returns 404 if branch does not exist" do
delete api("/projects/#{project.id}/protected_branches/barfoo", user) delete api("/projects/#{project.id}/protected_branches/barfoo", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when a policy restricts rule deletion' do context 'when a policy restricts rule deletion' do
...@@ -267,7 +267,7 @@ describe API::ProtectedBranches do ...@@ -267,7 +267,7 @@ describe API::ProtectedBranches do
it "prevents deletion of the protected branch rule" do it "prevents deletion of the protected branch rule" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -277,7 +277,7 @@ describe API::ProtectedBranches do ...@@ -277,7 +277,7 @@ describe API::ProtectedBranches do
it "unprotects a wildcard branch" do it "unprotects a wildcard branch" do
delete delete_endpoint delete delete_endpoint
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
......
...@@ -19,7 +19,7 @@ describe API::ProtectedTags do ...@@ -19,7 +19,7 @@ describe API::ProtectedTags do
it 'returns the protected tags' do it 'returns the protected tags' do
get api(route, user), params: { per_page: 100 } get api(route, user), params: { per_page: 100 }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
...@@ -55,7 +55,7 @@ describe API::ProtectedTags do ...@@ -55,7 +55,7 @@ describe API::ProtectedTags do
it 'returns the protected tag' do it 'returns the protected tag' do
get api(route, user) get api(route, user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
end end
...@@ -106,7 +106,7 @@ describe API::ProtectedTags do ...@@ -106,7 +106,7 @@ describe API::ProtectedTags do
it 'protects a single tag with maintainers can create tags' do it 'protects a single tag with maintainers can create tags' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end end
...@@ -115,7 +115,7 @@ describe API::ProtectedTags do ...@@ -115,7 +115,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), post api("/projects/#{project.id}/protected_tags", user),
params: { name: tag_name, create_access_level: 30 } params: { name: tag_name, create_access_level: 30 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
end end
...@@ -124,7 +124,7 @@ describe API::ProtectedTags do ...@@ -124,7 +124,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), post api("/projects/#{project.id}/protected_tags", user),
params: { name: tag_name, create_access_level: 0 } params: { name: tag_name, create_access_level: 0 }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
end end
...@@ -132,7 +132,7 @@ describe API::ProtectedTags do ...@@ -132,7 +132,7 @@ describe API::ProtectedTags do
it 'returns a 422 error if the same tag is protected twice' do it 'returns a 422 error if the same tag is protected twice' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message'][0]).to eq('Name has already been taken') expect(json_response['message'][0]).to eq('Name has already been taken')
end end
...@@ -140,7 +140,7 @@ describe API::ProtectedTags do ...@@ -140,7 +140,7 @@ describe API::ProtectedTags do
post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name } post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(protected_name) expect(json_response['name']).to eq(protected_name)
end end
...@@ -150,7 +150,7 @@ describe API::ProtectedTags do ...@@ -150,7 +150,7 @@ describe API::ProtectedTags do
it 'protects multiple tags with a wildcard in the name' do it 'protects multiple tags with a wildcard in the name' do
post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
end end
...@@ -165,7 +165,7 @@ describe API::ProtectedTags do ...@@ -165,7 +165,7 @@ describe API::ProtectedTags do
it 'returns a 403 error if guest' do it 'returns a 403 error if guest' do
post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name } post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -178,7 +178,7 @@ describe API::ProtectedTags do ...@@ -178,7 +178,7 @@ describe API::ProtectedTags do
it 'unprotects a single tag' do it 'unprotects a single tag' do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user) delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -188,7 +188,7 @@ describe API::ProtectedTags do ...@@ -188,7 +188,7 @@ describe API::ProtectedTags do
it "returns 404 if tag does not exist" do it "returns 404 if tag does not exist" do
delete api("/projects/#{project.id}/protected_tags/barfoo", user) delete api("/projects/#{project.id}/protected_tags/barfoo", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'when tag has a wildcard in its name' do context 'when tag has a wildcard in its name' do
...@@ -197,7 +197,7 @@ describe API::ProtectedTags do ...@@ -197,7 +197,7 @@ describe API::ProtectedTags do
it 'unprotects a wildcard tag' do it 'unprotects a wildcard tag' do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user) delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
end end
......
...@@ -16,7 +16,7 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do ...@@ -16,7 +16,7 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do
it 'does not register any offenses' do it 'does not register any offenses' do
expect_no_offenses(<<~RUBY) expect_no_offenses(<<~RUBY)
def up def up
add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: false)
end end
RUBY RUBY
end end
...@@ -29,38 +29,42 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do ...@@ -29,38 +29,42 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do
let(:offense) { '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, see https://gitlab.com/gitlab-org/gitlab/issues/38060' } let(:offense) { '`add_column_with_default` without `allow_null: true` may cause prolonged lock situations and downtime, see https://gitlab.com/gitlab-org/gitlab/issues/38060' }
it 'registers an offense when specifying allow_null: false' do context 'for blacklisted table' do
expect_offense(<<~RUBY) it 'registers an offense when specifying allow_null: false' do
def up expect_offense(<<~RUBY)
add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) def up
^^^^^^^^^^^^^^^^^^^^^^^ #{offense} add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: false)
end ^^^^^^^^^^^^^^^^^^^^^^^ #{offense}
RUBY end
end RUBY
end
it 'registers no offense when specifying allow_null: true' do it 'registers no offense when specifying allow_null: true' do
expect_no_offenses(<<~RUBY) expect_no_offenses(<<~RUBY)
def up def up
add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: true) add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: true)
end end
RUBY RUBY
end end
it 'registers an offense when allow_null is not specified' do it 'registers an offense when allow_null is not specified' do
expect_offense(<<~RUBY) expect_offense(<<~RUBY)
def up def up
add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true) add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true)
^^^^^^^^^^^^^^^^^^^^^^^ #{offense} ^^^^^^^^^^^^^^^^^^^^^^^ #{offense}
end end
RUBY RUBY
end
end end
it 'registers no offense for application_settings (whitelisted table)' do context 'for tables not on the blacklist' do
expect_no_offenses(<<~RUBY) it 'registers no offense for application_settings (not on blacklist)' do
def up expect_no_offenses(<<~RUBY)
add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false) def up
end add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false)
RUBY end
RUBY
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment