diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 00:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-28 00:09:17 +0300 |
commit | c77fda905a8619b756163c10a75171dc9cfe7084 (patch) | |
tree | ffa93b37bfe4b99ba0b8584c7a0bd1a4cd19772a | |
parent | e0fa0638a422c3e20d4423c9bb69d79afc9c7d3d (diff) |
Add latest changes from gitlab-org/gitlab@master
86 files changed, 1346 insertions, 1189 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index 927ee81a3ab..7977d607d87 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -349,8 +349,8 @@ RSpec/HaveGitlabHttpStatus: - 'ee/spec/requests/{groups,projects,repositories}/**/*' - 'spec/requests/api/*/**/*.rb' - 'ee/spec/requests/api/*/**/*.rb' - - 'spec/requests/api/[a-o]*.rb' - - 'ee/spec/requests/api/[a-o]*.rb' + - 'spec/requests/api/[a-p]*.rb' + - 'ee/spec/requests/api/[a-p]*.rb' Style/MultilineWhenThen: Enabled: false diff --git a/changelogs/unreleased/197918-add-package-type-to-project-packages-api.yml b/changelogs/unreleased/197918-add-package-type-to-project-packages-api.yml new file mode 100644 index 00000000000..9f7f6888092 --- /dev/null +++ b/changelogs/unreleased/197918-add-package-type-to-project-packages-api.yml @@ -0,0 +1,5 @@ +--- +title: Add package_type as a filter option to the packages list API endpoint +merge_request: 25816 +author: +type: added diff --git a/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml b/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml new file mode 100644 index 00000000000..5643e11e424 --- /dev/null +++ b/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml @@ -0,0 +1,6 @@ +--- +title: Allow 0 to be set for pages maximum size per project/group to indicate unlimited + size +merge_request: 25677 +author: +type: fixed diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index a2c0fd5cd5c..6ba2fa39aa6 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -20,38 +20,6 @@ unless Gitlab::Runtime.sidekiq? config.lograge.ignore_actions = ['Gitlab::RequestForgeryProtection::Controller#index'] # Add request parameters to log output - config.lograge.custom_options = lambda do |event| - 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 + config.lograge.custom_options = Gitlab::Lograge::CustomOptions end end diff --git a/db/migrate/20180305144721_add_privileged_to_runner.rb b/db/migrate/20180305144721_add_privileged_to_runner.rb index 1ad3c045d60..359498bf9b0 100644 --- a/db/migrate/20180305144721_add_privileged_to_runner.rb +++ b/db/migrate/20180305144721_add_privileged_to_runner.rb @@ -9,7 +9,7 @@ class AddPrivilegedToRunner < ActiveRecord::Migration[4.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb b/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb index c841c7eb77b..0c536f917ce 100644 --- a/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb +++ b/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb @@ -5,7 +5,7 @@ class AddPagesAccessLevelToProjectFeature < ActiveRecord::Migration[4.2] DOWNTIME = false 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) end diff --git a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb index 3c61729dca8..a0a1150f022 100644 --- a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb +++ b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb @@ -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 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, :boolean, default: false, diff --git a/db/migrate/20180601213245_add_deploy_strategy_to_project_auto_devops.rb b/db/migrate/20180601213245_add_deploy_strategy_to_project_auto_devops.rb index 67d20b949d9..78a3617ec93 100644 --- a/db/migrate/20180601213245_add_deploy_strategy_to_project_auto_devops.rb +++ b/db/migrate/20180601213245_add_deploy_strategy_to_project_auto_devops.rb @@ -10,7 +10,7 @@ class AddDeployStrategyToProjectAutoDevops < ActiveRecord::Migration[4.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20180831164905_add_common_to_prometheus_metrics.rb b/db/migrate/20180831164905_add_common_to_prometheus_metrics.rb index 6654e6d1957..5eb77d0480d 100644 --- a/db/migrate/20180831164905_add_common_to_prometheus_metrics.rb +++ b/db/migrate/20180831164905_add_common_to_prometheus_metrics.rb @@ -8,7 +8,7 @@ class AddCommonToPrometheusMetrics < ActiveRecord::Migration[4.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20180907015926_add_legacy_abac_to_cluster_providers_gcp.rb b/db/migrate/20180907015926_add_legacy_abac_to_cluster_providers_gcp.rb index 8bfb0c5612a..c57611a0f7d 100644 --- a/db/migrate/20180907015926_add_legacy_abac_to_cluster_providers_gcp.rb +++ b/db/migrate/20180907015926_add_legacy_abac_to_cluster_providers_gcp.rb @@ -8,7 +8,7 @@ class AddLegacyAbacToClusterProvidersGcp < ActiveRecord::Migration[4.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20181017001059_add_cluster_type_to_clusters.rb b/db/migrate/20181017001059_add_cluster_type_to_clusters.rb index 75abcfedfc9..d032afe1a43 100644 --- a/db/migrate/20181017001059_add_cluster_type_to_clusters.rb +++ b/db/migrate/20181017001059_add_cluster_type_to_clusters.rb @@ -9,7 +9,7 @@ class AddClusterTypeToClusters < ActiveRecord::Migration[4.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190218134158_add_masked_to_ci_variables.rb b/db/migrate/20190218134158_add_masked_to_ci_variables.rb index 60dcc0d7af5..b4999d5b4a9 100644 --- a/db/migrate/20190218134158_add_masked_to_ci_variables.rb +++ b/db/migrate/20190218134158_add_masked_to_ci_variables.rb @@ -12,7 +12,7 @@ class AddMaskedToCiVariables < ActiveRecord::Migration[5.0] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb index c25881410d0..8633875b341 100644 --- a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb +++ b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb @@ -12,7 +12,7 @@ class AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb b/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb index 33fb6b8ef0d..85b9e0580f4 100644 --- a/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb +++ b/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb @@ -8,7 +8,7 @@ class AddEmailHeaderAndFooterEnabledFlagToAppearancesTable < ActiveRecord::Migra DOWNTIME = false 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 def down diff --git a/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb index 766ea50161d..856dfc89fa3 100644 --- a/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb +++ b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb @@ -8,11 +8,9 @@ class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0] disable_ddl_transaction! 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_below, :integer, default: 0, allow_null: false add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false - # rubocop:enable Migration/AddColumnWithDefault end def down diff --git a/db/migrate/20190322164830_add_auto_ssl_enabled_to_pages_domain.rb b/db/migrate/20190322164830_add_auto_ssl_enabled_to_pages_domain.rb index 41552b0e2e3..e74a9535ddf 100644 --- a/db/migrate/20190322164830_add_auto_ssl_enabled_to_pages_domain.rb +++ b/db/migrate/20190322164830_add_auto_ssl_enabled_to_pages_domain.rb @@ -8,7 +8,7 @@ class AddAutoSslEnabledToPagesDomain < ActiveRecord::Migration[5.0] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190325165127_add_managed_to_cluster.rb b/db/migrate/20190325165127_add_managed_to_cluster.rb index 14ed4db143e..e960df9d502 100644 --- a/db/migrate/20190325165127_add_managed_to_cluster.rb +++ b/db/migrate/20190325165127_add_managed_to_cluster.rb @@ -8,7 +8,7 @@ class AddManagedToCluster < ActiveRecord::Migration[5.0] DOWNTIME = false 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 def down diff --git a/db/migrate/20190415030217_add_variable_type_to_ci_variables.rb b/db/migrate/20190415030217_add_variable_type_to_ci_variables.rb index ed7af455e12..433f510299a 100644 --- a/db/migrate/20190415030217_add_variable_type_to_ci_variables.rb +++ b/db/migrate/20190415030217_add_variable_type_to_ci_variables.rb @@ -8,7 +8,7 @@ class AddVariableTypeToCiVariables < ActiveRecord::Migration[5.0] ENV_VAR_VARIABLE_TYPE = 1 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 def down diff --git a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb index 55ef3c79f3f..60d4c2554f7 100644 --- a/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb +++ b/db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb @@ -8,12 +8,10 @@ class AddMergeTrainEnabledToCiCdSettings < ActiveRecord::Migration[5.1] disable_ddl_transaction! # rubocop:disable Migration/UpdateLargeTable - # rubocop:disable Migration/AddColumnWithDefault def up add_column_with_default :project_ci_cd_settings, :merge_trains_enabled, :boolean, default: false, allow_null: false end # rubocop:enable Migration/UpdateLargeTable - # rubocop:enable Migration/AddColumnWithDefault def down remove_column :project_ci_cd_settings, :merge_trains_enabled diff --git a/db/migrate/20190416213556_add_variable_type_to_ci_group_variables.rb b/db/migrate/20190416213556_add_variable_type_to_ci_group_variables.rb index 4d329cea1b5..dce73caeb5e 100644 --- a/db/migrate/20190416213556_add_variable_type_to_ci_group_variables.rb +++ b/db/migrate/20190416213556_add_variable_type_to_ci_group_variables.rb @@ -8,7 +8,7 @@ class AddVariableTypeToCiGroupVariables < ActiveRecord::Migration[5.0] ENV_VAR_VARIABLE_TYPE = 1 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 def down diff --git a/db/migrate/20190416213631_add_variable_type_to_ci_pipeline_schedule_variables.rb b/db/migrate/20190416213631_add_variable_type_to_ci_pipeline_schedule_variables.rb index b7d80cb2d0d..3079b2afd9c 100644 --- a/db/migrate/20190416213631_add_variable_type_to_ci_pipeline_schedule_variables.rb +++ b/db/migrate/20190416213631_add_variable_type_to_ci_pipeline_schedule_variables.rb @@ -8,7 +8,7 @@ class AddVariableTypeToCiPipelineScheduleVariables < ActiveRecord::Migration[5.0 ENV_VAR_VARIABLE_TYPE = 1 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 def down diff --git a/db/migrate/20190426180107_add_deployment_events_to_services.rb b/db/migrate/20190426180107_add_deployment_events_to_services.rb index e8e53728010..1fb137fb5f9 100644 --- a/db/migrate/20190426180107_add_deployment_events_to_services.rb +++ b/db/migrate/20190426180107_add_deployment_events_to_services.rb @@ -8,7 +8,7 @@ class AddDeploymentEventsToServices < ActiveRecord::Migration[5.0] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190520200123_add_rule_type_to_approval_merge_request_approval_rules.rb b/db/migrate/20190520200123_add_rule_type_to_approval_merge_request_approval_rules.rb index 7bdb48f3eec..7339a4fccba 100644 --- a/db/migrate/20190520200123_add_rule_type_to_approval_merge_request_approval_rules.rb +++ b/db/migrate/20190520200123_add_rule_type_to_approval_merge_request_approval_rules.rb @@ -12,7 +12,7 @@ class AddRuleTypeToApprovalMergeRequestApprovalRules < ActiveRecord::Migration[5 disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190607085356_add_source_to_pages_domains.rb b/db/migrate/20190607085356_add_source_to_pages_domains.rb index d681ab67431..0a845d7d11f 100644 --- a/db/migrate/20190607085356_add_source_to_pages_domains.rb +++ b/db/migrate/20190607085356_add_source_to_pages_domains.rb @@ -12,7 +12,7 @@ class AddSourceToPagesDomains < ActiveRecord::Migration[5.1] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190628145246_add_strategies_to_operations_feature_flag_scopes.rb b/db/migrate/20190628145246_add_strategies_to_operations_feature_flag_scopes.rb index 030ef9e4bd6..ed1f16ee69a 100644 --- a/db/migrate/20190628145246_add_strategies_to_operations_feature_flag_scopes.rb +++ b/db/migrate/20190628145246_add_strategies_to_operations_feature_flag_scopes.rb @@ -8,7 +8,7 @@ class AddStrategiesToOperationsFeatureFlagScopes < ActiveRecord::Migration[5.1] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190709204413_add_rule_type_to_approval_project_rules.rb b/db/migrate/20190709204413_add_rule_type_to_approval_project_rules.rb index b11154d0f26..87a228c9bf9 100644 --- a/db/migrate/20190709204413_add_rule_type_to_approval_project_rules.rb +++ b/db/migrate/20190709204413_add_rule_type_to_approval_project_rules.rb @@ -8,7 +8,7 @@ class AddRuleTypeToApprovalProjectRules < ActiveRecord::Migration[5.1] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190712064021_add_namespace_per_environment_flag_to_clusters.rb b/db/migrate/20190712064021_add_namespace_per_environment_flag_to_clusters.rb index 771eb21c4b6..4c8a0ab3def 100644 --- a/db/migrate/20190712064021_add_namespace_per_environment_flag_to_clusters.rb +++ b/db/migrate/20190712064021_add_namespace_per_environment_flag_to_clusters.rb @@ -11,7 +11,7 @@ class AddNamespacePerEnvironmentFlagToClusters < ActiveRecord::Migration[5.1] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190715173819_add_object_storage_flag_to_geo_node.rb b/db/migrate/20190715173819_add_object_storage_flag_to_geo_node.rb index cbc353b6282..2d3243f3357 100644 --- a/db/migrate/20190715173819_add_object_storage_flag_to_geo_node.rb +++ b/db/migrate/20190715173819_add_object_storage_flag_to_geo_node.rb @@ -12,7 +12,7 @@ class AddObjectStorageFlagToGeoNode < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190729180447_add_merge_requests_require_code_owner_approval_to_protected_branches.rb b/db/migrate/20190729180447_add_merge_requests_require_code_owner_approval_to_protected_branches.rb index bfac67606d6..098fcff9ace 100644 --- a/db/migrate/20190729180447_add_merge_requests_require_code_owner_approval_to_protected_branches.rb +++ b/db/migrate/20190729180447_add_merge_requests_require_code_owner_approval_to_protected_branches.rb @@ -9,7 +9,7 @@ class AddMergeRequestsRequireCodeOwnerApprovalToProtectedBranches < ActiveRecord disable_ddl_transaction! def up - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :protected_branches, :code_owner_approval_required, :boolean, diff --git a/db/migrate/20190816151221_add_active_jobs_limit_to_plans.rb b/db/migrate/20190816151221_add_active_jobs_limit_to_plans.rb index 193e6cb188e..951ff41f1a8 100644 --- a/db/migrate/20190816151221_add_active_jobs_limit_to_plans.rb +++ b/db/migrate/20190816151221_add_active_jobs_limit_to_plans.rb @@ -8,7 +8,7 @@ class AddActiveJobsLimitToPlans < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190901174200_add_max_issue_count_to_list.rb b/db/migrate/20190901174200_add_max_issue_count_to_list.rb index 7408d2f1c93..59359f28d6a 100644 --- a/db/migrate/20190901174200_add_max_issue_count_to_list.rb +++ b/db/migrate/20190901174200_add_max_issue_count_to_list.rb @@ -7,7 +7,7 @@ class AddMaxIssueCountToList < ActiveRecord::Migration[4.2] DOWNTIME = false 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 def down diff --git a/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb b/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb index cd6b2fb7d4f..e7ffd7cd4d3 100644 --- a/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb +++ b/db/migrate/20190905140605_add_cloud_run_to_clusters_providers_gcp.rb @@ -8,7 +8,7 @@ class AddCloudRunToClustersProvidersGcp < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb b/db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb index 41f9b36278a..50d5d2b0574 100644 --- a/db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb +++ b/db/migrate/20190907184714_add_show_whitespace_in_diffs_to_user_preferences.rb @@ -11,7 +11,7 @@ class AddShowWhitespaceInDiffsToUserPreferences < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb index 62290fb0fa6..0ba9d8e6c89 100644 --- a/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb +++ b/db/migrate/20190918104731_add_cleanup_status_to_cluster.rb @@ -9,7 +9,7 @@ class AddCleanupStatusToCluster < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default(:clusters, :cleanup_status, # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:clusters, :cleanup_status, :smallint, default: 1, allow_null: false) diff --git a/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb index 41a81e3ac87..f172d3bdcbd 100644 --- a/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb +++ b/db/migrate/20191014123159_add_expire_notification_delivered_to_personal_access_tokens.rb @@ -8,7 +8,7 @@ class AddExpireNotificationDeliveredToPersonalAccessTokens < ActiveRecord::Migra disable_ddl_transaction! 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 def down diff --git a/db/migrate/20191023093207_add_comment_actions_to_services.rb b/db/migrate/20191023093207_add_comment_actions_to_services.rb index 0bd528cc85d..f3fc12ac7c7 100644 --- a/db/migrate/20191023093207_add_comment_actions_to_services.rb +++ b/db/migrate/20191023093207_add_comment_actions_to_services.rb @@ -8,7 +8,7 @@ class AddCommentActionsToServices < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20191028130054_add_max_issue_weight_to_list.rb b/db/migrate/20191028130054_add_max_issue_weight_to_list.rb index f15b65067f6..eec7c42c907 100644 --- a/db/migrate/20191028130054_add_max_issue_weight_to_list.rb +++ b/db/migrate/20191028130054_add_max_issue_weight_to_list.rb @@ -8,7 +8,7 @@ class AddMaxIssueWeightToList < ActiveRecord::Migration[5.2] DOWNTIME = false 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 def down diff --git a/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb index 40e361e2150..8db11724874 100644 --- a/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb +++ b/db/migrate/20191029191901_add_enabled_to_grafana_integrations.rb @@ -8,7 +8,7 @@ class AddEnabledToGrafanaIntegrations < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :grafana_integrations, :enabled, :boolean, diff --git a/db/migrate/20191105155113_add_secret_to_snippet.rb b/db/migrate/20191105155113_add_secret_to_snippet.rb index 8f0a330238b..ae514d48494 100644 --- a/db/migrate/20191105155113_add_secret_to_snippet.rb +++ b/db/migrate/20191105155113_add_secret_to_snippet.rb @@ -9,7 +9,7 @@ class AddSecretToSnippet < ActiveRecord::Migration[5.2] def up 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 add_concurrent_index :snippets, [:visibility_level, :secret] diff --git a/db/migrate/20191106144901_add_state_to_merge_trains.rb b/db/migrate/20191106144901_add_state_to_merge_trains.rb index 64a70575c91..e2256705f53 100644 --- a/db/migrate/20191106144901_add_state_to_merge_trains.rb +++ b/db/migrate/20191106144901_add_state_to_merge_trains.rb @@ -9,7 +9,7 @@ class AddStateToMergeTrains < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb b/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb index b868e0b44a8..2fbd003b2e5 100644 --- a/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb +++ b/db/migrate/20191112090226_add_artifacts_to_ci_build_need.rb @@ -8,7 +8,7 @@ class AddArtifactsToCiBuildNeed < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default(:ci_build_needs, :artifacts, # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) diff --git a/db/migrate/20191121193110_add_issue_links_type.rb b/db/migrate/20191121193110_add_issue_links_type.rb index 86bfd41b916..61ef2e7d7e8 100644 --- a/db/migrate/20191121193110_add_issue_links_type.rb +++ b/db/migrate/20191121193110_add_issue_links_type.rb @@ -8,7 +8,7 @@ class AddIssueLinksType < ActiveRecord::Migration[5.1] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb b/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb index 12e22b4744c..1fb02085c37 100644 --- a/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb +++ b/db/migrate/20191127163053_add_confidential_to_doorkeeper_application.rb @@ -8,7 +8,7 @@ class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :oauth_applications, :confidential, :boolean, diff --git a/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb b/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb index 4ca7ad29691..6893a02bcad 100644 --- a/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb +++ b/db/migrate/20191127221608_add_wildcard_and_domain_type_to_pages_domains.rb @@ -9,10 +9,8 @@ class AddWildcardAndDomainTypeToPagesDomains < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - # rubocop:disable Migration/AddColumnWithDefault add_column_with_default :pages_domains, :wildcard, :boolean, default: false add_column_with_default :pages_domains, :domain_type, :integer, limit: 2, default: PROJECT_TYPE - # rubocop:enable Migration/AddColumnWithDefault end def down diff --git a/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb b/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb index 884d9ac6d7f..84d17f558d1 100644 --- a/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb +++ b/db/migrate/20191129134844_add_broadcast_type_to_broadcast_message.rb @@ -10,7 +10,7 @@ class AddBroadcastTypeToBroadcastMessage < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20191218124915_add_repository_storage_to_snippets.rb b/db/migrate/20191218124915_add_repository_storage_to_snippets.rb index df9a9d2ff43..ff391c04062 100644 --- a/db/migrate/20191218124915_add_repository_storage_to_snippets.rb +++ b/db/migrate/20191218124915_add_repository_storage_to_snippets.rb @@ -8,7 +8,7 @@ class AddRepositoryStorageToSnippets < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :snippets, :repository_storage, :string, diff --git a/db/migrate/20191218125015_add_storage_version_to_snippets.rb b/db/migrate/20191218125015_add_storage_version_to_snippets.rb index b1bd3589692..659f36f42b5 100644 --- a/db/migrate/20191218125015_add_storage_version_to_snippets.rb +++ b/db/migrate/20191218125015_add_storage_version_to_snippets.rb @@ -8,7 +8,7 @@ class AddStorageVersionToSnippets < ActiveRecord::Migration[5.2] disable_ddl_transaction! def up - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :snippets, :storage_version, :integer, diff --git a/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb b/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb index e0cf18caf9c..2fe79250ea2 100644 --- a/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb +++ b/db/migrate/20200122161638_add_deploy_token_type_to_deploy_tokens.rb @@ -8,7 +8,7 @@ class AddDeployTokenTypeToDeployTokens < ActiveRecord::Migration[5.2] DOWNTIME = false 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 def down diff --git a/db/migrate/20200128184209_add_usage_to_pages_domains.rb b/db/migrate/20200128184209_add_usage_to_pages_domains.rb index 292490078cd..ac644814076 100644 --- a/db/migrate/20200128184209_add_usage_to_pages_domains.rb +++ b/db/migrate/20200128184209_add_usage_to_pages_domains.rb @@ -9,7 +9,7 @@ class AddUsageToPagesDomains < ActiveRecord::Migration[5.2] disable_ddl_transaction! 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 def down diff --git a/db/migrate/20200224163804_add_version_to_feature_flags_table.rb b/db/migrate/20200224163804_add_version_to_feature_flags_table.rb index e2ccefd8955..bf3179f070c 100644 --- a/db/migrate/20200224163804_add_version_to_feature_flags_table.rb +++ b/db/migrate/20200224163804_add_version_to_feature_flags_table.rb @@ -12,9 +12,7 @@ class AddVersionToFeatureFlagsTable < ActiveRecord::Migration[6.0] def up # 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 - # rubocop: disable Migration/AddColumnWithDefault add_column_with_default(:operations_feature_flags, :version, :smallint, default: FEATURE_FLAG_LEGACY_VERSION, allow_null: false) - # rubocop: enable Migration/AddColumnWithDefault end def down diff --git a/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb b/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb index 62bb3f46cae..e94dc75e65c 100644 --- a/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb +++ b/db/post_migrate/20200120083607_remove_storage_version_column_from_snippets.rb @@ -19,7 +19,7 @@ class RemoveStorageVersionColumnFromSnippets < ActiveRecord::Migration[5.2] def down return if column_exists?(:snippets, :storage_version) - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :snippets, :storage_version, :integer, diff --git a/db/post_migrate/20200221142216_remove_repository_storage_from_snippets.rb b/db/post_migrate/20200221142216_remove_repository_storage_from_snippets.rb index f9ef985218b..fb8721a45b8 100644 --- a/db/post_migrate/20200221142216_remove_repository_storage_from_snippets.rb +++ b/db/post_migrate/20200221142216_remove_repository_storage_from_snippets.rb @@ -16,7 +16,7 @@ class RemoveRepositoryStorageFromSnippets < ActiveRecord::Migration[6.0] def down return if column_exists?(:snippets, :repository_storage) - add_column_with_default( # rubocop:disable Migration/AddColumnWithDefault + add_column_with_default( :snippets, :repository_storage, :string, diff --git a/doc/administration/monitoring/gitlab_self_monitoring_project/index.md b/doc/administration/monitoring/gitlab_self_monitoring_project/index.md index b2e44f02ff1..1946e55603c 100644 --- a/doc/administration/monitoring/gitlab_self_monitoring_project/index.md +++ b/doc/administration/monitoring/gitlab_self_monitoring_project/index.md @@ -1,6 +1,6 @@ # 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. GitLab has been adding the ability for administrators to see insights into the health of diff --git a/doc/api/packages.md b/doc/api/packages.md index 5e993dbf5f5..e04cb44538a 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.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. -Get a list of project packages. Both Maven and NPM packages are included in results. -When accessed without authentication, only packages of public projects are returned. +Get a list of project packages. All package types are included in results. When +accessed without authentication, only packages of public projects are returned. ``` 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) | | `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. | +| `package_type` | string | no | Filter the returned packages by type. One of `conan`, `maven`, `npm` or `nuget`. (_Introduced in GitLab 12.9_) ```shell curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/:id/packages diff --git a/doc/api/users.md b/doc/api/users.md index 2c1d68be964..7952a703e47 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -160,7 +160,7 @@ Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) ... "shared_runners_minutes_limit": 133, "extra_shared_runners_minutes_limit": 133, - "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123" + "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123", ... } ] @@ -313,7 +313,7 @@ the `shared_runners_minutes_limit`, `extra_shared_runners_minutes_limit`, and `n "username": "john_smith", "shared_runners_minutes_limit": 133, "extra_shared_runners_minutes_limit": 133, - "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123" + "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123", ... } ``` @@ -327,7 +327,7 @@ see the `group_saml` option: "username": "john_smith", "shared_runners_minutes_limit": 133, "extra_shared_runners_minutes_limit": 133, - "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123" + "note": "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123", "identities": [ {"provider": "github", "extern_uid": "2435223452345"}, {"provider": "bitbucket", "extern_uid": "john.smith"}, @@ -364,33 +364,36 @@ POST /users Parameters: -- `email` (required) - Email -- `password` (optional) - Password -- `reset_password` (optional) - Send user password reset link - true or false(default) -- `force_random_password` (optional) - Set user password to a random value - true or false (default) -- `username` (required) - Username -- `name` (required) - Name -- `skype` (optional) - Skype ID -- `linkedin` (optional) - LinkedIn -- `twitter` (optional) - Twitter account -- `website_url` (optional) - Website URL -- `organization` (optional) - Organization name -- `projects_limit` (optional) - Number of projects user can create -- `extern_uid` (optional) - External UID -- `provider` (optional) - External provider name -- `bio` (optional) - User's biography -- `location` (optional) - User's location -- `public_email` (optional) - The public email of the user -- `admin` (optional) - User is admin - true or false (default) -- `can_create_group` (optional) - User can create groups - true or false -- `skip_confirmation` (optional) - Skip confirmation - true or false (default) -- `external` (optional) - Flags the user as external - true or false (default) -- `avatar` (optional) - Image file for user's avatar -- `theme_id` (optional) - The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) -- `color_scheme_id` (optional) - User's color scheme for the file viewer (see [the user preference docs](../user/profile/preferences.md#syntax-highlighting-theme) for more information) -- `private_profile` (optional) - User's profile is private - true, false (default), or null (will be converted to false) -- `shared_runners_minutes_limit` (optional) - Pipeline minutes quota for this user **(STARTER)** -- `extra_shared_runners_minutes_limit` (optional) - Extra pipeline minutes quota for this user **(STARTER)** +| Attribute | Required | Description | +|:-------------------------------------|:---------|:--------------------------------------------------------------------------------------------------------------------------------------------------------| +| `admin` | No | User is admin - true or false (default) | +| `avatar` | No | Image file for user's avatar | +| `bio` | No | User's biography | +| `can_create_group` | No | User can create groups - true or false | +| `color_scheme_id` | No | User's color scheme for the file viewer (see [the user preference docs](../user/profile/preferences.md#syntax-highlighting-theme) for more information) | +| `email` | Yes | Email | +| `extern_uid` | No | External UID | +| `external` | No | Flags the user as external - true or false (default) | +| `extra_shared_runners_minutes_limit` | No | Extra pipeline minutes quota for this user **(STARTER)** | +| `force_random_password` | No | Set user password to a random value - true or false (default) | +| `group_id_for_saml` | No | ID of group where SAML has been configured | +| `linkedin` | No | LinkedIn | +| `location` | No | User's location | +| `name` | No | Name | +| `organization` | No | Organization name | +| `password` | No | Password | +| `private_profile` | No | User's profile is private - true, false (default), or null (will be converted to false) | +| `projects_limit` | No | Number of projects user can create | +| `provider` | No | External provider name | +| `public_email` | No | The public email of the user | +| `reset_password` | No | Send user password reset link - true or false(default) | +| `shared_runners_minutes_limit` | No | Pipeline minutes quota for this user **(STARTER)** | +| `skip_confirmation` | No | Skip confirmation - true or false (default) | +| `skype` | No | Skype ID | +| `theme_id` | No | The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) | +| `twitter` | No | Twitter account | +| `username` | Yes | Username | +| `website_url` | No | Website URL | ## User modification @@ -402,36 +405,36 @@ PUT /users/:id Parameters: -- `id` (required) - The ID of the user -- `email` (optional) - Email -- `username` (optional) - Username -- `name` (optional) - Name -- `password` (optional) - Password -- `skype` (optional) - Skype ID -- `linkedin` (optional) - LinkedIn -- `twitter` (optional) - Twitter account -- `website_url` (optional) - Website URL -- `organization` (optional) - Organization name -- `projects_limit` (optional) - Limit projects each user can create -- `extern_uid` (optional) - External UID -- `provider` (optional) - External provider name -- `group_id_for_saml` (optional) - ID of group where SAML has been configured -- `bio` (optional) - User's biography -- `location` (optional) - User's location -- `public_email` (optional) - The public email of the user -- `admin` (optional) - User is admin - true or false (default) -- `can_create_group` (optional) - User can create groups - true or false -- `skip_reconfirmation` (optional) - Skip reconfirmation - true or false (default) -- `external` (optional) - Flags the user as external - true or false (default) -- `shared_runners_minutes_limit` (optional) - Pipeline minutes quota for this user -- `extra_shared_runners_minutes_limit` (optional) - Extra pipeline minutes quota for this user -- `avatar` (optional) - Image file for user's avatar -- `theme_id` (optional) - The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) -- `color_scheme_id` (optional) - User's color scheme for the file viewer (see [the user preference docs](../user/profile/preferences.md#syntax-highlighting-theme) for more information) -- `private_profile` (optional) - User's profile is private - true, false (default), or null (will be converted to false) -- `shared_runners_minutes_limit` (optional) - Pipeline minutes quota for this user **(STARTER)** -- `extra_shared_runners_minutes_limit` (optional) - Extra pipeline minutes quota for this user **(STARTER)** -- `note` (optional) - Admin notes for this user **(STARTER)** +| Attribute | Required | Description | +|:-------------------------------------|:---------|:--------------------------------------------------------------------------------------------------------------------------------------------------------| +| `admin` | No | User is admin - true or false (default) | +| `avatar` | No | Image file for user's avatar | +| `bio` | No | User's biography | +| `can_create_group` | No | User can create groups - true or false | +| `color_scheme_id` | No | User's color scheme for the file viewer (see [the user preference docs](../user/profile/preferences.md#syntax-highlighting-theme) for more information) | +| `email` | No | Email | +| `extern_uid` | No | External UID | +| `external` | No | Flags the user as external - true or false (default) | +| `extra_shared_runners_minutes_limit` | No | Extra pipeline minutes quota for this user **(STARTER)** | +| `group_id_for_saml` | No | ID of group where SAML has been configured | +| `id` | Yes | The ID of the user | +| `linkedin` | No | LinkedIn | +| `location` | No | User's location | +| `name` | No | Name | +| `note` | No | Admin notes for this user **(STARTER)** | +| `organization` | No | Organization name | +| `password` | No | Password | +| `private_profile` | No | User's profile is private - true, false (default), or null (will be converted to false) | +| `projects_limit` | No | Limit projects each user can create | +| `provider` | No | External provider name | +| `public_email` | No | The public email of the user | +| `shared_runners_minutes_limit` | No | Pipeline minutes quota for this user **(STARTER)** | +| `skip_reconfirmation` | No | Skip reconfirmation - true or false (default) | +| `skype` | No | Skype ID | +| `theme_id` | No | The GitLab theme for the user (see [the user preference docs](../user/profile/preferences.md#navigation-theme) for more information) | +| `twitter` | No | Twitter account | +| `username` | No | Username | +| `website_url` | No | Website URL | On password update, user will be forced to change it upon next login. Note, at the moment this method does only return a `404` error, diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md index 7698492b29b..57f8ff36c00 100644 --- a/doc/development/migration_style_guide.md +++ b/doc/development/migration_style_guide.md @@ -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 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 By default, migrations are single transaction. That is, a transaction is opened diff --git a/doc/user/project/integrations/img/prometheus_dashboard_label_variable_shorthand.png b/doc/user/project/integrations/img/prometheus_dashboard_label_variable_shorthand.png Binary files differnew file mode 100644 index 00000000000..15111a97464 --- /dev/null +++ b/doc/user/project/integrations/img/prometheus_dashboard_label_variable_shorthand.png diff --git a/doc/user/project/integrations/img/prometheus_dashboard_label_variables.png b/doc/user/project/integrations/img/prometheus_dashboard_label_variables.png Binary files differnew file mode 100644 index 00000000000..9b94d0c6afa --- /dev/null +++ b/doc/user/project/integrations/img/prometheus_dashboard_label_variables.png diff --git a/doc/user/project/integrations/img/prometheus_dashboard_repeated_label.png b/doc/user/project/integrations/img/prometheus_dashboard_repeated_label.png Binary files differnew file mode 100644 index 00000000000..d43a890f0fa --- /dev/null +++ b/doc/user/project/integrations/img/prometheus_dashboard_repeated_label.png diff --git a/doc/user/project/integrations/jira.md b/doc/user/project/integrations/jira.md index 0bfb13ba54f..1af56b79e82 100644 --- a/doc/user/project/integrations/jira.md +++ b/doc/user/project/integrations/jira.md @@ -71,8 +71,8 @@ in the table below. | 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`. | -| `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`. | +| `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`. 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**. | | `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.** | diff --git a/doc/user/project/integrations/prometheus.md b/doc/user/project/integrations/prometheus.md index 624ab0616c4..2f1be1c2257 100644 --- a/doc/user/project/integrations/prometheus.md +++ b/doc/user/project/integrations/prometheus.md @@ -191,7 +191,7 @@ For example: metrics: - id: metric_of_ages query_range: 'http_requests_total' - label: "Metric of Ages" + label: "Instance: {{instance}}, method: {{method}}" unit: "count" ``` @@ -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)). | | `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_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 The below panel types are supported in monitoring dashboards. @@ -290,7 +336,7 @@ panel_groups: metrics: - id: area_http_requests_total query_range: 'http_requests_total' - label: "Metric of Ages" + label: "Instance: {{instance}}, Method: {{method}}" unit: "count" ``` diff --git a/lib/gitlab/git/rugged_impl/repository.rb b/lib/gitlab/git/rugged_impl/repository.rb index 8fde93e71e2..8679d977773 100644 --- a/lib/gitlab/git/rugged_impl/repository.rb +++ b/lib/gitlab/git/rugged_impl/repository.rb @@ -70,7 +70,7 @@ module Gitlab # Lookup for rugged object by 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 diff --git a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb index 1eb1e1b783b..045a341f2ed 100644 --- a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb +++ b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb @@ -6,6 +6,8 @@ module Gitlab class LogrageWithTimestamp include Gitlab::EncodingHelper + EMPTY_ARRAY = [].freeze + def call(severity, datetime, _, data) time = data.delete :time data[:params] = process_params(data) @@ -16,30 +18,27 @@ module Gitlab duration: time[:total], db: time[:db], view: time[:view] - }.merge(data) - ::Lograge.formatter.call(attributes) + "\n" + }.merge!(data) + + ::Lograge.formatter.call(attributes) << "\n" end private def process_params(data) - return [] unless data.has_key?(:params) + return EMPTY_ARRAY unless data.has_key?(:params) - params_array = - data[:params] - .each_pair - .map { |k, v| { key: k, value: utf8_encode_values(v) } } + params_array = data[:params].map { |k, v| { key: k, value: utf8_encode_values(v) } } - Gitlab::Utils::LogLimitedArray.log_limited_array(params_array, - sentinel: { key: 'truncated', value: '...' }) + Gitlab::Utils::LogLimitedArray.log_limited_array(params_array, sentinel: Gitlab::Lograge::CustomOptions::LIMITED_ARRAY_SENTINEL) end def utf8_encode_values(data) case data when Hash - data.merge(data) { |k, v| utf8_encode_values(v) } + data.merge!(data) { |k, v| utf8_encode_values(v) } when Array - data.map { |v| utf8_encode_values(v) } + data.map! { |v| utf8_encode_values(v) } when String encode_utf8(data) end diff --git a/lib/gitlab/lograge/custom_options.rb b/lib/gitlab/lograge/custom_options.rb new file mode 100644 index 00000000000..5dbff7d9102 --- /dev/null +++ b/lib/gitlab/lograge/custom_options.rb @@ -0,0 +1,43 @@ +# 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 diff --git a/rubocop/cop/migration/add_column_with_default.rb b/rubocop/cop/migration/add_column_with_default.rb index d9f8fe62a86..68e53b17f19 100644 --- a/rubocop/cop/migration/add_column_with_default.rb +++ b/rubocop/cop/migration/add_column_with_default.rb @@ -10,7 +10,37 @@ module RuboCop class AddColumnWithDefault < RuboCop::Cop::Cop 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, ' \ 'see https://gitlab.com/gitlab-org/gitlab/issues/38060'.freeze @@ -23,21 +53,23 @@ module RuboCop return unless in_migration?(node) add_column_with_default?(node) do |table, options| - break if table_whitelisted?(table) || nulls_allowed?(options) - - add_offense(node, location: :selector) + add_offense(node, location: :selector) if offensive?(table, options) end end private + def offensive?(table, options) + table_blacklisted?(table) && !nulls_allowed?(options) + end + def nulls_allowed?(options) options.find { |opt| opt.key.value == :allow_null && opt.value.true_type? } end - def table_whitelisted?(symbol) + def table_blacklisted?(symbol) symbol && symbol.type == :sym && - WHITELISTED_TABLES.include?(symbol.children[0]) + BLACKLISTED_TABLES.include?(symbol.children[0]) end end end diff --git a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js index 35c1495be58..4237bdd80be 100644 --- a/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/javascripts/vue_mr_widget/mr_widget_options_spec.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import waitForPromises from 'spec/helpers/wait_for_promises'; import axios from '~/lib/utils/axios_utils'; import mrWidgetOptions from '~/vue_merge_request_widget/mr_widget_options.vue'; import eventHub from '~/vue_merge_request_widget/event_hub'; @@ -25,6 +26,7 @@ describe('mrWidgetOptions', () => { const COLLABORATION_MESSAGE = 'Allows commits from members who can merge to the target branch'; beforeEach(() => { + jasmine.clock().install(); // Prevent component mounting delete mrWidgetOptions.el; @@ -36,729 +38,591 @@ describe('mrWidgetOptions', () => { mock.onGet(mockData.merge_request_cached_widget_path).reply(() => [200, { ...mockData }]); MrWidgetOptions = Vue.extend(mrWidgetOptions); - vm = mountComponent(MrWidgetOptions, { - mrData: { ...mockData }, - }); }); afterEach(() => { - vm.$destroy(); + jasmine.clock().uninstall(); mock.restore(); + + vm.$destroy(); + vm = null; + gl.mrWidgetData = {}; gon.features = {}; }); - describe('data', () => { - it('should instantiate Store and Service', () => { - expect(vm.mr).toBeDefined(); - expect(vm.service).toBeDefined(); - }); - }); + const createComponent = () => { + if (vm) { + vm.$destroy(); + } - describe('computed', () => { - describe('componentName', () => { - it('should return merged component', () => { - expect(vm.componentName).toEqual('mr-widget-merged'); - }); + vm = mountComponent(MrWidgetOptions, { + mrData: { ...mockData }, + }); + }; - it('should return conflicts component', () => { - vm.mr.state = 'conflicts'; + describe('default', () => { + beforeEach(() => { + createComponent(); + }); - expect(vm.componentName).toEqual('mr-widget-conflicts'); + describe('data', () => { + it('should instantiate Store and Service', () => { + expect(vm.mr).toBeDefined(); + expect(vm.service).toBeDefined(); }); }); - describe('shouldRenderMergeHelp', () => { - it('should return false for the initial merged state', () => { - expect(vm.shouldRenderMergeHelp).toBeFalsy(); - }); + describe('computed', () => { + describe('componentName', () => { + it('should return merged component', () => { + expect(vm.componentName).toEqual('mr-widget-merged'); + }); - it('should return true for a state which requires help widget', () => { - vm.mr.state = 'conflicts'; + it('should return conflicts component', () => { + vm.mr.state = 'conflicts'; - expect(vm.shouldRenderMergeHelp).toBeTruthy(); + expect(vm.componentName).toEqual('mr-widget-conflicts'); + }); }); - }); - - describe('shouldRenderPipelines', () => { - it('should return true when hasCI is true', () => { - vm.mr.hasCI = true; - expect(vm.shouldRenderPipelines).toBeTruthy(); - }); + describe('shouldRenderMergeHelp', () => { + it('should return false for the initial merged state', () => { + expect(vm.shouldRenderMergeHelp).toBeFalsy(); + }); - it('should return false when hasCI is false', () => { - vm.mr.hasCI = false; + it('should return true for a state which requires help widget', () => { + vm.mr.state = 'conflicts'; - expect(vm.shouldRenderPipelines).toBeFalsy(); + expect(vm.shouldRenderMergeHelp).toBeTruthy(); + }); }); - }); - describe('shouldSuggestPipelines', () => { - describe('given suggestPipeline feature flag is enabled', () => { - beforeEach(() => { - gon.features = { suggestPipeline: true }; - vm = mountComponent(MrWidgetOptions, { - mrData: { ...mockData }, - }); - }); + describe('shouldRenderPipelines', () => { + it('should return true when hasCI is true', () => { + vm.mr.hasCI = true; - afterEach(() => { - gon.features = {}; + expect(vm.shouldRenderPipelines).toBeTruthy(); }); - it('should suggest pipelines when none exist', () => { - vm.mr.mergeRequestAddCiConfigPath = 'some/path'; + it('should return false when hasCI is false', () => { vm.mr.hasCI = false; - expect(vm.shouldSuggestPipelines).toBeTruthy(); + expect(vm.shouldRenderPipelines).toBeFalsy(); }); + }); - it('should not suggest pipelines when they exist', () => { - vm.mr.mergeRequestAddCiConfigPath = null; - vm.mr.hasCI = false; - - expect(vm.shouldSuggestPipelines).toBeFalsy(); + describe('shouldRenderRelatedLinks', () => { + it('should return false for the initial data', () => { + expect(vm.shouldRenderRelatedLinks).toBeFalsy(); }); - it('should not suggest pipelines hasCI is true', () => { - vm.mr.mergeRequestAddCiConfigPath = 'some/path'; - vm.mr.hasCI = true; + it('should return true if there is relatedLinks in MR', () => { + Vue.set(vm.mr, 'relatedLinks', {}); - expect(vm.shouldSuggestPipelines).toBeFalsy(); + expect(vm.shouldRenderRelatedLinks).toBeTruthy(); }); }); - describe('given suggestPipeline feature flag is not enabled', () => { + describe('shouldRenderSourceBranchRemovalStatus', () => { beforeEach(() => { - gon.features = { suggestPipeline: false }; - vm = mountComponent(MrWidgetOptions, { - mrData: { ...mockData }, - }); + vm.mr.state = 'readyToMerge'; }); - afterEach(() => { - gon.features = {}; + it('should return true when cannot remove source branch and branch will be removed', () => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = true; + + expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(true); }); - it('should not suggest pipelines', () => { - vm.mr.mergeRequestAddCiConfigPath = null; + it('should return false when can remove source branch and branch will be removed', () => { + vm.mr.canRemoveSourceBranch = true; + vm.mr.shouldRemoveSourceBranch = true; - expect(vm.shouldSuggestPipelines).toBeFalsy(); + expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); }); - }); - }); - describe('shouldRenderRelatedLinks', () => { - it('should return false for the initial data', () => { - expect(vm.shouldRenderRelatedLinks).toBeFalsy(); - }); + it('should return false when cannot remove source branch and branch will not be removed', () => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = false; - it('should return true if there is relatedLinks in MR', () => { - Vue.set(vm.mr, 'relatedLinks', {}); + expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); + }); - expect(vm.shouldRenderRelatedLinks).toBeTruthy(); - }); - }); + it('should return false when in merged state', () => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = true; + vm.mr.state = 'merged'; - describe('shouldRenderSourceBranchRemovalStatus', () => { - beforeEach(() => { - vm.mr.state = 'readyToMerge'; - }); + expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); + }); - it('should return true when cannot remove source branch and branch will be removed', () => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = true; + it('should return false when in nothing to merge state', () => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = true; + vm.mr.state = 'nothingToMerge'; - expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(true); + expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); + }); }); - it('should return false when can remove source branch and branch will be removed', () => { - vm.mr.canRemoveSourceBranch = true; - vm.mr.shouldRemoveSourceBranch = true; - - expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); - }); + describe('shouldRenderCollaborationStatus', () => { + describe('when collaboration is allowed', () => { + beforeEach(() => { + vm.mr.allowCollaboration = true; + }); - it('should return false when cannot remove source branch and branch will not be removed', () => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = false; + describe('when merge request is opened', () => { + beforeEach(done => { + vm.mr.isOpen = true; + vm.$nextTick(done); + }); - expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); - }); + it('should render collaboration status', () => { + expect(vm.$el.textContent).toContain(COLLABORATION_MESSAGE); + }); + }); - it('should return false when in merged state', () => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = true; - vm.mr.state = 'merged'; + describe('when merge request is not opened', () => { + beforeEach(done => { + vm.mr.isOpen = false; + vm.$nextTick(done); + }); - expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); - }); + it('should not render collaboration status', () => { + expect(vm.$el.textContent).not.toContain(COLLABORATION_MESSAGE); + }); + }); + }); - it('should return false when in nothing to merge state', () => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = true; - vm.mr.state = 'nothingToMerge'; + describe('when collaboration is not allowed', () => { + beforeEach(() => { + vm.mr.allowCollaboration = false; + }); - expect(vm.shouldRenderSourceBranchRemovalStatus).toEqual(false); - }); - }); + describe('when merge request is opened', () => { + beforeEach(done => { + vm.mr.isOpen = true; + vm.$nextTick(done); + }); - describe('shouldRenderCollaborationStatus', () => { - describe('when collaboration is allowed', () => { - beforeEach(() => { - vm.mr.allowCollaboration = true; + it('should not render collaboration status', () => { + expect(vm.$el.textContent).not.toContain(COLLABORATION_MESSAGE); + }); + }); }); + }); - describe('when merge request is opened', () => { + describe('showMergePipelineForkWarning', () => { + describe('when the source project and target project are the same', () => { beforeEach(done => { - vm.mr.isOpen = true; + Vue.set(vm.mr, 'mergePipelinesEnabled', true); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 1); vm.$nextTick(done); }); - it('should render collaboration status', () => { - expect(vm.$el.textContent).toContain(COLLABORATION_MESSAGE); + it('should be false', () => { + expect(vm.showMergePipelineForkWarning).toEqual(false); }); }); - describe('when merge request is not opened', () => { + describe('when merge pipelines are not enabled', () => { beforeEach(done => { - vm.mr.isOpen = false; + Vue.set(vm.mr, 'mergePipelinesEnabled', false); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 2); vm.$nextTick(done); }); - it('should not render collaboration status', () => { - expect(vm.$el.textContent).not.toContain(COLLABORATION_MESSAGE); + it('should be false', () => { + expect(vm.showMergePipelineForkWarning).toEqual(false); }); }); - }); - describe('when collaboration is not allowed', () => { - beforeEach(() => { - vm.mr.allowCollaboration = false; - }); - - describe('when merge request is opened', () => { + describe('when merge pipelines are enabled _and_ the source project and target project are different', () => { beforeEach(done => { - vm.mr.isOpen = true; + Vue.set(vm.mr, 'mergePipelinesEnabled', true); + Vue.set(vm.mr, 'sourceProjectId', 1); + Vue.set(vm.mr, 'targetProjectId', 2); vm.$nextTick(done); }); - it('should not render collaboration status', () => { - expect(vm.$el.textContent).not.toContain(COLLABORATION_MESSAGE); + it('should be true', () => { + expect(vm.showMergePipelineForkWarning).toEqual(true); }); }); }); }); - describe('showMergePipelineForkWarning', () => { - describe('when the source project and target project are the same', () => { - beforeEach(done => { - Vue.set(vm.mr, 'mergePipelinesEnabled', true); - Vue.set(vm.mr, 'sourceProjectId', 1); - Vue.set(vm.mr, 'targetProjectId', 1); - vm.$nextTick(done); - }); + describe('methods', () => { + describe('checkStatus', () => { + it('should tell service to check status', () => { + spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); + spyOn(vm.mr, 'setData'); + spyOn(vm, 'handleNotification'); - it('should be false', () => { - expect(vm.showMergePipelineForkWarning).toEqual(false); - }); - }); - - describe('when merge pipelines are not enabled', () => { - beforeEach(done => { - Vue.set(vm.mr, 'mergePipelinesEnabled', false); - Vue.set(vm.mr, 'sourceProjectId', 1); - Vue.set(vm.mr, 'targetProjectId', 2); - vm.$nextTick(done); - }); - - it('should be false', () => { - expect(vm.showMergePipelineForkWarning).toEqual(false); - }); - }); + let isCbExecuted = false; + const cb = () => { + isCbExecuted = true; + }; - describe('when merge pipelines are enabled _and_ the source project and target project are different', () => { - beforeEach(done => { - Vue.set(vm.mr, 'mergePipelinesEnabled', true); - Vue.set(vm.mr, 'sourceProjectId', 1); - Vue.set(vm.mr, 'targetProjectId', 2); - vm.$nextTick(done); - }); + vm.checkStatus(cb); - it('should be true', () => { - expect(vm.showMergePipelineForkWarning).toEqual(true); + return vm.$nextTick().then(() => { + expect(vm.service.checkStatus).toHaveBeenCalled(); + expect(vm.mr.setData).toHaveBeenCalled(); + expect(vm.handleNotification).toHaveBeenCalledWith(mockData); + expect(isCbExecuted).toBeTruthy(); + }); }); }); - }); - }); - - describe('methods', () => { - describe('checkStatus', () => { - it('should tell service to check status', done => { - spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); - spyOn(vm.mr, 'setData'); - spyOn(vm, 'handleNotification'); - - let isCbExecuted = false; - const cb = () => { - isCbExecuted = true; - }; - - vm.checkStatus(cb); - - setTimeout(() => { - expect(vm.service.checkStatus).toHaveBeenCalled(); - expect(vm.mr.setData).toHaveBeenCalled(); - expect(vm.handleNotification).toHaveBeenCalledWith(mockData); - expect(isCbExecuted).toBeTruthy(); - done(); - }, 333); - }); - }); - describe('initPolling', () => { - it('should call SmartInterval', () => { - spyOn(vm, 'checkStatus').and.returnValue(Promise.resolve()); - jasmine.clock().install(); - vm.initPolling(); + describe('initPolling', () => { + it('should call SmartInterval', () => { + spyOn(vm, 'checkStatus').and.returnValue(Promise.resolve()); + vm.initPolling(); - expect(vm.checkStatus).not.toHaveBeenCalled(); + expect(vm.checkStatus).not.toHaveBeenCalled(); - jasmine.clock().tick(10000); + jasmine.clock().tick(10000); - expect(vm.pollingInterval).toBeDefined(); - expect(vm.checkStatus).toHaveBeenCalled(); - - jasmine.clock().uninstall(); + expect(vm.pollingInterval).toBeDefined(); + expect(vm.checkStatus).toHaveBeenCalled(); + }); }); - }); - describe('initDeploymentsPolling', () => { - it('should call SmartInterval', () => { - spyOn(vm, 'fetchDeployments').and.returnValue(Promise.resolve()); - vm.initDeploymentsPolling(); + describe('initDeploymentsPolling', () => { + it('should call SmartInterval', () => { + spyOn(vm, 'fetchDeployments').and.returnValue(Promise.resolve()); + vm.initDeploymentsPolling(); - expect(vm.deploymentsInterval).toBeDefined(); - expect(vm.fetchDeployments).toHaveBeenCalled(); + expect(vm.deploymentsInterval).toBeDefined(); + expect(vm.fetchDeployments).toHaveBeenCalled(); + }); }); - }); - describe('fetchDeployments', () => { - it('should fetch deployments', done => { - spyOn(vm.service, 'fetchDeployments').and.returnValue( - returnPromise([{ id: 1, status: SUCCESS }]), - ); + describe('fetchDeployments', () => { + it('should fetch deployments', () => { + spyOn(vm.service, 'fetchDeployments').and.returnValue( + returnPromise([{ id: 1, status: SUCCESS }]), + ); - vm.fetchPreMergeDeployments(); + vm.fetchPreMergeDeployments(); - setTimeout(() => { - expect(vm.service.fetchDeployments).toHaveBeenCalled(); - expect(vm.mr.deployments.length).toEqual(1); - expect(vm.mr.deployments[0].id).toBe(1); - done(); + return vm.$nextTick().then(() => { + expect(vm.service.fetchDeployments).toHaveBeenCalled(); + expect(vm.mr.deployments.length).toEqual(1); + expect(vm.mr.deployments[0].id).toBe(1); + }); }); }); - }); - describe('fetchActionsContent', () => { - it('should fetch content of Cherry Pick and Revert modals', done => { - spyOn(vm.service, 'fetchMergeActionsContent').and.returnValue(returnPromise('hello world')); + describe('fetchActionsContent', () => { + it('should fetch content of Cherry Pick and Revert modals', () => { + spyOn(vm.service, 'fetchMergeActionsContent').and.returnValue( + returnPromise('hello world'), + ); - vm.fetchActionsContent(); + vm.fetchActionsContent(); - setTimeout(() => { - expect(vm.service.fetchMergeActionsContent).toHaveBeenCalled(); - expect(document.body.textContent).toContain('hello world'); - done(); - }, 333); + return vm.$nextTick().then(() => { + expect(vm.service.fetchMergeActionsContent).toHaveBeenCalled(); + expect(document.body.textContent).toContain('hello world'); + }); + }); }); - }); - describe('bindEventHubListeners', () => { - it('should bind eventHub listeners', done => { - spyOn(vm, 'checkStatus').and.returnValue(() => {}); - spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); - spyOn(vm, 'fetchActionsContent'); - spyOn(vm.mr, 'setData'); - spyOn(vm, 'resumePolling'); - spyOn(vm, 'stopPolling'); - spyOn(eventHub, '$on').and.callThrough(); + describe('bindEventHubListeners', () => { + it('should bind eventHub listeners', () => { + spyOn(vm, 'checkStatus').and.returnValue(() => {}); + spyOn(vm.service, 'checkStatus').and.returnValue(returnPromise(mockData)); + spyOn(vm, 'fetchActionsContent'); + spyOn(vm.mr, 'setData'); + spyOn(vm, 'resumePolling'); + spyOn(vm, 'stopPolling'); + spyOn(eventHub, '$on').and.callThrough(); - setTimeout(() => { - eventHub.$emit('SetBranchRemoveFlag', ['flag']); + return waitForPromises().then(() => { + eventHub.$emit('SetBranchRemoveFlag', ['flag']); - expect(vm.mr.isRemovingSourceBranch).toEqual('flag'); + expect(vm.mr.isRemovingSourceBranch).toEqual('flag'); - eventHub.$emit('FailedToMerge'); + eventHub.$emit('FailedToMerge'); - expect(vm.mr.state).toEqual('failedToMerge'); + expect(vm.mr.state).toEqual('failedToMerge'); - eventHub.$emit('UpdateWidgetData', mockData); + eventHub.$emit('UpdateWidgetData', mockData); - expect(vm.mr.setData).toHaveBeenCalledWith(mockData); + expect(vm.mr.setData).toHaveBeenCalledWith(mockData); - eventHub.$emit('EnablePolling'); + eventHub.$emit('EnablePolling'); - expect(vm.resumePolling).toHaveBeenCalled(); + expect(vm.resumePolling).toHaveBeenCalled(); - eventHub.$emit('DisablePolling'); + eventHub.$emit('DisablePolling'); - expect(vm.stopPolling).toHaveBeenCalled(); - - const listenersWithServiceRequest = { - MRWidgetUpdateRequested: true, - FetchActionsContent: true, - }; + expect(vm.stopPolling).toHaveBeenCalled(); - const allArgs = eventHub.$on.calls.allArgs(); - allArgs.forEach(params => { - const eventName = params[0]; - const callback = params[1]; + const listenersWithServiceRequest = { + MRWidgetUpdateRequested: true, + FetchActionsContent: true, + }; - if (listenersWithServiceRequest[eventName]) { - listenersWithServiceRequest[eventName] = callback; - } - }); + const allArgs = eventHub.$on.calls.allArgs(); + allArgs.forEach(params => { + const eventName = params[0]; + const callback = params[1]; - listenersWithServiceRequest.MRWidgetUpdateRequested(); + if (listenersWithServiceRequest[eventName]) { + listenersWithServiceRequest[eventName] = callback; + } + }); - expect(vm.checkStatus).toHaveBeenCalled(); + listenersWithServiceRequest.MRWidgetUpdateRequested(); - listenersWithServiceRequest.FetchActionsContent(); + expect(vm.checkStatus).toHaveBeenCalled(); - expect(vm.fetchActionsContent).toHaveBeenCalled(); + listenersWithServiceRequest.FetchActionsContent(); - done(); + expect(vm.fetchActionsContent).toHaveBeenCalled(); + }); }); }); - }); - describe('setFavicon', () => { - let faviconElement; + describe('setFavicon', () => { + let faviconElement; - beforeEach(() => { - const favicon = document.createElement('link'); - favicon.setAttribute('id', 'favicon'); - favicon.setAttribute('data-original-href', faviconDataUrl); - document.body.appendChild(favicon); + beforeEach(() => { + const favicon = document.createElement('link'); + favicon.setAttribute('id', 'favicon'); + favicon.setAttribute('data-original-href', faviconDataUrl); + document.body.appendChild(favicon); - faviconElement = document.getElementById('favicon'); - }); + faviconElement = document.getElementById('favicon'); + }); - afterEach(() => { - document.body.removeChild(document.getElementById('favicon')); - }); + afterEach(() => { + document.body.removeChild(document.getElementById('favicon')); + }); - it('should call setFavicon method', done => { - vm.mr.ciStatusFaviconPath = overlayDataUrl; - vm.setFaviconHelper() - .then(() => { - /* + it('should call setFavicon method', done => { + vm.mr.ciStatusFaviconPath = overlayDataUrl; + vm.setFaviconHelper() + .then(() => { + /* It would be better if we'd could mock commonUtils.setFaviconURL with a spy and test that it was called. We are doing the following tests as a proxy to show that the function has been called */ - expect(faviconElement.getAttribute('href')).not.toEqual(null); - expect(faviconElement.getAttribute('href')).not.toEqual(overlayDataUrl); - expect(faviconElement.getAttribute('href')).not.toEqual(faviconDataUrl); - done(); - }) - .catch(done.fail); - }); + expect(faviconElement.getAttribute('href')).not.toEqual(null); + expect(faviconElement.getAttribute('href')).not.toEqual(overlayDataUrl); + expect(faviconElement.getAttribute('href')).not.toEqual(faviconDataUrl); + done(); + }) + .catch(done.fail); + }); - it('should not call setFavicon when there is no ciStatusFaviconPath', done => { - vm.mr.ciStatusFaviconPath = null; - vm.setFaviconHelper() - .then(() => { - expect(faviconElement.getAttribute('href')).toEqual(null); - done(); - }) - .catch(done.fail); + it('should not call setFavicon when there is no ciStatusFaviconPath', done => { + vm.mr.ciStatusFaviconPath = null; + vm.setFaviconHelper() + .then(() => { + expect(faviconElement.getAttribute('href')).toEqual(null); + done(); + }) + .catch(done.fail); + }); }); - }); - describe('handleNotification', () => { - const data = { - ci_status: 'running', - title: 'title', - pipeline: { details: { status: { label: 'running-label' } } }, - }; + describe('handleNotification', () => { + const data = { + ci_status: 'running', + title: 'title', + pipeline: { details: { status: { label: 'running-label' } } }, + }; - beforeEach(() => { - spyOn(notify, 'notifyMe'); + beforeEach(() => { + spyOn(notify, 'notifyMe'); - vm.mr.ciStatus = 'failed'; - vm.mr.gitlabLogo = 'logo.png'; - }); + vm.mr.ciStatus = 'failed'; + vm.mr.gitlabLogo = 'logo.png'; + }); - it('should call notifyMe', () => { - vm.handleNotification(data); + it('should call notifyMe', () => { + vm.handleNotification(data); - expect(notify.notifyMe).toHaveBeenCalledWith( - 'Pipeline running-label', - 'Pipeline running-label for "title"', - 'logo.png', - ); - }); - - it('should not call notifyMe if the status has not changed', () => { - vm.mr.ciStatus = data.ci_status; + expect(notify.notifyMe).toHaveBeenCalledWith( + 'Pipeline running-label', + 'Pipeline running-label for "title"', + 'logo.png', + ); + }); - vm.handleNotification(data); + it('should not call notifyMe if the status has not changed', () => { + vm.mr.ciStatus = data.ci_status; - expect(notify.notifyMe).not.toHaveBeenCalled(); - }); + vm.handleNotification(data); - it('should not notify if no pipeline provided', () => { - vm.handleNotification({ - ...data, - pipeline: undefined, + expect(notify.notifyMe).not.toHaveBeenCalled(); }); - expect(notify.notifyMe).not.toHaveBeenCalled(); - }); - }); + it('should not notify if no pipeline provided', () => { + vm.handleNotification({ + ...data, + pipeline: undefined, + }); - describe('resumePolling', () => { - it('should call stopTimer on pollingInterval', done => { - setTimeout(() => { - spyOn(vm.pollingInterval, 'resume'); + expect(notify.notifyMe).not.toHaveBeenCalled(); + }); + }); - vm.resumePolling(); + describe('resumePolling', () => { + it('should call stopTimer on pollingInterval', () => + waitForPromises().then(() => { + spyOn(vm.pollingInterval, 'resume'); - expect(vm.pollingInterval.resume).toHaveBeenCalled(); + vm.resumePolling(); - done(); - }); + expect(vm.pollingInterval.resume).toHaveBeenCalled(); + })); }); - }); - describe('stopPolling', () => { - it('should call stopTimer on pollingInterval', done => { - setTimeout(() => { - spyOn(vm.pollingInterval, 'stopTimer'); + describe('stopPolling', () => { + it('should call stopTimer on pollingInterval', () => + waitForPromises().then(() => { + spyOn(vm.pollingInterval, 'stopTimer'); - vm.stopPolling(); + vm.stopPolling(); - expect(vm.pollingInterval.stopTimer).toHaveBeenCalled(); - - done(); - }); + expect(vm.pollingInterval.stopTimer).toHaveBeenCalled(); + })); }); }); - }); - describe('rendering relatedLinks', () => { - beforeEach(done => { - vm.mr.relatedLinks = { - assignToMe: null, - closing: ` + describe('rendering relatedLinks', () => { + beforeEach(done => { + vm.mr.relatedLinks = { + assignToMe: null, + closing: ` <a class="close-related-link" href="#"> Close </a> `, - mentioned: '', - }; - Vue.nextTick(done); - }); + mentioned: '', + }; + Vue.nextTick(done); + }); - it('renders if there are relatedLinks', () => { - expect(vm.$el.querySelector('.close-related-link')).toBeDefined(); - }); + it('renders if there are relatedLinks', () => { + expect(vm.$el.querySelector('.close-related-link')).toBeDefined(); + }); - it('does not render if state is nothingToMerge', done => { - vm.mr.state = stateKey.nothingToMerge; - Vue.nextTick(() => { - expect(vm.$el.querySelector('.close-related-link')).toBeNull(); - done(); + it('does not render if state is nothingToMerge', done => { + vm.mr.state = stateKey.nothingToMerge; + Vue.nextTick(() => { + expect(vm.$el.querySelector('.close-related-link')).toBeNull(); + done(); + }); }); }); - }); - describe('rendering source branch removal status', () => { - it('renders when user cannot remove branch and branch should be removed', done => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = true; - vm.mr.state = 'readyToMerge'; + describe('rendering source branch removal status', () => { + it('renders when user cannot remove branch and branch should be removed', done => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = true; + vm.mr.state = 'readyToMerge'; - vm.$nextTick(() => { - const tooltip = vm.$el.querySelector('.fa-question-circle'); + vm.$nextTick(() => { + const tooltip = vm.$el.querySelector('.fa-question-circle'); - expect(vm.$el.textContent).toContain('Deletes source branch'); - expect(tooltip.getAttribute('data-original-title')).toBe( - 'A user with write access to the source branch selected this option', - ); + expect(vm.$el.textContent).toContain('Deletes source branch'); + expect(tooltip.getAttribute('data-original-title')).toBe( + 'A user with write access to the source branch selected this option', + ); - done(); + done(); + }); }); - }); - it('does not render in merged state', done => { - vm.mr.canRemoveSourceBranch = false; - vm.mr.shouldRemoveSourceBranch = true; - vm.mr.state = 'merged'; + it('does not render in merged state', done => { + vm.mr.canRemoveSourceBranch = false; + vm.mr.shouldRemoveSourceBranch = true; + vm.mr.state = 'merged'; - vm.$nextTick(() => { - expect(vm.$el.textContent).toContain('The source branch has been deleted'); - expect(vm.$el.textContent).not.toContain('Deletes source branch'); + vm.$nextTick(() => { + expect(vm.$el.textContent).toContain('The source branch has been deleted'); + expect(vm.$el.textContent).not.toContain('Deletes source branch'); - done(); + done(); + }); }); }); - }); - describe('rendering deployments', () => { - const changes = [ - { - path: 'index.html', - external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html', - }, - { - path: 'imgs/gallery.html', - external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html', - }, - { - path: 'about/', - external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/', - }, - ]; - const deploymentMockData = { - id: 15, - name: 'review/diplo', - url: '/root/acets-review-apps/environments/15', - stop_url: '/root/acets-review-apps/environments/15/stop', - metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics', - metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics', - external_url: 'http://diplo.', - external_url_formatted: 'diplo.', - deployed_at: '2017-03-22T22:44:42.258Z', - deployed_at_formatted: 'Mar 22, 2017 10:44pm', - changes, - status: SUCCESS, - }; - - beforeEach(done => { - vm.mr.deployments.push( + describe('rendering deployments', () => { + const changes = [ + { + path: 'index.html', + external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html', + }, { - ...deploymentMockData, + path: 'imgs/gallery.html', + external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html', }, { - ...deploymentMockData, - id: deploymentMockData.id + 1, + path: 'about/', + external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/', }, - ); + ]; + const deploymentMockData = { + id: 15, + name: 'review/diplo', + url: '/root/acets-review-apps/environments/15', + stop_url: '/root/acets-review-apps/environments/15/stop', + metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics', + metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics', + external_url: 'http://diplo.', + external_url_formatted: 'diplo.', + deployed_at: '2017-03-22T22:44:42.258Z', + deployed_at_formatted: 'Mar 22, 2017 10:44pm', + changes, + status: SUCCESS, + }; - vm.$nextTick(done); - }); + beforeEach(done => { + vm.mr.deployments.push( + { + ...deploymentMockData, + }, + { + ...deploymentMockData, + id: deploymentMockData.id + 1, + }, + ); - it('renders multiple deployments', () => { - expect(vm.$el.querySelectorAll('.deploy-heading').length).toBe(2); - }); + vm.$nextTick(done); + }); + + it('renders multiple deployments', () => { + expect(vm.$el.querySelectorAll('.deploy-heading').length).toBe(2); + }); - it('renders dropdpown with multiple file changes', () => { - expect( - vm.$el - .querySelector('.js-mr-wigdet-deployment-dropdown') - .querySelectorAll('.js-filtered-dropdown-result').length, - ).toEqual(changes.length); + it('renders dropdpown with multiple file changes', () => { + expect( + vm.$el + .querySelector('.js-mr-wigdet-deployment-dropdown') + .querySelectorAll('.js-filtered-dropdown-result').length, + ).toEqual(changes.length); + }); }); - }); - describe('pipeline for target branch after merge', () => { - describe('with information for target branch pipeline', () => { - beforeEach(done => { - vm.mr.state = 'merged'; - vm.mr.mergePipeline = { - id: 127, - user: { - id: 1, - name: 'Administrator', - username: 'root', - state: 'active', - avatar_url: null, - web_url: 'http://localhost:3000/root', - status_tooltip_html: null, - path: '/root', - }, - active: true, - coverage: null, - source: 'push', - created_at: '2018-10-22T11:41:35.186Z', - updated_at: '2018-10-22T11:41:35.433Z', - path: '/root/ci-web-terminal/pipelines/127', - flags: { - latest: true, - stuck: true, - auto_devops: false, - yaml_errors: false, - retryable: false, - cancelable: true, - failure_reason: false, - }, - details: { - status: { - icon: 'status_pending', - text: 'pending', - label: 'pending', - group: 'pending', - tooltip: 'pending', - has_details: true, - details_path: '/root/ci-web-terminal/pipelines/127', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png', - }, - duration: null, - finished_at: null, - stages: [ - { - name: 'test', - title: 'test: pending', - status: { - icon: 'status_pending', - text: 'pending', - label: 'pending', - group: 'pending', - tooltip: 'pending', - has_details: true, - details_path: '/root/ci-web-terminal/pipelines/127#test', - illustration: null, - favicon: - '/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png', - }, - path: '/root/ci-web-terminal/pipelines/127#test', - dropdown_path: '/root/ci-web-terminal/pipelines/127/stage.json?stage=test', - }, - ], - artifacts: [], - manual_actions: [], - scheduled_actions: [], - }, - ref: { - name: 'master', - path: '/root/ci-web-terminal/commits/master', - tag: false, - branch: true, - }, - commit: { - id: 'aa1939133d373c94879becb79d91828a892ee319', - short_id: 'aa193913', - title: "Merge branch 'master-test' into 'master'", - created_at: '2018-10-22T11:41:33.000Z', - parent_ids: [ - '4622f4dd792468993003caf2e3be978798cbe096', - '76598df914cdfe87132d0c3c40f80db9fa9396a4', - ], - message: - "Merge branch 'master-test' into 'master'\n\nUpdate .gitlab-ci.yml\n\nSee merge request root/ci-web-terminal!1", - author_name: 'Administrator', - author_email: 'admin@example.com', - authored_date: '2018-10-22T11:41:33.000Z', - committer_name: 'Administrator', - committer_email: 'admin@example.com', - committed_date: '2018-10-22T11:41:33.000Z', - author: { + describe('pipeline for target branch after merge', () => { + describe('with information for target branch pipeline', () => { + beforeEach(done => { + vm.mr.state = 'merged'; + vm.mr.mergePipeline = { + id: 127, + user: { id: 1, name: 'Administrator', username: 'root', @@ -768,88 +632,211 @@ describe('mrWidgetOptions', () => { status_tooltip_html: null, path: '/root', }, - author_gravatar_url: null, - commit_url: - 'http://localhost:3000/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319', - commit_path: '/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319', - }, - cancel_path: '/root/ci-web-terminal/pipelines/127/cancel', - }; - vm.$nextTick(done); + active: true, + coverage: null, + source: 'push', + created_at: '2018-10-22T11:41:35.186Z', + updated_at: '2018-10-22T11:41:35.433Z', + path: '/root/ci-web-terminal/pipelines/127', + flags: { + latest: true, + stuck: true, + auto_devops: false, + yaml_errors: false, + retryable: false, + cancelable: true, + failure_reason: false, + }, + details: { + status: { + icon: 'status_pending', + text: 'pending', + label: 'pending', + group: 'pending', + tooltip: 'pending', + has_details: true, + details_path: '/root/ci-web-terminal/pipelines/127', + illustration: null, + favicon: + '/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png', + }, + duration: null, + finished_at: null, + stages: [ + { + name: 'test', + title: 'test: pending', + status: { + icon: 'status_pending', + text: 'pending', + label: 'pending', + group: 'pending', + tooltip: 'pending', + has_details: true, + details_path: '/root/ci-web-terminal/pipelines/127#test', + illustration: null, + favicon: + '/assets/ci_favicons/favicon_status_pending-5bdf338420e5221ca24353b6bff1c9367189588750632e9a871b7af09ff6a2ae.png', + }, + path: '/root/ci-web-terminal/pipelines/127#test', + dropdown_path: '/root/ci-web-terminal/pipelines/127/stage.json?stage=test', + }, + ], + artifacts: [], + manual_actions: [], + scheduled_actions: [], + }, + ref: { + name: 'master', + path: '/root/ci-web-terminal/commits/master', + tag: false, + branch: true, + }, + commit: { + id: 'aa1939133d373c94879becb79d91828a892ee319', + short_id: 'aa193913', + title: "Merge branch 'master-test' into 'master'", + created_at: '2018-10-22T11:41:33.000Z', + parent_ids: [ + '4622f4dd792468993003caf2e3be978798cbe096', + '76598df914cdfe87132d0c3c40f80db9fa9396a4', + ], + message: + "Merge branch 'master-test' into 'master'\n\nUpdate .gitlab-ci.yml\n\nSee merge request root/ci-web-terminal!1", + author_name: 'Administrator', + author_email: 'admin@example.com', + authored_date: '2018-10-22T11:41:33.000Z', + committer_name: 'Administrator', + committer_email: 'admin@example.com', + committed_date: '2018-10-22T11:41:33.000Z', + author: { + id: 1, + name: 'Administrator', + username: 'root', + state: 'active', + avatar_url: null, + web_url: 'http://localhost:3000/root', + status_tooltip_html: null, + path: '/root', + }, + author_gravatar_url: null, + commit_url: + 'http://localhost:3000/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319', + commit_path: '/root/ci-web-terminal/commit/aa1939133d373c94879becb79d91828a892ee319', + }, + cancel_path: '/root/ci-web-terminal/pipelines/127/cancel', + }; + vm.$nextTick(done); + }); + + it('renders pipeline block', () => { + expect(vm.$el.querySelector('.js-post-merge-pipeline')).not.toBeNull(); + }); + + describe('with post merge deployments', () => { + beforeEach(done => { + vm.mr.postMergeDeployments = [ + { + id: 15, + name: 'review/diplo', + url: '/root/acets-review-apps/environments/15', + stop_url: '/root/acets-review-apps/environments/15/stop', + metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics', + metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics', + external_url: 'http://diplo.', + external_url_formatted: 'diplo.', + deployed_at: '2017-03-22T22:44:42.258Z', + deployed_at_formatted: 'Mar 22, 2017 10:44pm', + changes: [ + { + path: 'index.html', + external_url: + 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html', + }, + { + path: 'imgs/gallery.html', + external_url: + 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html', + }, + { + path: 'about/', + external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/', + }, + ], + status: 'success', + }, + ]; + + vm.$nextTick(done); + }); + + it('renders post deployment information', () => { + expect(vm.$el.querySelector('.js-post-deployment')).not.toBeNull(); + }); + }); }); - it('renders pipeline block', () => { - expect(vm.$el.querySelector('.js-post-merge-pipeline')).not.toBeNull(); + describe('without information for target branch pipeline', () => { + beforeEach(done => { + vm.mr.state = 'merged'; + + vm.$nextTick(done); + }); + + it('does not render pipeline block', () => { + expect(vm.$el.querySelector('.js-post-merge-pipeline')).toBeNull(); + }); }); - describe('with post merge deployments', () => { + describe('when state is not merged', () => { beforeEach(done => { - vm.mr.postMergeDeployments = [ - { - id: 15, - name: 'review/diplo', - url: '/root/acets-review-apps/environments/15', - stop_url: '/root/acets-review-apps/environments/15/stop', - metrics_url: '/root/acets-review-apps/environments/15/deployments/1/metrics', - metrics_monitoring_url: '/root/acets-review-apps/environments/15/metrics', - external_url: 'http://diplo.', - external_url_formatted: 'diplo.', - deployed_at: '2017-03-22T22:44:42.258Z', - deployed_at_formatted: 'Mar 22, 2017 10:44pm', - changes: [ - { - path: 'index.html', - external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/index.html', - }, - { - path: 'imgs/gallery.html', - external_url: - 'http://root-master-patch-91341.volatile-watch.surge.sh/imgs/gallery.html', - }, - { - path: 'about/', - external_url: 'http://root-master-patch-91341.volatile-watch.surge.sh/about/', - }, - ], - status: 'success', - }, - ]; + vm.mr.state = 'archived'; vm.$nextTick(done); }); - it('renders post deployment information', () => { - expect(vm.$el.querySelector('.js-post-deployment')).not.toBeNull(); + it('does not render pipeline block', () => { + expect(vm.$el.querySelector('.js-post-merge-pipeline')).toBeNull(); + }); + + it('does not render post deployment information', () => { + expect(vm.$el.querySelector('.js-post-deployment')).toBeNull(); }); }); }); - describe('without information for target branch pipeline', () => { - beforeEach(done => { - vm.mr.state = 'merged'; + it('should not suggest pipelines', () => { + vm.mr.mergeRequestAddCiConfigPath = null; - vm.$nextTick(done); - }); + expect(vm.shouldSuggestPipelines).toBeFalsy(); + }); + }); - it('does not render pipeline block', () => { - expect(vm.$el.querySelector('.js-post-merge-pipeline')).toBeNull(); - }); + describe('given suggestPipeline feature flag is enabled', () => { + beforeEach(() => { + gon.features = { suggestPipeline: true }; + createComponent(); }); - describe('when state is not merged', () => { - beforeEach(done => { - vm.mr.state = 'archived'; + it('should suggest pipelines when none exist', () => { + vm.mr.mergeRequestAddCiConfigPath = 'some/path'; + vm.mr.hasCI = false; - vm.$nextTick(done); - }); + expect(vm.shouldSuggestPipelines).toBeTruthy(); + }); - it('does not render pipeline block', () => { - expect(vm.$el.querySelector('.js-post-merge-pipeline')).toBeNull(); - }); + it('should not suggest pipelines when they exist', () => { + vm.mr.mergeRequestAddCiConfigPath = null; + vm.mr.hasCI = false; - it('does not render post deployment information', () => { - expect(vm.$el.querySelector('.js-post-deployment')).toBeNull(); - }); + expect(vm.shouldSuggestPipelines).toBeFalsy(); + }); + + it('should not suggest pipelines hasCI is true', () => { + vm.mr.mergeRequestAddCiConfigPath = 'some/path'; + vm.mr.hasCI = true; + + expect(vm.shouldSuggestPipelines).toBeFalsy(); }); }); }); diff --git a/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb new file mode 100644 index 00000000000..d3b108f60ff --- /dev/null +++ b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb @@ -0,0 +1,49 @@ +# 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 diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 076897e6312..58f17a3661f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2381,7 +2381,7 @@ describe Repository do end end - describe '#tree' do + shared_examples '#tree' do context 'using a non-existing repository' do before do allow(repository).to receive(:head_commit).and_return(nil) @@ -2399,10 +2399,17 @@ describe Repository do context 'using an existing repository' do it 'returns a Tree' do 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 + it_behaves_like '#tree' + + describe '#tree? with Rugged enabled', :enable_rugged do + it_behaves_like '#tree' + end + describe '#size' do context 'with a non-existing repository' do it 'returns 0' do diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb index 6b774e9335e..8c411233b27 100644 --- a/spec/requests/api/pages_domains_spec.rb +++ b/spec/requests/api/pages_domains_spec.rb @@ -49,7 +49,7 @@ describe API::PagesDomains do it 'returns paginated all pages domains' do get api('/pages/domains', admin) - 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/pages_domain_basics') expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -76,7 +76,7 @@ describe API::PagesDomains do it 'returns paginated pages domains' do get api(route, 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/pages_domains') expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -147,7 +147,7 @@ describe API::PagesDomains do it 'returns pages domain' do get api(route_domain, 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/pages_domain/detail') expect(json_response['domain']).to eq(pages_domain.domain) expect(json_response['url']).to eq(pages_domain.url) @@ -157,7 +157,7 @@ describe API::PagesDomains do it 'returns pages domain with project path' do get api(route_domain_path, 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/pages_domain/detail') expect(json_response['domain']).to eq(pages_domain.domain) expect(json_response['url']).to eq(pages_domain.url) @@ -167,7 +167,7 @@ describe API::PagesDomains do it 'returns pages domain with a certificate' do get api(route_secure_domain, 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/pages_domain/detail') expect(json_response['domain']).to eq(pages_domain_secure.domain) expect(json_response['url']).to eq(pages_domain_secure.url) @@ -179,7 +179,7 @@ describe API::PagesDomains do it 'returns pages domain with an expired certificate' do get api(route_expired_domain, 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/pages_domain/detail') expect(json_response['certificate']['expired']).to be true end @@ -187,7 +187,7 @@ describe API::PagesDomains do it 'returns pages domain with letsencrypt' do get api(route_letsencrypt_domain, 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/pages_domain/detail') expect(json_response['domain']).to eq(pages_domain_with_letsencrypt.domain) expect(json_response['url']).to eq(pages_domain_with_letsencrypt.url) @@ -261,7 +261,7 @@ describe API::PagesDomains do post api(route, user), params: params pages_domain = PagesDomain.find_by(domain: json_response['domain']) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('public_api/v4/pages_domain/detail') expect(pages_domain.domain).to eq(params[:domain]) expect(pages_domain.certificate).to be_nil @@ -273,7 +273,7 @@ describe API::PagesDomains do post api(route, user), params: params_secure pages_domain = PagesDomain.find_by(domain: json_response['domain']) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('public_api/v4/pages_domain/detail') expect(pages_domain.domain).to eq(params_secure[:domain]) expect(pages_domain.certificate).to eq(params_secure[:certificate]) @@ -285,7 +285,7 @@ describe API::PagesDomains do post api(route, user), params: pages_domain_with_letsencrypt_params pages_domain = PagesDomain.find_by(domain: json_response['domain']) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('public_api/v4/pages_domain/detail') expect(pages_domain.domain).to eq(pages_domain_with_letsencrypt_params[:domain]) expect(pages_domain.auto_ssl_enabled).to be true @@ -295,7 +295,7 @@ describe API::PagesDomains do post api(route, user), params: params_secure.merge(auto_ssl_enabled: true) pages_domain = PagesDomain.find_by(domain: json_response['domain']) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('public_api/v4/pages_domain/detail') expect(pages_domain.domain).to eq(params_secure[:domain]) expect(pages_domain.certificate).to eq(params_secure[:certificate]) @@ -306,13 +306,13 @@ describe API::PagesDomains do it 'fails to create pages domain without key' do post api(route, user), params: pages_domain_secure_params.slice(:domain, :certificate) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'fails to create pages domain with key missmatch' do post api(route, user), params: pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -370,7 +370,7 @@ describe API::PagesDomains do put api(route_secure_domain, user), params: { certificate: nil, key: nil } pages_domain_secure.reload - 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/pages_domain/detail') expect(pages_domain_secure.certificate).to be_nil expect(pages_domain_secure.key).to be_nil @@ -381,7 +381,7 @@ describe API::PagesDomains do put api(route_domain, user), params: params_secure pages_domain.reload - 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/pages_domain/detail') expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.key).to eq(params_secure[:key]) @@ -391,7 +391,7 @@ describe API::PagesDomains do put api(route_domain, user), params: params_secure.merge(auto_ssl_enabled: true) pages_domain.reload - 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/pages_domain/detail') expect(pages_domain.certificate).to eq(params_secure[:certificate]) expect(pages_domain.key).to eq(params_secure[:key]) @@ -402,7 +402,7 @@ describe API::PagesDomains do put api(route_domain, user), params: { auto_ssl_enabled: true } pages_domain.reload - 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/pages_domain/detail') expect(pages_domain.auto_ssl_enabled).to be true end @@ -411,7 +411,7 @@ describe API::PagesDomains do put api(route_letsencrypt_domain, user), params: { auto_ssl_enabled: false } pages_domain_with_letsencrypt.reload - 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/pages_domain/detail') expect(pages_domain_with_letsencrypt.auto_ssl_enabled).to be false expect(pages_domain_with_letsencrypt.key).to be @@ -422,7 +422,7 @@ describe API::PagesDomains do put api(route_expired_domain, user), params: params_secure pages_domain_expired.reload - 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/pages_domain/detail') expect(pages_domain_expired.certificate).to eq(params_secure[:certificate]) expect(pages_domain_expired.key).to eq(params_secure[:key]) @@ -432,7 +432,7 @@ describe API::PagesDomains do put api(route_secure_domain, user), params: params_secure_nokey pages_domain_secure.reload - 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/pages_domain/detail') expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate]) end @@ -448,19 +448,19 @@ describe API::PagesDomains do it 'fails to update pages domain adding certificate without key' do put api(route_domain, user), params: params_secure_nokey - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'fails to update pages domain adding certificate with missing chain' do put api(route_domain, user), params: pages_domain_secure_missing_chain_params.slice(:certificate) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'fails to update pages domain with key missmatch' do put api(route_secure_domain, user), params: pages_domain_secure_key_missmatch_params.slice(:certificate, :key) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -524,7 +524,7 @@ describe API::PagesDomains do it 'deletes a pages domain' do delete api(route_domain, user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index fdb9508ed08..05abdf76be9 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -289,7 +289,7 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer) 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 it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 75e3013d362..b38b92af139 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -23,7 +23,7 @@ describe API::Pipelines do it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['sha']).to match /\A\h{40}\z/ @@ -294,7 +294,7 @@ describe API::Pipelines do it 'does not return project pipelines' do get api("/projects/#{project.id}/pipelines", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -323,7 +323,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } end.to change { project.ci_pipelines.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id end @@ -337,7 +337,7 @@ describe API::Pipelines do end.to change { project.ci_pipelines.count }.by(1) expect_variables(project.ci_pipelines.last.variables, variables) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id expect(json_response).not_to have_key('variables') @@ -358,7 +358,7 @@ describe API::Pipelines do end.to change { project.ci_pipelines.count }.by(1) expect_variables(project.ci_pipelines.last.variables, variables) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id expect(json_response).not_to have_key('variables') @@ -372,7 +372,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } end.not_to change { project.ci_pipelines.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -380,7 +380,7 @@ describe API::Pipelines do it 'fails when using an invalid ref' do post api("/projects/#{project.id}/pipeline", user), params: { ref: 'invalid_ref' } - 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 'Reference not found' expect(json_response).not_to be_an Array end @@ -395,7 +395,7 @@ describe API::Pipelines do it 'fails to create pipeline' do post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } - 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 'Missing CI config file' expect(json_response).not_to be_an Array end @@ -407,7 +407,7 @@ describe API::Pipelines do it 'does not create pipeline' do post api("/projects/#{project.id}/pipeline", non_member), params: { ref: project.default_branch } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -428,21 +428,21 @@ describe API::Pipelines do it 'exposes known attributes' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", 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/pipeline/detail') end it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['sha']).to match /\A\h{40}\z/ end it 'returns 404 when it does not exist' do get api("/projects/#{project.id}/pipelines/123456", 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['id']).to be nil end @@ -464,7 +464,7 @@ describe API::Pipelines do it 'does not return a project pipeline' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -489,7 +489,7 @@ describe API::Pipelines do it 'gets the latest pipleine' do get api("/projects/#{project.id}/pipelines/latest", 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/pipeline/detail') expect(json_response['ref']).to eq(project.default_branch) expect(json_response['sha']).to eq(project.commit.id) @@ -500,7 +500,7 @@ describe API::Pipelines do it 'gets the latest pipleine' do get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name } - 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/pipeline/detail') expect(json_response['ref']).to eq(second_branch.name) expect(json_response['sha']).to eq(second_branch.target) @@ -512,7 +512,7 @@ describe API::Pipelines do it 'does not return a project pipeline' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -528,7 +528,7 @@ describe API::Pipelines do it 'returns pipeline variables empty' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end @@ -538,7 +538,7 @@ describe API::Pipelines do it 'returns pipeline variables' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" }) end end @@ -559,7 +559,7 @@ describe API::Pipelines do it 'returns pipeline variables' do subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly({ "variable_type" => "env_var", "key" => "foo", "value" => "bar" }) end end @@ -570,7 +570,7 @@ describe API::Pipelines do it 'does not return pipeline variables' do subject - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -579,7 +579,7 @@ describe API::Pipelines do it 'does not return pipeline variables' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' end end @@ -592,14 +592,14 @@ describe API::Pipelines do it 'destroys the pipeline' do delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound) end it 'returns 404 when it does not exist' do delete api("/projects/#{project.id}/pipelines/123456", owner) - 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' end @@ -613,7 +613,7 @@ describe API::Pipelines do it 'destroys associated jobs' do delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect { build.reload }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -624,7 +624,7 @@ describe API::Pipelines do it 'returns a 404' do delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' end end @@ -639,7 +639,7 @@ describe API::Pipelines do it 'returns a 403' do delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", 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' end end @@ -660,7 +660,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) end.to change { pipeline.builds.count }.from(1).to(2) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(build.reload.retried?).to be true end end @@ -669,7 +669,7 @@ describe API::Pipelines do it 'does not return a project pipeline' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -688,7 +688,7 @@ describe API::Pipelines do it 'retries failed builds', :sidekiq_might_not_need_inline do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['status']).to eq('canceled') end end @@ -703,7 +703,7 @@ describe API::Pipelines do it 'rejects the action' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) expect(pipeline.reload.status).to eq('pending') end end diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb index f3d005322f2..7cef40ff3b5 100644 --- a/spec/requests/api/project_clusters_spec.rb +++ b/spec/requests/api/project_clusters_spec.rb @@ -26,7 +26,7 @@ describe API::ProjectClusters do it 'responds with 403' do 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 @@ -36,7 +36,7 @@ describe API::ProjectClusters do end it 'responds with 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'includes pagination headers' do @@ -71,7 +71,7 @@ describe API::ProjectClusters do it 'responds with 403' do 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 @@ -142,7 +142,7 @@ describe API::ProjectClusters do let(:cluster_id) { 123 } it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -175,7 +175,7 @@ describe API::ProjectClusters do it 'responds with 403' do 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 @@ -186,7 +186,7 @@ describe API::ProjectClusters do context 'with valid params' do it 'responds with 201' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'creates a new Cluster::Cluster' do @@ -236,7 +236,7 @@ describe API::ProjectClusters do let(:namespace) { 'invalid_namespace' } it 'responds with 400' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'does not create a new Clusters::Cluster' do @@ -258,7 +258,7 @@ describe API::ProjectClusters do end 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')) end @@ -270,7 +270,7 @@ describe API::ProjectClusters do end 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') end @@ -307,7 +307,7 @@ describe API::ProjectClusters do it 'responds with 403' do 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 @@ -322,7 +322,7 @@ describe API::ProjectClusters do context 'with valid params' do it 'responds with 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'updates cluster attributes' do @@ -336,7 +336,7 @@ describe API::ProjectClusters do let(:namespace) { 'invalid_namespace' } it 'responds with 400' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'does not update cluster attributes' do @@ -354,7 +354,7 @@ describe API::ProjectClusters do let(:management_project_id) { create(:project).id } it 'responds with 400' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns validation errors' do @@ -372,7 +372,7 @@ describe API::ProjectClusters do end it 'responds with 400' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns validation error' do @@ -384,7 +384,7 @@ describe API::ProjectClusters do let(:namespace) { 'new-namespace' } it 'responds with 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -413,7 +413,7 @@ describe API::ProjectClusters do end it 'responds with 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'updates platform kubernetes attributes' do @@ -430,7 +430,7 @@ describe API::ProjectClusters do let(:cluster) { create(:cluster, :project, :provided_by_user) } 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 @@ -448,7 +448,7 @@ describe API::ProjectClusters do it 'responds with 403' do 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 @@ -458,7 +458,7 @@ describe API::ProjectClusters do end it 'responds with 204' do - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end it 'deletes the cluster' do @@ -469,7 +469,7 @@ describe API::ProjectClusters do let(:cluster) { create(:cluster, :project, :provided_by_user) } 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 diff --git a/spec/requests/api/project_container_repositories_spec.rb b/spec/requests/api/project_container_repositories_spec.rb index 98b3416a2bc..1854d4db920 100644 --- a/spec/requests/api/project_container_repositories_spec.rb +++ b/spec/requests/api/project_container_repositories_spec.rb @@ -163,7 +163,7 @@ describe API::ProjectContainerRepositories do stub_exclusive_lease_taken(lease_key, timeout: 1.hour) 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.') end diff --git a/spec/requests/api/project_events_spec.rb b/spec/requests/api/project_events_spec.rb index d466dca9884..3fa3d4fa899 100644 --- a/spec/requests/api/project_events_spec.rb +++ b/spec/requests/api/project_events_spec.rb @@ -14,7 +14,7 @@ describe API::ProjectEvents do it 'returns 404 for private project' do 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 it 'returns 200 status for a public project' do @@ -22,7 +22,7 @@ describe API::ProjectEvents do 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 @@ -36,14 +36,14 @@ describe API::ProjectEvents do it 'returns only accessible events' do 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) end it 'returns all events when the user has access' do 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) end end @@ -92,7 +92,7 @@ describe API::ProjectEvents do it 'returns 404' do 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 @@ -100,7 +100,7 @@ describe API::ProjectEvents 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) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -109,7 +109,7 @@ describe API::ProjectEvents do it 'returns 404 if project does not exist' do get api("/projects/1234/events", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'when the requesting token does not have "api" scope' do @@ -118,7 +118,7 @@ describe API::ProjectEvents do it 'returns a "403" response' do 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 @@ -142,7 +142,7 @@ describe API::ProjectEvents do get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request } 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(json_response.size).to eq(2) expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id]) diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb index 98214a8c471..d5c822385da 100644 --- a/spec/requests/api/project_export_spec.rb +++ b/spec/requests/api/project_export_spec.rb @@ -55,7 +55,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'prevents requesting project export' do 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.') end end @@ -77,7 +77,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'is none' do 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(json_response['export_status']).to eq('none') end @@ -85,7 +85,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'is started' do 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(json_response['export_status']).to eq('started') end @@ -93,7 +93,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'is after_export' do 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(json_response['export_status']).to eq('after_export_action') end @@ -101,7 +101,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'is finished' do 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(json_response['export_status']).to eq('finished') end @@ -185,7 +185,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'downloads' do get api(download_path_finished, user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -194,7 +194,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do it 'downloads' do 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 @@ -324,7 +324,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do 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 @@ -334,7 +334,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do post api(path, user) - expect(response).to have_gitlab_http_status(202) + expect(response).to have_gitlab_http_status(:accepted) end end end @@ -403,7 +403,7 @@ describe API::ProjectExport, :clean_gitlab_redis_cache do expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute) 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 diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index b466bcb1a12..540b30e2969 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -25,7 +25,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns project hooks" do 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(response).to include_pagination_headers expect(json_response.count).to eq(1) @@ -49,7 +49,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "does not access project hooks" do 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 @@ -59,7 +59,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a project hook" do 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['issues_events']).to eq(hook.issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) @@ -77,14 +77,14 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 404 error if hook id is not available" do 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 context "unauthorized user" do it "does not access an existing hook" do 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 @@ -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' } 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['issues_events']).to eq(true) expect(json_response['confidential_issues_events']).to eq(true) @@ -120,7 +120,7 @@ describe API::ProjectHooks, 'ProjectHooks' do post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token } 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).not_to include("token") @@ -132,17 +132,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 400 error if url not given" do 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 it "returns a 422 error if url not valid" do 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 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/' } - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -151,7 +151,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put api("/projects/#{project.id}/hooks/#{hook.id}", user), 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['issues_events']).to eq(hook.issues_events) expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events) @@ -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 } - 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).not_to include("token") @@ -181,17 +181,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns 404 error if hook id not found" do 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 it "returns 400 error if url is not given" do 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 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' } - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -200,19 +200,19 @@ describe API::ProjectHooks, 'ProjectHooks' do expect do 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 it "returns a 404 error when deleting non existent hook" do 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 it "returns a 404 error if hook id not given" do 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 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 other_project.add_maintainer(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 end diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 1cba98d6dee..f4aa8b2e19b 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -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 } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'schedules an import using the namespace path' 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 } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end context 'when a name is explicitly set' 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 } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'schedules an import using the namespace path and a different name' 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 } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'sets name correctly' do @@ -93,7 +93,7 @@ describe API::ProjectImport do 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 it 'does not schedule an import for a namespace that does not exist' 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) } - 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') end @@ -116,7 +116,7 @@ describe API::ProjectImport do 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') end @@ -125,7 +125,7 @@ describe API::ProjectImport do 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') end @@ -186,7 +186,7 @@ describe API::ProjectImport do 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') end @@ -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 } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end end end @@ -209,7 +209,7 @@ describe API::ProjectImport 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 } - 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.') end end @@ -276,7 +276,7 @@ describe API::ProjectImport do 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') end @@ -287,7 +287,7 @@ describe API::ProjectImport do 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', 'import_error' => 'error') end diff --git a/spec/requests/api/project_milestones_spec.rb b/spec/requests/api/project_milestones_spec.rb index df6d83c1e65..a40878fc807 100644 --- a/spec/requests/api/project_milestones_spec.rb +++ b/spec/requests/api/project_milestones_spec.rb @@ -27,19 +27,19 @@ describe API::ProjectMilestones do it 'returns 404 response when the project does not exists' do 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 it 'returns 404 response when the milestone does not exists' do 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 it "returns 404 from guest user deleting a milestone" do 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 @@ -67,7 +67,7 @@ describe API::ProjectMilestones do it 'returns 403' do 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 @@ -79,14 +79,14 @@ describe API::ProjectMilestones do it 'returns 200' do 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) end it 'returns 200 for closed milestone' do 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) end end @@ -99,13 +99,13 @@ describe API::ProjectMilestones do it 'returns 404 response when the project does not exist' do 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 it 'returns 404 response when the milestone does not exist' do 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 @@ -117,7 +117,7 @@ describe API::ProjectMilestones do it 'returns 403' do 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 diff --git a/spec/requests/api/project_snapshots_spec.rb b/spec/requests/api/project_snapshots_spec.rb index cdd44f71649..a54f317782b 100644 --- a/spec/requests/api/project_snapshots_spec.rb +++ b/spec/requests/api/project_snapshots_spec.rb @@ -34,26 +34,26 @@ describe API::ProjectSnapshots do it 'returns authentication error as project owner' do 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 it 'returns authentication error as unauthenticated user' do get api("/projects/#{project.id}/snapshot", nil) - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it 'requests project repository raw archive as administrator' do 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) end it 'requests wiki repository raw archive as administrator' do 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) end end diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 2c6a13efc12..7efc426c81d 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -14,7 +14,7 @@ describe API::ProjectSnippets do it 'exposes known attributes' do 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['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -24,13 +24,13 @@ describe API::ProjectSnippets do other_project = create(:project) 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 it "returns unauthorized for non-admin users" do 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 @@ -45,7 +45,7 @@ describe API::ProjectSnippets do 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(json_response).to be_an Array expect(json_response.size).to eq(3) @@ -58,7 +58,7 @@ describe API::ProjectSnippets do 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(json_response).to be_an Array expect(json_response.size).to eq(0) @@ -72,7 +72,7 @@ describe API::ProjectSnippets do it 'returns snippet json' do 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['description']).to eq(snippet.description) @@ -82,7 +82,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do 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') end end @@ -110,7 +110,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do 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']) expect(snippet.content).to eq(params[:code]) expect(snippet.description).to eq(params[:description]) @@ -123,7 +123,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do 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']) expect(snippet.content).to eq(params[:code]) expect(snippet.description).to eq(params[:description]) @@ -137,7 +137,7 @@ describe API::ProjectSnippets do 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']) expect(snippet.content).to eq(params[:content]) expect(snippet.description).to eq(params[:description]) @@ -151,7 +151,7 @@ describe API::ProjectSnippets do 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') end @@ -160,7 +160,7 @@ describe API::ProjectSnippets do 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 it 'returns 400 for empty code field' do @@ -168,7 +168,7 @@ describe API::ProjectSnippets do 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 context 'when the snippet is spam' do @@ -196,7 +196,7 @@ describe API::ProjectSnippets do expect { create_snippet(project, visibility: 'public') } .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" }) end @@ -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' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -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 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -240,21 +240,21 @@ describe API::ProjectSnippets 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' } - 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') end it 'returns 404 for invalid snippet id' do 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') end it 'returns 400 for missing parameters' do 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 it 'returns 400 for empty code field' do @@ -262,7 +262,7 @@ describe API::ProjectSnippets do 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 context 'when the snippet is spam' do @@ -306,7 +306,7 @@ describe API::ProjectSnippets do expect { update_snippet(title: 'Foo', visibility: 'public') } .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" }) end @@ -324,13 +324,13 @@ describe API::ProjectSnippets do it 'deletes snippet' do 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 it 'returns 404 for invalid snippet id' do 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') end @@ -345,7 +345,7 @@ describe API::ProjectSnippets do it 'returns raw text' do 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.body).to eq(snippet.content) end @@ -353,7 +353,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do 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') end end diff --git a/spec/requests/api/project_statistics_spec.rb b/spec/requests/api/project_statistics_spec.rb index 184d0a72c37..5d0b506cc92 100644 --- a/spec/requests/api/project_statistics_spec.rb +++ b/spec/requests/api/project_statistics_spec.rb @@ -21,7 +21,7 @@ describe API::ProjectStatistics do it 'returns the fetch statistics of the last 30 days' do 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'] expect(fetches['total']).to eq(40) expect(fetches['days'].length).to eq(5) @@ -34,7 +34,7 @@ describe API::ProjectStatistics do 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'] expect(fetches['total']).to eq(40) expect(fetches['days'].length).to eq(5) @@ -47,7 +47,7 @@ describe API::ProjectStatistics do 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') end @@ -56,7 +56,7 @@ describe API::ProjectStatistics do 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 diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb index 2bf864afe87..50b950fb5c1 100644 --- a/spec/requests/api/project_templates_spec.rb +++ b/spec/requests/api/project_templates_spec.rb @@ -15,7 +15,7 @@ describe API::ProjectTemplates do it 'returns dockerfiles' do 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 match_response_schema('public_api/v4/template_list') expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' } @@ -24,7 +24,7 @@ describe API::ProjectTemplates do it 'returns gitignores' do 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 match_response_schema('public_api/v4/template_list') expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' } @@ -33,7 +33,7 @@ describe API::ProjectTemplates do it 'returns gitlab_ci_ymls' do 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 match_response_schema('public_api/v4/template_list') expect(json_response).to satisfy_one { |template| template['key'] == 'Android' } @@ -42,7 +42,7 @@ describe API::ProjectTemplates do it 'returns licenses' do 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 match_response_schema('public_api/v4/template_list') expect(json_response).to satisfy_one { |template| template['key'] == 'mit' } @@ -51,19 +51,19 @@ describe API::ProjectTemplates do it 'returns 400 for an unknown template type' do 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 it 'denies access to an anonymous user on a private project' do 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 it 'permits access to a developer on a private project' do 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') end end @@ -72,7 +72,7 @@ describe API::ProjectTemplates do it 'returns key and name for the listed licenses' do 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') end end @@ -81,7 +81,7 @@ describe API::ProjectTemplates do it 'returns a specific dockerfile' do 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(json_response['name']).to eq('Binary') end @@ -89,7 +89,7 @@ describe API::ProjectTemplates do it 'returns a specific gitignore' do 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(json_response['name']).to eq('Actionscript') end @@ -97,7 +97,7 @@ describe API::ProjectTemplates do it 'returns C++ gitignore' do 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(json_response['name']).to eq('C++') end @@ -105,7 +105,7 @@ describe API::ProjectTemplates do it 'returns C++ gitignore for URL-encoded names' do 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(json_response['name']).to eq('C++') end @@ -113,7 +113,7 @@ describe API::ProjectTemplates do it 'returns a specific gitlab_ci_yml' do 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(json_response['name']).to eq('Android') end @@ -121,26 +121,26 @@ describe API::ProjectTemplates do it 'returns a specific license' do 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') end it 'returns 404 for an unknown specific template' do 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 it 'denies access to an anonymous user on a private project' do 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 it 'permits access to a developer on a private project' do 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') end @@ -148,7 +148,7 @@ describe API::ProjectTemplates do it 'rejects invalid filenames' do 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 @@ -165,7 +165,7 @@ describe API::ProjectTemplates do 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') content = json_response['content'] diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index c78a1d4ec62..38543e1efe5 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -110,7 +110,7 @@ describe API::Projects do it 'returns an array of projects' do get api('/projects', current_user), params: filter - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) @@ -210,7 +210,7 @@ describe API::Projects do get api('/projects', 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.map { |p| p['id'] }).not_to include(project.id) end @@ -242,7 +242,7 @@ describe API::Projects do it "does not include statistics by default" do get api('/projects', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') @@ -251,7 +251,7 @@ describe API::Projects do it "includes statistics if requested" do get api('/projects', user), params: { statistics: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).to include 'statistics' @@ -260,7 +260,7 @@ describe API::Projects do it "does not include license by default" do get api('/projects', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include('license', 'license_url') @@ -269,7 +269,7 @@ describe API::Projects do it "does not include license if requested" do get api('/projects', user), params: { license: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include('license', 'license_url') @@ -314,7 +314,7 @@ describe API::Projects do get api('/projects?simple=true', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first.keys).to match_array expected_keys @@ -327,7 +327,7 @@ describe API::Projects do it 'returns archived projects' do get api('/projects?archived=true', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: true).size) @@ -337,7 +337,7 @@ describe API::Projects do it 'returns non-archived projects' do get api('/projects?archived=false', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: false).size) @@ -347,7 +347,7 @@ describe API::Projects do it 'returns every project' do get api('/projects', user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id)) @@ -398,7 +398,7 @@ describe API::Projects do it 'filters based on private visibility param' do get api('/projects', user), params: { visibility: 'private' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id) @@ -409,7 +409,7 @@ describe API::Projects do get api('/projects', user), params: { visibility: 'internal' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project2.id) @@ -418,7 +418,7 @@ describe API::Projects do it 'filters based on public visibility param' do get api('/projects', user), params: { visibility: 'public' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id) @@ -431,7 +431,7 @@ describe API::Projects do it 'filters case-insensitively by programming language' do get api('/projects', user), params: { with_programming_language: 'javascript' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project3.id) @@ -442,7 +442,7 @@ describe API::Projects do it 'returns the correct order when sorted by id' do get api('/projects', user), params: { order_by: 'id', sort: 'desc' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['id']).to eq(project3.id) @@ -453,7 +453,7 @@ describe API::Projects do it 'returns an array of projects the user owns' do get api('/projects', user4), params: { owned: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project4.name) @@ -472,7 +472,7 @@ describe API::Projects do it 'returns the starred projects viewable by the user' do get api('/projects', user3), params: { starred: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) @@ -494,7 +494,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), params: { visibility: 'public', owned: true, starred: true, search: 'gitlab' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -513,7 +513,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), params: { visibility: 'public', membership: true, starred: true, search: 'gitlab' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) @@ -532,7 +532,7 @@ describe API::Projects do it 'returns an array of projects the user has at least developer access' do get api('/projects', user2), params: { min_access_level: 30 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project2.id, project3.id) @@ -587,7 +587,7 @@ describe API::Projects do it 'contains only the first project with per_page = 1' do get api('/projects', current_user), params: params - 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.map { |p| p['id'] }).to contain_exactly(public_project.id) end @@ -609,14 +609,14 @@ describe API::Projects do it 'returns an empty array when the page does not have any records' do get api('/projects', current_user), params: params.merge(id_after: Project.maximum(:id)) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq([]) end it 'responds with 501 if order_by is different from id' do get api('/projects', current_user), params: params.merge(order_by: :created_at) - expect(response).to have_gitlab_http_status(405) + expect(response).to have_gitlab_http_status(:method_not_allowed) end end @@ -634,7 +634,7 @@ describe API::Projects do it 'contains only the last project with per_page = 1' do get api('/projects', current_user), params: params - 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.map { |p| p['id'] }).to contain_exactly(project3.id) end @@ -672,14 +672,14 @@ describe API::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post api('/projects', user2), params: { name: 'foo' } } .to change {Project.count}.by(0) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end it 'creates new project without path but with name and returns 201' do expect { post api('/projects', user), params: { name: 'Foo Project' } } .to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.first @@ -690,7 +690,7 @@ describe API::Projects do it 'creates new project without name but with path and returns 201' do expect { post api('/projects', user), params: { path: 'foo_project' } } .to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.first @@ -701,7 +701,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api('/projects', user), params: { path: 'path-project-Foo', name: 'Foo Project' } } .to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.first @@ -712,12 +712,12 @@ describe API::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post api('/projects', user2), params: { name: 'foo' } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'does not create new project without name or path and returns 400' do expect { post api('/projects', user) }.not_to change { Project.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "assigns attributes to project" do @@ -739,7 +739,7 @@ describe API::Projects do post api('/projects', user), params: project - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project.each_pair do |k, v| next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled storage_version].include?(k) @@ -758,7 +758,7 @@ describe API::Projects do expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } } .to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.find(json_response['id']) expect(project).to be_saved @@ -769,7 +769,7 @@ describe API::Projects do expect { post api('/projects', user), params: { template_name: 'unknown', name: 'rails-test' } } .not_to change { Project.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']['template_name']).to eq(["'unknown' is unknown or invalid"]) end @@ -778,7 +778,7 @@ describe API::Projects do expect { post api('/projects', user), params: project_params } .not_to change { Project.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'sets a project as public' do @@ -931,7 +931,7 @@ describe API::Projects do post api('/projects', user), params: project - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'ignores import_url when it is nil' do @@ -939,7 +939,7 @@ describe API::Projects do post api('/projects', user), params: project - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end context 'when a visibility level is restricted' do @@ -952,7 +952,7 @@ describe API::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post api('/projects', user), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -972,14 +972,14 @@ describe API::Projects do it 'returns error when user not found' do get api('/users/0/projects/') - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 User Not Found') end it 'returns projects filtered by user id' do get api("/users/#{user4.id}/projects/", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) @@ -991,7 +991,7 @@ describe API::Projects do it 'only returns projects with id_after filter given' do get api("/users/#{user4.id}/projects?id_after=#{public_project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(another_public_project.id) @@ -1000,7 +1000,7 @@ describe API::Projects do it 'returns both projects without a id_after filter' do get api("/users/#{user4.id}/projects", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id) @@ -1013,7 +1013,7 @@ describe API::Projects do it 'only returns projects with id_before filter given' do get api("/users/#{user4.id}/projects?id_before=#{another_public_project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) @@ -1022,7 +1022,7 @@ describe API::Projects do it 'returns both projects without a id_before filter' do get api("/users/#{user4.id}/projects", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id, another_public_project.id) @@ -1035,7 +1035,7 @@ describe API::Projects do it 'only returns projects with id matching the range' do get api("/users/#{user4.id}/projects?id_after=#{more_projects.first.id}&id_before=#{more_projects.last.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(*more_projects[1..-2].map(&:id)) @@ -1045,7 +1045,7 @@ describe API::Projects do it 'returns projects filtered by username' do get api("/users/#{user4.username}/projects/", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) @@ -1059,7 +1059,7 @@ describe API::Projects do get api("/users/#{user4.id}/projects/", user2), params: { min_access_level: 30 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(private_project1.id) @@ -1071,7 +1071,7 @@ describe API::Projects do it 'filters case-insensitively by programming language' do get api('/projects', user), params: { with_programming_language: 'ruby' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id) @@ -1087,14 +1087,14 @@ describe API::Projects do it 'returns error when user not found' do get api('/users/9999/starred_projects/') - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response['message']).to eq('404 User Not Found') end it 'returns projects filtered by user' do get api("/users/#{user3.id}/starred_projects/", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, project2.id, project3.id) @@ -1104,7 +1104,7 @@ describe API::Projects do describe 'POST /projects/user/:id' do it 'creates new project without path but with name and return 201' do expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.find(json_response['id']) @@ -1115,7 +1115,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', name: 'Foo Project' } } .to change { Project.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project = Project.find(json_response['id']) @@ -1127,7 +1127,7 @@ describe API::Projects do expect { post api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to eq('name is missing') end @@ -1142,7 +1142,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), params: project - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) project.each_pair do |k, v| next if %i[has_external_issue_tracker path storage_version].include?(k) @@ -1156,7 +1156,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), params: project - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['visibility']).to eq('public') end @@ -1165,7 +1165,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), params: project - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['visibility']).to eq('internal') end @@ -1246,7 +1246,7 @@ describe API::Projects do it "uploads the file and returns its info" do post api("/projects/#{project.id}/uploads", user), params: { file: fixture_file_upload("spec/fixtures/dk.png", "image/png") } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -1260,7 +1260,7 @@ describe API::Projects do get api("/projects/#{private_project.id}") - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns public projects' do @@ -1268,7 +1268,7 @@ describe API::Projects do get api("/projects/#{public_project.id}") - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -1283,7 +1283,7 @@ describe API::Projects do get api("/projects/#{fork.id}") - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['forked_from_project']).to be_nil end end @@ -1295,7 +1295,7 @@ describe API::Projects do it 'hides protected attributes of private repositories if user is not a member' do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) protected_attributes.each do |attribute| expect(json_response.keys).not_to include(attribute) end @@ -1306,7 +1306,7 @@ describe API::Projects do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) protected_attributes.each do |attribute| expect(json_response.keys).to include(attribute) end @@ -1323,7 +1323,7 @@ describe API::Projects do get api("/projects/#{project.id}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -1374,7 +1374,7 @@ describe API::Projects do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -1448,20 +1448,20 @@ describe API::Projects do it 'returns a project by path name' do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get api('/projects/42', 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 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get api("/projects/#{project.id}", other_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'handles users with dots' do @@ -1469,14 +1469,14 @@ describe API::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -1492,14 +1492,14 @@ describe API::Projects do it "does not include license fields by default" do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).not_to include('license', 'license_url') end it 'includes license fields when requested' do get api("/projects/#{project.id}", user), params: { license: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['license']).to eq({ 'key' => project.repository.license.key, 'name' => project.repository.license.name, @@ -1512,14 +1512,14 @@ describe API::Projects do it "does not include statistics by default" do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).not_to include 'statistics' end it "includes statistics if requested" do get api("/projects/#{project.id}", user), params: { statistics: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to include 'statistics' end @@ -1529,7 +1529,7 @@ describe API::Projects do it "does not include statistics if user is not a member" do get api("/projects/#{project.id}", user), params: { statistics: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).not_to include 'statistics' end @@ -1538,7 +1538,7 @@ describe API::Projects do get api("/projects/#{project.id}", user), params: { statistics: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to include 'statistics' end @@ -1548,7 +1548,7 @@ describe API::Projects do get api("/projects/#{project.id}", user), params: { statistics: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to include 'statistics' end end @@ -1556,14 +1556,14 @@ describe API::Projects do it "includes import_error if user can admin project" do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to include("import_error") end it "does not include import_error if user cannot admin project" do get api("/projects/#{project.id}", user3) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).not_to include("import_error") end @@ -1572,7 +1572,7 @@ describe API::Projects do get api("/projects/#{project.id}", 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 Project Not Found') end @@ -1614,7 +1614,7 @@ describe API::Projects do get api("/projects/#{fork.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['forked_from_project']).to include('id' => project.id) end @@ -1625,7 +1625,7 @@ describe API::Projects do get api("/projects/#{fork.id}", fork_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['forked_from_project']).to be_nil end end @@ -1639,7 +1639,7 @@ describe API::Projects do it 'contains permission information' do get api("/projects", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MAINTAINER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -1651,7 +1651,7 @@ describe API::Projects do project.add_maintainer(user) get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MAINTAINER) expect(json_response['permissions']['group_access']).to be_nil @@ -1668,7 +1668,7 @@ describe API::Projects do it 'sets the owner and return 200' do get api("/projects/#{project2.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -1687,7 +1687,7 @@ describe API::Projects do it 'sets group access and return 200' do get api("/projects/#{project2.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -1701,7 +1701,7 @@ describe API::Projects do it 'sets the maximum group access and return 200' do get api("/projects/#{project2.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -1718,7 +1718,7 @@ describe API::Projects do it 'returns group web_url and avatar_url' do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) group_data = json_response['namespace'] expect(group_data['web_url']).to eq(group.web_url) @@ -1733,7 +1733,7 @@ describe API::Projects do it 'returns user web_url and avatar_url' do get api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) user_data = json_response['namespace'] expect(user_data['web_url']).to eq("http://localhost/#{user.username}") @@ -1758,7 +1758,7 @@ describe API::Projects do user = project.namespace.owner - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -1787,7 +1787,7 @@ describe API::Projects do it 'returns a 404 error if not found' do get api('/projects/42/users', 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 Project Not Found') end @@ -1796,7 +1796,7 @@ describe API::Projects do get api("/projects/#{project.id}/users", other_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'filters out users listed in skip_users' do @@ -1805,7 +1805,7 @@ describe API::Projects do get api("/projects/#{project.id}/users?skip_users=#{user.id}", user) - 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[0]['id']).to eq(other_user.id) end @@ -1826,7 +1826,7 @@ describe API::Projects do it 'denies project to be forked from an existing project' do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -1845,7 +1845,7 @@ describe API::Projects do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) project_fork_target.reload - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.fork_network_member).to be_present expect(project_fork_target).to be_forked @@ -1854,7 +1854,7 @@ describe API::Projects do it 'denies project to be forked from a private project' do post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -1864,13 +1864,13 @@ describe API::Projects do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'allows project to be forked from a private project' do post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", admin) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end it 'refreshes the forks count cachce' do @@ -1881,7 +1881,7 @@ describe API::Projects do it 'fails if forked_from project which does not exist' do post api("/projects/#{project_fork_target.id}/fork/0", admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'fails with 409 if already forked' do @@ -1892,7 +1892,7 @@ describe API::Projects do post api("/projects/#{project_fork_target.id}/fork/#{other_project_fork_source.id}", admin) project_fork_target.reload - expect(response).to have_gitlab_http_status(409) + expect(response).to have_gitlab_http_status(:conflict) expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target).to be_forked end @@ -1902,7 +1902,7 @@ describe API::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end context 'when users belong to project group' do @@ -1924,7 +1924,7 @@ describe API::Projects do it 'makes forked project unforked' do delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target).not_to be_forked @@ -1937,13 +1937,13 @@ describe API::Projects do it 'is forbidden to non-owner users' do delete api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_gitlab_http_status(304) + expect(response).to have_gitlab_http_status(:not_modified) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1973,7 +1973,7 @@ describe API::Projects do it 'returns the forks' do get api("/projects/#{project_fork_source.id}/forks", member) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response[0]['name']).to eq(private_fork.name) @@ -1984,7 +1984,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks", non_member) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.length).to eq(0) end @@ -1995,7 +1995,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks") - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.length).to eq(0) end @@ -2017,7 +2017,7 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at } end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -2025,18 +2025,18 @@ describe API::Projects do it "returns a 400 error when group id is not given" do post api("/projects/#{project.id}/share", user), params: { group_access: Gitlab::Access::DEVELOPER } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "returns a 400 error when access level is not given" do post api("/projects/#{project.id}/share", user), params: { group_id: group.id } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns a 404 error when user cannot read group' do @@ -2044,19 +2044,19 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), params: { group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns a 404 error when group does not exist' do post api("/projects/#{project.id}/share", user), params: { group_id: 1234, group_access: Gitlab::Access::DEVELOPER } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns a 400 error when wrong params passed" do post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: 1234 } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to eq 'group_access does not have a valid value' end @@ -2066,7 +2066,7 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER } - expect(response).to have_gitlab_http_status(409) + expect(response).to have_gitlab_http_status(:conflict) end end @@ -2081,7 +2081,7 @@ describe API::Projects do it 'returns 204 when deleting a group share' do delete api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(project.project_group_links).to be_empty end @@ -2093,19 +2093,19 @@ describe API::Projects do it 'returns a 400 when group id is not an integer' do delete api("/projects/#{project.id}/share/foo", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'returns a 404 error when group link does not exist' do delete api("/projects/#{project.id}/share/1234", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'returns a 404 error when project does not exist' do delete api("/projects/123/share/1234", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -2126,7 +2126,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['error']).to match('at least one parameter must be provided') end @@ -2136,7 +2136,7 @@ describe API::Projects do put api("/projects/#{project.id}"), params: project_param - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -2146,7 +2146,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2158,7 +2158,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2171,7 +2171,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2185,7 +2185,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -2194,7 +2194,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['request_access_enabled']).to eq(false) end @@ -2203,7 +2203,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2215,7 +2215,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2227,7 +2227,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['builds_access_level']).to eq('private') end @@ -2247,7 +2247,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['emails_disabled']).to eq(true) end @@ -2257,7 +2257,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['build_git_strategy']).to eq('clone') end @@ -2267,7 +2267,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'updates merge_method' do @@ -2275,7 +2275,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -2287,7 +2287,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it 'updates avatar' do @@ -2298,7 +2298,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ '-/system/project/avatar/'\ "#{project3.id}/banana_sample.gif") @@ -2309,7 +2309,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['auto_devops_deploy_strategy']).to eq('timed_incremental') end @@ -2319,7 +2319,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['auto_devops_enabled']).to eq(false) end @@ -2329,7 +2329,7 @@ describe API::Projects do it 'updates path' do project_param = { path: 'bar' } put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -2345,7 +2345,7 @@ describe API::Projects do description: 'new description' } put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -2354,20 +2354,20 @@ describe API::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not update visibility_level' do project_param = { visibility: 'public' } put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'updates container_expiration_policy' do @@ -2380,7 +2380,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user4), params: project_param - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['container_expiration_policy']['cadence']).to eq('1month') expect(json_response['container_expiration_policy']['keep_n']).to eq(1) @@ -2397,7 +2397,7 @@ describe API::Projects do description: 'new description', request_access_enabled: true } put api("/projects/#{project.id}", user3), params: project_param - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -2407,7 +2407,7 @@ describe API::Projects do it 'archives the project' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['archived']).to be_truthy end end @@ -2420,7 +2420,7 @@ describe API::Projects do it 'remains archived' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['archived']).to be_truthy end end @@ -2433,7 +2433,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/archive", user3) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -2443,7 +2443,7 @@ describe API::Projects do it 'remains unarchived' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['archived']).to be_falsey end end @@ -2456,7 +2456,7 @@ describe API::Projects do it 'unarchives the project' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['archived']).to be_falsey end end @@ -2469,7 +2469,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end end @@ -2479,7 +2479,7 @@ describe API::Projects do it 'stars the project' do expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['star_count']).to eq(1) end end @@ -2493,7 +2493,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_gitlab_http_status(304) + expect(response).to have_gitlab_http_status(:not_modified) end end end @@ -2508,7 +2508,7 @@ describe API::Projects do it 'unstars the project' do expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['star_count']).to eq(0) end end @@ -2517,7 +2517,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count } - expect(response).to have_gitlab_http_status(304) + expect(response).to have_gitlab_http_status(:not_modified) end end end @@ -2527,7 +2527,7 @@ describe API::Projects do it 'returns an array of starrers' do get api("/projects/#{public_project.id}/starrers", current_user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response[0]['starred_since']).to be_present @@ -2642,7 +2642,7 @@ describe API::Projects do it 'removes project' do delete api("/projects/#{project.id}", user) - expect(response).to have_gitlab_http_status(202) + expect(response).to have_gitlab_http_status(:accepted) expect(json_response['message']).to eql('202 Accepted') end @@ -2655,17 +2655,17 @@ describe API::Projects do user3 = create(:user) project.add_developer(user3) delete api("/projects/#{project.id}", user3) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end it 'does not remove a non existing project' do delete api('/projects/1328', user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not remove a project not attached to user' do delete api("/projects/#{project.id}", user2) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -2673,13 +2673,13 @@ describe API::Projects do it 'removes any existing project' do delete api("/projects/#{project.id}", admin) - expect(response).to have_gitlab_http_status(202) + expect(response).to have_gitlab_http_status(:accepted) expect(json_response['message']).to eql('202 Accepted') end it 'does not remove a non existing project' do delete api('/projects/1328', admin) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do @@ -2906,7 +2906,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) end context 'when housekeeping lease is taken' do @@ -2915,7 +2915,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_gitlab_http_status(409) + expect(response).to have_gitlab_http_status(:conflict) expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/) end end @@ -2929,7 +2929,7 @@ describe API::Projects do it 'returns forbidden error' do post api("/projects/#{project.id}/housekeeping", user3) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -2937,7 +2937,7 @@ describe API::Projects do it 'returns authentication error' do post api("/projects/#{project.id}/housekeeping") - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -2951,25 +2951,25 @@ describe API::Projects do put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'fails when transferring to a non owned namespace' do put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'fails when transferring to an unknown namespace' do put api("/projects/#{project.id}/transfer", user), params: { namespace: 'unknown' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'fails on missing namespace' do put api("/projects/#{project.id}/transfer", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -2984,7 +2984,7 @@ describe API::Projects do it 'fails transferring the project to the target namespace' do put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end diff --git a/spec/requests/api/protected_branches_spec.rb b/spec/requests/api/protected_branches_spec.rb index 8499a165d8b..9203e0ec819 100644 --- a/spec/requests/api/protected_branches_spec.rb +++ b/spec/requests/api/protected_branches_spec.rb @@ -19,7 +19,7 @@ describe API::ProtectedBranches do it 'returns the protected branches' do 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(json_response).to be_an Array @@ -66,7 +66,7 @@ describe API::ProtectedBranches do it 'returns the protected branch' do 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['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) @@ -118,7 +118,7 @@ describe API::ProtectedBranches do let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) } 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) end @@ -130,7 +130,7 @@ describe API::ProtectedBranches do it 'protects a single branch' do 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['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) @@ -139,7 +139,7 @@ describe API::ProtectedBranches do it 'protects a single branch and developers can push' do 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['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) @@ -148,7 +148,7 @@ describe API::ProtectedBranches do it 'protects a single branch and developers can merge' do 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['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) @@ -157,7 +157,7 @@ describe API::ProtectedBranches 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 } - 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['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) @@ -166,7 +166,7 @@ describe API::ProtectedBranches do it 'protects a single branch and no one can push' do 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['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) @@ -175,7 +175,7 @@ describe API::ProtectedBranches do it 'protects a single branch and no one can merge' do 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['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) @@ -184,7 +184,7 @@ describe API::ProtectedBranches 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 } - 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['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) @@ -193,7 +193,7 @@ describe API::ProtectedBranches do it 'returns a 409 error if the same branch is protected twice' do post post_endpoint, params: { name: protected_name } - expect(response).to have_gitlab_http_status(409) + expect(response).to have_gitlab_http_status(:conflict) end context 'when branch has a wildcard in its name' do @@ -217,7 +217,7 @@ describe API::ProtectedBranches do it "prevents deletion of the protected branch rule" do 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 @@ -230,7 +230,7 @@ describe API::ProtectedBranches do it "returns a 403 error if guest" do 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 @@ -245,7 +245,7 @@ describe API::ProtectedBranches do it "unprotects a single branch" do delete delete_endpoint - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end it_behaves_like '412 response' do @@ -255,7 +255,7 @@ describe API::ProtectedBranches do it "returns 404 if branch does not exist" do 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 context 'when a policy restricts rule deletion' do @@ -267,7 +267,7 @@ describe API::ProtectedBranches do it "prevents deletion of the protected branch rule" do delete delete_endpoint - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -277,7 +277,7 @@ describe API::ProtectedBranches do it "unprotects a wildcard branch" do delete delete_endpoint - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) end end end diff --git a/spec/requests/api/protected_tags_spec.rb b/spec/requests/api/protected_tags_spec.rb index 5a962cd5667..3bc8ecbee73 100644 --- a/spec/requests/api/protected_tags_spec.rb +++ b/spec/requests/api/protected_tags_spec.rb @@ -19,7 +19,7 @@ describe API::ProtectedTags do it 'returns the protected tags' do 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(json_response).to be_an Array @@ -55,7 +55,7 @@ describe API::ProtectedTags do it 'returns the protected tag' do 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['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER) end @@ -106,7 +106,7 @@ describe API::ProtectedTags do it 'protects a single tag with maintainers can create tags' do 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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) end @@ -115,7 +115,7 @@ describe API::ProtectedTags do post api("/projects/#{project.id}/protected_tags", user), 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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER) end @@ -124,7 +124,7 @@ describe API::ProtectedTags do post api("/projects/#{project.id}/protected_tags", user), 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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS) end @@ -132,7 +132,7 @@ describe API::ProtectedTags 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 } - 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') end @@ -140,7 +140,7 @@ describe API::ProtectedTags do post api("/projects/#{project.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) end @@ -150,7 +150,7 @@ describe API::ProtectedTags do it 'protects multiple tags with a wildcard in the name' do 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['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) end @@ -165,7 +165,7 @@ describe API::ProtectedTags do it 'returns a 403 error if guest' do 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 @@ -178,7 +178,7 @@ describe API::ProtectedTags do it 'unprotects a single tag' do 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 it_behaves_like '412 response' do @@ -188,7 +188,7 @@ describe API::ProtectedTags do it "returns 404 if tag does not exist" do 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 context 'when tag has a wildcard in its name' do @@ -197,7 +197,7 @@ describe API::ProtectedTags do it 'unprotects a wildcard tag' do 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 diff --git a/spec/rubocop/cop/migration/add_column_with_default_spec.rb b/spec/rubocop/cop/migration/add_column_with_default_spec.rb index f3518f2f058..a8cf965a3ef 100644 --- a/spec/rubocop/cop/migration/add_column_with_default_spec.rb +++ b/spec/rubocop/cop/migration/add_column_with_default_spec.rb @@ -16,7 +16,7 @@ describe RuboCop::Cop::Migration::AddColumnWithDefault do it 'does not register any offenses' do expect_no_offenses(<<~RUBY) 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 RUBY end @@ -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' } - it 'registers an offense when specifying allow_null: false' do - expect_offense(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: false) - ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} - end - RUBY - end + context 'for blacklisted table' do + it 'registers an offense when specifying allow_null: false' do + expect_offense(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: false) + ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} + end + RUBY + end - it 'registers no offense when specifying allow_null: true' do - expect_no_offenses(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true, allow_null: true) - end - RUBY - end + it 'registers no offense when specifying allow_null: true' do + expect_no_offenses(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true, allow_null: true) + end + RUBY + end - it 'registers an offense when allow_null is not specified' do - expect_offense(<<~RUBY) - def up - add_column_with_default(:ci_build_needs, :artifacts, :boolean, default: true) - ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} - end - RUBY + it 'registers an offense when allow_null is not specified' do + expect_offense(<<~RUBY) + def up + add_column_with_default(:merge_request_diff_files, :artifacts, :boolean, default: true) + ^^^^^^^^^^^^^^^^^^^^^^^ #{offense} + end + RUBY + end end - it 'registers no offense for application_settings (whitelisted table)' do - expect_no_offenses(<<~RUBY) - def up - add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false) - end - RUBY + context 'for tables not on the blacklist' do + it 'registers no offense for application_settings (not on blacklist)' do + expect_no_offenses(<<~RUBY) + def up + add_column_with_default(:application_settings, :another_column, :boolean, default: true, allow_null: false) + end + RUBY + end end end end |