Commit 6c15c18f authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 263f926c
...@@ -301,12 +301,6 @@ RSpec/AnyInstanceOf: ...@@ -301,12 +301,6 @@ RSpec/AnyInstanceOf:
Enabled: false Enabled: false
# Cops for upgrade to gitlab-styles 3.1.0 # Cops for upgrade to gitlab-styles 3.1.0
FactoryBot/FactoryClassName:
Enabled: false
FactoryBot/CreateList:
Enabled: false
Rails/SafeNavigationWithBlank: Rails/SafeNavigationWithBlank:
Enabled: false Enabled: false
......
...@@ -555,6 +555,16 @@ export const calculateRemainingMilliseconds = endDate => { ...@@ -555,6 +555,16 @@ export const calculateRemainingMilliseconds = endDate => {
export const getDateInPast = (date, daysInPast) => export const getDateInPast = (date, daysInPast) =>
new Date(newDate(date).setDate(date.getDate() - daysInPast)); new Date(newDate(date).setDate(date.getDate() - daysInPast));
/**
* Adds a given number of days to a given date and returns the new date.
*
* @param {Date} date the date that we will add days to
* @param {Number} daysInFuture number of days that are added to a given date
* @returns {Date} Date in future as Date object
*/
export const getDateInFuture = (date, daysInFuture) =>
new Date(newDate(date).setDate(date.getDate() + daysInFuture));
/* /*
* Appending T00:00:00 makes JS assume local time and prevents it from shifting the date * Appending T00:00:00 makes JS assume local time and prevents it from shifting the date
* to match the user's time zone. We want to display the date in server time for now, to * to match the user's time zone. We want to display the date in server time for now, to
......
...@@ -48,9 +48,6 @@ ...@@ -48,9 +48,6 @@
padding: 10px; padding: 10px;
border: 0; border: 0;
border-radius: 0; border-radius: 0;
font-family: $monospace-font;
font-size: $code-font-size;
line-height: $code-line-height;
margin: 0; margin: 0;
overflow: auto; overflow: auto;
overflow-y: hidden; overflow-y: hidden;
...@@ -58,6 +55,12 @@ ...@@ -58,6 +55,12 @@
word-wrap: normal; word-wrap: normal;
border-left: $border-style; border-left: $border-style;
} }
code {
font-family: $monospace-font;
font-size: $code-font-size;
line-height: $code-line-height;
}
} }
.line-numbers { .line-numbers {
......
...@@ -51,7 +51,7 @@ module Emails ...@@ -51,7 +51,7 @@ module Emails
add_project_headers add_project_headers
headers['X-GitLab-Author'] = @message.author_username headers['X-GitLab-Author'] = @message.author_username
mail(from: sender(@message.author_id, @message.send_from_committer_email?), mail(from: sender(@message.author_id, send_from_user_email: @message.send_from_committer_email?),
reply_to: @message.reply_to, reply_to: @message.reply_to,
subject: @message.subject) subject: @message.subject)
end end
......
...@@ -59,11 +59,11 @@ class Notify < BaseMailer ...@@ -59,11 +59,11 @@ class Notify < BaseMailer
# Return an email address that displays the name of the sender. # Return an email address that displays the name of the sender.
# Only the displayed name changes; the actual email address is always the same. # Only the displayed name changes; the actual email address is always the same.
def sender(sender_id, send_from_user_email = false) def sender(sender_id, send_from_user_email: false, sender_name: nil)
return unless sender = User.find(sender_id) return unless sender = User.find(sender_id)
address = default_sender_address address = default_sender_address
address.display_name = sender.name address.display_name = sender_name.presence || sender.name
if send_from_user_email && can_send_from_user_email?(sender) if send_from_user_email && can_send_from_user_email?(sender)
address.address = sender.email address.address = sender.email
......
...@@ -23,7 +23,7 @@ module Ci ...@@ -23,7 +23,7 @@ module Ci
container_scanning: 'gl-container-scanning-report.json', container_scanning: 'gl-container-scanning-report.json',
dast: 'gl-dast-report.json', dast: 'gl-dast-report.json',
license_management: 'gl-license-management-report.json', license_management: 'gl-license-management-report.json',
license_scanning: 'gl-license-management-report.json', license_scanning: 'gl-license-scanning-report.json',
performance: 'performance.json', performance: 'performance.json',
metrics: 'metrics.txt' metrics: 'metrics.txt'
}.freeze }.freeze
......
...@@ -18,6 +18,7 @@ module Issuable ...@@ -18,6 +18,7 @@ module Issuable
new_entity.update(update_attributes) new_entity.update(update_attributes)
copy_resource_label_events copy_resource_label_events
copy_resource_weight_events
end end
private private
...@@ -60,6 +61,20 @@ module Issuable ...@@ -60,6 +61,20 @@ module Issuable
end end
end end
def copy_resource_weight_events
return unless original_entity.respond_to?(:resource_weight_events)
original_entity.resource_weight_events.find_in_batches do |batch|
events = batch.map do |event|
event.attributes
.except('id', 'reference', 'reference_html')
.merge('issue_id' => new_entity.id)
end
Gitlab::Database.bulk_insert(ResourceWeightEvent.table_name, events)
end
end
def entity_key def entity_key
new_entity.class.name.parameterize('_').foreign_key new_entity.class.name.parameterize('_').foreign_key
end end
......
---
title: Add build metadata to package API
merge_request: 20682
author:
type: added
---
title: Add getDateInFuture util method
merge_request: 22671
author:
type: added
---
title: Align embedded snippet mono space font with GitLab mono space font.
merge_request: !20865
author:
type: changed
...@@ -79,7 +79,10 @@ Example response: ...@@ -79,7 +79,10 @@ Example response:
"web_path": "/namespace1/project1/-/packages/1", "web_path": "/namespace1/project1/-/packages/1",
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z" "created_at": "2019-11-27T03:37:38.711Z",
"build_info": {
"pipeline_id": 123
}
}, },
{ {
"id": 2, "id": 2,
...@@ -90,7 +93,10 @@ Example response: ...@@ -90,7 +93,10 @@ Example response:
"web_path": "/namespace1/project1/-/packages/1", "web_path": "/namespace1/project1/-/packages/1",
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z" "created_at": "2019-11-27T03:37:38.711Z",
"build_info": {
"pipeline_id": 123
}
} }
] ]
``` ```
...@@ -133,7 +139,10 @@ Example response: ...@@ -133,7 +139,10 @@ Example response:
"web_path": "/namespace1/project1/-/packages/1", "web_path": "/namespace1/project1/-/packages/1",
"delete_api_path": "/namespace1/project1/-/packages/1" "delete_api_path": "/namespace1/project1/-/packages/1"
}, },
"created_at": "2019-11-27T03:37:38.711Z" "created_at": "2019-11-27T03:37:38.711Z",
"build_info": {
"pipeline_id": 123
}
} }
``` ```
......
...@@ -62,10 +62,18 @@ module Gitlab ...@@ -62,10 +62,18 @@ module Gitlab
end end
def error_detected! def error_detected!
set_error!(true)
end
def clear_errors!
set_error!(false)
end
def set_error!(status)
clear_memoization(:prometheus_metrics_enabled) clear_memoization(:prometheus_metrics_enabled)
PROVIDER_MUTEX.synchronize do PROVIDER_MUTEX.synchronize do
@error = true @error = status
end end
end end
......
...@@ -19,11 +19,10 @@ module QA ...@@ -19,11 +19,10 @@ module QA
members.add_member(@user.username) members.add_member(@user.username)
end end
issue = Resource::Issue.fabricate_via_api! do |issue| Resource::Issue.fabricate_via_api! do |issue|
issue.title = 'issue to test mention' issue.title = 'issue to test mention'
issue.project = project issue.project = project
end end.visit!
issue.visit!
end end
it 'user mentions another user in an issue' do it 'user mentions another user in an issue' do
......
...@@ -112,9 +112,7 @@ describe AutocompleteController do ...@@ -112,9 +112,7 @@ describe AutocompleteController do
context 'limited users per page' do context 'limited users per page' do
before do before do
25.times do create_list(:user, 25)
create(:user)
end
sign_in(user) sign_in(user)
get(:users) get(:users)
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cycle_analytics_project_stage, class: Analytics::CycleAnalytics::ProjectStage do factory :cycle_analytics_project_stage, class: 'Analytics::CycleAnalytics::ProjectStage' do
project project
sequence(:name) { |n| "Stage ##{n}" } sequence(:name) { |n| "Stage ##{n}" }
hidden { false } hidden { false }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :aws_role, class: Aws::Role do factory :aws_role, class: 'Aws::Role' do
user user
role_arn { 'arn:aws:iam::123456789012:role/role-name' } role_arn { 'arn:aws:iam::123456789012:role/role-name' }
......
...@@ -6,11 +6,11 @@ FactoryBot.define do ...@@ -6,11 +6,11 @@ FactoryBot.define do
image_url { generate(:url) } image_url { generate(:url) }
end end
factory :project_badge, traits: [:base_badge], class: ProjectBadge do factory :project_badge, traits: [:base_badge], class: 'ProjectBadge' do
project project
end end
factory :group_badge, aliases: [:badge], traits: [:base_badge], class: GroupBadge do factory :group_badge, aliases: [:badge], traits: [:base_badge], class: 'GroupBadge' do
group group
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :chat_name, class: ChatName do factory :chat_name, class: 'ChatName' do
user factory: :user user factory: :user
service factory: :service service factory: :service
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :chat_team, class: ChatTeam do factory :chat_team, class: 'ChatTeam' do
sequence(:team_id) { |n| "abcdefghijklm#{n}" } sequence(:team_id) { |n| "abcdefghijklm#{n}" }
namespace factory: :group namespace factory: :group
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_bridge, class: Ci::Bridge do factory :ci_bridge, class: 'Ci::Bridge' do
name { 'bridge' } name { 'bridge' }
stage { 'test' } stage { 'test' }
stage_idx { 0 } stage_idx { 0 }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_build_need, class: Ci::BuildNeed do factory :ci_build_need, class: 'Ci::BuildNeed' do
build factory: :ci_build build factory: :ci_build
sequence(:name) { |n| "build_#{n}" } sequence(:name) { |n| "build_#{n}" }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_build_trace_chunk, class: Ci::BuildTraceChunk do factory :ci_build_trace_chunk, class: 'Ci::BuildTraceChunk' do
build factory: :ci_build build factory: :ci_build
chunk_index { 0 } chunk_index { 0 }
data_store { :redis } data_store { :redis }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_build_trace_section_name, class: Ci::BuildTraceSectionName do factory :ci_build_trace_section_name, class: 'Ci::BuildTraceSectionName' do
sequence(:name) { |n| "section_#{n}" } sequence(:name) { |n| "section_#{n}" }
project factory: :project project factory: :project
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryBot.define do FactoryBot.define do
factory :ci_build, class: Ci::Build do factory :ci_build, class: 'Ci::Build' do
name { 'test' } name { 'test' }
stage { 'test' } stage { 'test' }
stage_idx { 0 } stage_idx { 0 }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_group_variable, class: Ci::GroupVariable do factory :ci_group_variable, class: 'Ci::GroupVariable' do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value { 'VARIABLE_VALUE' } value { 'VARIABLE_VALUE' }
masked { false } masked { false }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
include ActionDispatch::TestProcess include ActionDispatch::TestProcess
FactoryBot.define do FactoryBot.define do
factory :ci_job_artifact, class: Ci::JobArtifact do factory :ci_job_artifact, class: 'Ci::JobArtifact' do
job factory: :ci_build job factory: :ci_build
file_type { :archive } file_type { :archive }
file_format { :zip } file_format { :zip }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_job_variable, class: Ci::JobVariable do factory :ci_job_variable, class: 'Ci::JobVariable' do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value { 'VARIABLE_VALUE' } value { 'VARIABLE_VALUE' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do factory :ci_pipeline_schedule, class: 'Ci::PipelineSchedule' do
cron { '0 1 * * *' } cron { '0 1 * * *' }
cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE } cron_timezone { Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE }
ref { 'master' } ref { 'master' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do factory :ci_pipeline_schedule_variable, class: 'Ci::PipelineScheduleVariable' do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value { 'VARIABLE_VALUE' } value { 'VARIABLE_VALUE' }
variable_type { 'env_var' } variable_type { 'env_var' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_pipeline_variable, class: Ci::PipelineVariable do factory :ci_pipeline_variable, class: 'Ci::PipelineVariable' do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value { 'VARIABLE_VALUE' } value { 'VARIABLE_VALUE' }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
FactoryBot.define do FactoryBot.define do
# TODO: we can remove this factory in favour of :ci_pipeline # TODO: we can remove this factory in favour of :ci_pipeline
factory :ci_empty_pipeline, class: Ci::Pipeline do factory :ci_empty_pipeline, class: 'Ci::Pipeline' do
source { :push } source { :push }
ref { 'master' } ref { 'master' }
sha { '97de212e80737a608d939f648d959671fb0a0142' } sha { '97de212e80737a608d939f648d959671fb0a0142' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_resource, class: Ci::Resource do factory :ci_resource, class: 'Ci::Resource' do
resource_group factory: :ci_resource_group resource_group factory: :ci_resource_group
trait(:retained) do trait(:retained) do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_resource_group, class: Ci::ResourceGroup do factory :ci_resource_group, class: 'Ci::ResourceGroup' do
project project
sequence(:key) { |n| "IOS_#{n}" } sequence(:key) { |n| "IOS_#{n}" }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_runner_project, class: Ci::RunnerProject do factory :ci_runner_project, class: 'Ci::RunnerProject' do
runner factory: [:ci_runner, :project] runner factory: [:ci_runner, :project]
project project
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_runner, class: Ci::Runner do factory :ci_runner, class: 'Ci::Runner' do
sequence(:description) { |n| "My runner#{n}" } sequence(:description) { |n| "My runner#{n}" }
platform { "darwin" } platform { "darwin" }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_sources_pipeline, class: Ci::Sources::Pipeline do factory :ci_sources_pipeline, class: 'Ci::Sources::Pipeline' do
after(:build) do |source| after(:build) do |source|
source.project ||= source.pipeline.project source.project ||= source.pipeline.project
source.source_pipeline ||= source.source_job.pipeline source.source_pipeline ||= source.source_job.pipeline
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_stage, class: Ci::LegacyStage do factory :ci_stage, class: 'Ci::LegacyStage' do
skip_create skip_create
transient do transient do
...@@ -18,7 +18,7 @@ FactoryBot.define do ...@@ -18,7 +18,7 @@ FactoryBot.define do
end end
end end
factory :ci_stage_entity, class: Ci::Stage do factory :ci_stage_entity, class: 'Ci::Stage' do
project factory: :project project factory: :project
pipeline factory: :ci_empty_pipeline pipeline factory: :ci_empty_pipeline
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_trigger_request, class: Ci::TriggerRequest do factory :ci_trigger_request, class: 'Ci::TriggerRequest' do
trigger factory: :ci_trigger trigger factory: :ci_trigger
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger_without_token, class: 'Ci::Trigger' do
owner owner
factory :ci_trigger do factory :ci_trigger do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :ci_variable, class: Ci::Variable do factory :ci_variable, class: 'Ci::Variable' do
sequence(:key) { |n| "VARIABLE_#{n}" } sequence(:key) { |n| "VARIABLE_#{n}" }
value { 'VARIABLE_VALUE' } value { 'VARIABLE_VALUE' }
masked { false } masked { false }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :clusters_applications_helm, class: Clusters::Applications::Helm do factory :clusters_applications_helm, class: 'Clusters::Applications::Helm' do
cluster factory: %i(cluster provided_by_gcp) cluster factory: %i(cluster provided_by_gcp)
before(:create) do before(:create) do
...@@ -70,40 +70,40 @@ FactoryBot.define do ...@@ -70,40 +70,40 @@ FactoryBot.define do
updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago } updated_at { ClusterWaitForAppInstallationWorker::TIMEOUT.ago }
end end
factory :clusters_applications_ingress, class: Clusters::Applications::Ingress do factory :clusters_applications_ingress, class: 'Clusters::Applications::Ingress' do
modsecurity_enabled { false } modsecurity_enabled { false }
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_cert_manager, class: Clusters::Applications::CertManager do factory :clusters_applications_cert_manager, class: 'Clusters::Applications::CertManager' do
email { 'admin@example.com' } email { 'admin@example.com' }
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_elastic_stack, class: Clusters::Applications::ElasticStack do factory :clusters_applications_elastic_stack, class: 'Clusters::Applications::ElasticStack' do
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_crossplane, class: Clusters::Applications::Crossplane do factory :clusters_applications_crossplane, class: 'Clusters::Applications::Crossplane' do
stack { 'gcp' } stack { 'gcp' }
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_prometheus, class: Clusters::Applications::Prometheus do factory :clusters_applications_prometheus, class: 'Clusters::Applications::Prometheus' do
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_runner, class: Clusters::Applications::Runner do factory :clusters_applications_runner, class: 'Clusters::Applications::Runner' do
runner factory: %i(ci_runner) runner factory: %i(ci_runner)
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_knative, class: Clusters::Applications::Knative do factory :clusters_applications_knative, class: 'Clusters::Applications::Knative' do
hostname { 'example.com' } hostname { 'example.com' }
cluster factory: %i(cluster with_installed_helm provided_by_gcp) cluster factory: %i(cluster with_installed_helm provided_by_gcp)
end end
factory :clusters_applications_jupyter, class: Clusters::Applications::Jupyter do factory :clusters_applications_jupyter, class: 'Clusters::Applications::Jupyter' do
oauth_application factory: :oauth_application oauth_application factory: :oauth_application
cluster factory: %i(cluster with_installed_helm provided_by_gcp project) cluster factory: %i(cluster with_installed_helm provided_by_gcp project)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster, class: Clusters::Cluster do factory :cluster, class: 'Clusters::Cluster' do
user user
name { 'test-cluster' } name { 'test-cluster' }
cluster_type { :project_type } cluster_type { :project_type }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster_kubernetes_namespace, class: Clusters::KubernetesNamespace do factory :cluster_kubernetes_namespace, class: 'Clusters::KubernetesNamespace' do
association :cluster, :project, :provided_by_gcp association :cluster, :project, :provided_by_gcp
after(:build) do |kubernetes_namespace| after(:build) do |kubernetes_namespace|
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do factory :cluster_platform_kubernetes, class: 'Clusters::Platforms::Kubernetes' do
association :cluster, platform_type: :kubernetes, provider_type: :user association :cluster, platform_type: :kubernetes, provider_type: :user
namespace { nil } namespace { nil }
api_url { 'https://kubernetes.example.com' } api_url { 'https://kubernetes.example.com' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster_project, class: Clusters::Project do factory :cluster_project, class: 'Clusters::Project' do
cluster cluster
project project
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster_provider_aws, class: Clusters::Providers::Aws do factory :cluster_provider_aws, class: 'Clusters::Providers::Aws' do
association :cluster, platform_type: :kubernetes, provider_type: :aws association :cluster, platform_type: :kubernetes, provider_type: :aws
role_arn { 'arn:aws:iam::123456789012:role/role-name' } role_arn { 'arn:aws:iam::123456789012:role/role-name' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do factory :cluster_provider_gcp, class: 'Clusters::Providers::Gcp' do
association :cluster, platform_type: :kubernetes, provider_type: :gcp association :cluster, platform_type: :kubernetes, provider_type: :gcp
gcp_project_id { 'test-gcp-project' } gcp_project_id { 'test-gcp-project' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :commit_status, class: CommitStatus do factory :commit_status, class: 'CommitStatus' do
name { 'default' } name { 'default' }
stage { 'test' } stage { 'test' }
stage_idx { 0 } stage_idx { 0 }
...@@ -59,7 +59,7 @@ FactoryBot.define do ...@@ -59,7 +59,7 @@ FactoryBot.define do
build.project = build.pipeline.project build.project = build.pipeline.project
end end
factory :generic_commit_status, class: GenericCommitStatus do factory :generic_commit_status, class: 'GenericCommitStatus' do
name { 'generic' } name { 'generic' }
description { 'external commit status' } description { 'external commit status' }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :deployment, class: Deployment do factory :deployment, class: 'Deployment' do
sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' } sha { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
ref { 'master' } ref { 'master' }
tag { false } tag { false }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :dev_ops_score_metric, class: DevOpsScore::Metric do factory :dev_ops_score_metric, class: 'DevOpsScore::Metric' do
leader_issues { 9.256 } leader_issues { 9.256 }
instance_issues { 1.234 } instance_issues { 1.234 }
percentage_issues { 13.331 } percentage_issues { 13.331 }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :environment, class: Environment do factory :environment, class: 'Environment' do
sequence(:name) { |n| "environment#{n}" } sequence(:name) { |n| "environment#{n}" }
association :project, :repository association :project, :repository
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :detailed_error_tracking_error, class: Gitlab::ErrorTracking::DetailedError do factory :detailed_error_tracking_error, class: 'Gitlab::ErrorTracking::DetailedError' do
id { '1' } id { '1' }
title { 'title' } title { 'title' }
type { 'error' } type { 'error' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :error_tracking_error, class: Gitlab::ErrorTracking::Error do factory :error_tracking_error, class: 'Gitlab::ErrorTracking::Error' do
id { 'id' } id { 'id' }
title { 'title' } title { 'title' }
type { 'error' } type { 'error' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :error_tracking_error_event, class: Gitlab::ErrorTracking::ErrorEvent do factory :error_tracking_error_event, class: 'Gitlab::ErrorTracking::ErrorEvent' do
issue_id { 'id' } issue_id { 'id' }
date_received { Time.now.iso8601 } date_received { Time.now.iso8601 }
stack_trace_entries do stack_trace_entries do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :error_tracking_project, class: Gitlab::ErrorTracking::Project do factory :error_tracking_project, class: 'Gitlab::ErrorTracking::Project' do
id { '1' } id { '1' }
name { 'Sentry Example' } name { 'Sentry Example' }
slug { 'sentry-example' } slug { 'sentry-example' }
......
...@@ -24,7 +24,7 @@ FactoryBot.define do ...@@ -24,7 +24,7 @@ FactoryBot.define do
end end
end end
factory :push_event, class: PushEvent do factory :push_event, class: 'PushEvent' do
project factory: :project_empty_repo project factory: :project_empty_repo
author(factory: :user) { project.creator } author(factory: :user) { project.creator }
action { Event::PUSHED } action { Event::PUSHED }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
FactoryBot.define do FactoryBot.define do
sequence(:gitaly_commit_id) { Digest::SHA1.hexdigest(Time.now.to_f.to_s) } sequence(:gitaly_commit_id) { Digest::SHA1.hexdigest(Time.now.to_f.to_s) }
factory :gitaly_commit, class: Gitaly::GitCommit do factory :gitaly_commit, class: 'Gitaly::GitCommit' do
skip_create skip_create
id { generate(:gitaly_commit_id) } id { generate(:gitaly_commit_id) }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :gitaly_commit_author, class: Gitaly::CommitAuthor do factory :gitaly_commit_author, class: 'Gitaly::CommitAuthor' do
skip_create skip_create
name { generate(:name) } name { generate(:name) }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :gitaly_tag, class: Gitaly::Tag do factory :gitaly_tag, class: 'Gitaly::Tag' do
skip_create skip_create
name { 'v3.1.4' } name { 'v3.1.4' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :grafana_integration, class: GrafanaIntegration do factory :grafana_integration, class: 'GrafanaIntegration' do
project project
grafana_url { 'https://grafana.example.com' } grafana_url { 'https://grafana.example.com' }
token { SecureRandom.hex(10) } token { SecureRandom.hex(10) }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :group, class: Group, parent: :namespace do factory :group, class: 'Group', parent: :namespace do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
type { 'Group' } type { 'Group' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :import_state, class: ProjectImportState do factory :import_state, class: 'ProjectImportState' do
status { :none } status { :none }
association :project, factory: :project association :project, factory: :project
......
...@@ -6,7 +6,7 @@ FactoryBot.define do ...@@ -6,7 +6,7 @@ FactoryBot.define do
color { "#990000" } color { "#990000" }
end end
factory :label, traits: [:base_label], class: ProjectLabel do factory :label, traits: [:base_label], class: 'ProjectLabel' do
project project
transient do transient do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :namespace_aggregation_schedules, class: Namespace::AggregationSchedule do factory :namespace_aggregation_schedules, class: 'Namespace::AggregationSchedule' do
namespace namespace
end end
end end
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :namespace_root_storage_statistics, class: Namespace::RootStorageStatistics do factory :namespace_root_storage_statistics, class: 'Namespace::RootStorageStatistics' do
namespace namespace
end end
end end
...@@ -18,9 +18,9 @@ FactoryBot.define do ...@@ -18,9 +18,9 @@ FactoryBot.define do
factory :note_on_personal_snippet, traits: [:on_personal_snippet] factory :note_on_personal_snippet, traits: [:on_personal_snippet]
factory :system_note, traits: [:system] factory :system_note, traits: [:system]
factory :discussion_note, class: DiscussionNote factory :discussion_note, class: 'DiscussionNote'
factory :discussion_note_on_merge_request, traits: [:on_merge_request], class: DiscussionNote do factory :discussion_note_on_merge_request, traits: [:on_merge_request], class: 'DiscussionNote' do
association :project, :repository association :project, :repository
trait :resolved do trait :resolved do
...@@ -29,22 +29,22 @@ FactoryBot.define do ...@@ -29,22 +29,22 @@ FactoryBot.define do
end end
end end
factory :discussion_note_on_issue, traits: [:on_issue], class: DiscussionNote factory :discussion_note_on_issue, traits: [:on_issue], class: 'DiscussionNote'
factory :discussion_note_on_commit, traits: [:on_commit], class: DiscussionNote factory :discussion_note_on_commit, traits: [:on_commit], class: 'DiscussionNote'
factory :discussion_note_on_personal_snippet, traits: [:on_personal_snippet], class: DiscussionNote factory :discussion_note_on_personal_snippet, traits: [:on_personal_snippet], class: 'DiscussionNote'
factory :discussion_note_on_snippet, traits: [:on_snippet], class: DiscussionNote factory :discussion_note_on_snippet, traits: [:on_snippet], class: 'DiscussionNote'
factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: 'LegacyDiffNote'
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: 'LegacyDiffNote' do
association :project, :repository association :project, :repository
position { '' } position { '' }
end end
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do factory :diff_note_on_merge_request, traits: [:on_merge_request], class: 'DiffNote' do
association :project, :repository association :project, :repository
transient do transient do
...@@ -95,7 +95,7 @@ FactoryBot.define do ...@@ -95,7 +95,7 @@ FactoryBot.define do
end end
end end
factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do factory :diff_note_on_commit, traits: [:on_commit], class: 'DiffNote' do
association :project, :repository association :project, :repository
transient do transient do
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :project_error_tracking_setting, class: ErrorTracking::ProjectErrorTrackingSetting do factory :project_error_tracking_setting, class: 'ErrorTracking::ProjectErrorTrackingSetting' do
project project
api_url { 'https://gitlab.com/api/0/projects/sentry-org/sentry-project' } api_url { 'https://gitlab.com/api/0/projects/sentry-org/sentry-project' }
enabled { true } enabled { true }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :project_metrics_setting, class: ProjectMetricsSetting do factory :project_metrics_setting, class: 'ProjectMetricsSetting' do
project project
external_dashboard_url { 'https://grafana.com' } external_dashboard_url { 'https://grafana.com' }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :prometheus_metric, class: PrometheusMetric do factory :prometheus_metric, class: 'PrometheusMetric' do
title { 'title' } title { 'title' }
query { 'avg(metric)' } query { 'avg(metric)' }
y_label { 'y_label' } y_label { 'y_label' }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :release_link, class: ::Releases::Link do factory :release_link, class: '::Releases::Link' do
release release
sequence(:name) { |n| "release-18.#{n}.dmg" } sequence(:name) { |n| "release-18.#{n}.dmg" }
sequence(:url) { |n| "https://example.com/scrambled-url/app-#{n}.zip" } sequence(:url) { |n| "https://example.com/scrambled-url/app-#{n}.zip" }
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :sentry_issue, class: SentryIssue do factory :sentry_issue, class: 'SentryIssue' do
issue issue
sentry_issue_identifier { 1234567891 } sentry_issue_identifier { 1234567891 }
end end
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :serverless_domain_cluster, class: Serverless::DomainCluster do factory :serverless_domain_cluster, class: 'Serverless::DomainCluster' do
pages_domain { create(:pages_domain) } pages_domain { create(:pages_domain) }
knative { create(:clusters_applications_knative) } knative { create(:clusters_applications_knative) }
creator { create(:user) } creator { create(:user) }
......
...@@ -6,7 +6,7 @@ FactoryBot.define do ...@@ -6,7 +6,7 @@ FactoryBot.define do
type { 'Service' } type { 'Service' }
end end
factory :custom_issue_tracker_service, class: CustomIssueTrackerService do factory :custom_issue_tracker_service, class: 'CustomIssueTrackerService' do
project project
active { true } active { true }
issue_tracker issue_tracker
......
# frozen_string_literal: true # frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :term, class: ApplicationSetting::Term do factory :term, class: 'ApplicationSetting::Term' do
terms { "Lorem ipsum dolor sit amet, consectetur adipiscing elit." } terms { "Lorem ipsum dolor sit amet, consectetur adipiscing elit." }
end end
end end
...@@ -46,7 +46,7 @@ FactoryBot.define do ...@@ -46,7 +46,7 @@ FactoryBot.define do
end end
end end
factory :on_commit_todo, class: Todo do factory :on_commit_todo, class: 'Todo' do
project project
author author
user user
......
...@@ -163,9 +163,7 @@ describe 'Issue Boards', :js do ...@@ -163,9 +163,7 @@ describe 'Issue Boards', :js do
end end
it 'infinite scrolls list' do it 'infinite scrolls list' do
50.times do create_list(:labeled_issue, 50, project: project, labels: [planning])
create(:labeled_issue, project: project, labels: [planning])
end
visit project_board_path(project, board) visit project_board_path(project, board)
wait_for_requests wait_for_requests
...@@ -475,9 +473,7 @@ describe 'Issue Boards', :js do ...@@ -475,9 +473,7 @@ describe 'Issue Boards', :js do
end end
it 'infinite scrolls list with label filter' do it 'infinite scrolls list with label filter' do
50.times do create_list(:labeled_issue, 50, project: project, labels: [planning, testing])
create(:labeled_issue, project: project, labels: [planning, testing])
end
set_filter("label", testing.title) set_filter("label", testing.title)
click_filter_link(testing.title) click_filter_link(testing.title)
......
...@@ -10,7 +10,7 @@ describe 'Cohorts page' do ...@@ -10,7 +10,7 @@ describe 'Cohorts page' do
end end
it 'See users count per month' do it 'See users count per month' do
2.times { create(:user) } create_list(:user, 2)
visit instance_statistics_cohorts_path visit instance_statistics_cohorts_path
......
...@@ -83,9 +83,7 @@ describe 'issuable list' do ...@@ -83,9 +83,7 @@ describe 'issuable list' do
create(:merge_request, title: FFaker::Lorem.sentence, source_project: project, source_branch: source_branch, head_pipeline: pipeline) create(:merge_request, title: FFaker::Lorem.sentence, source_project: project, source_branch: source_branch, head_pipeline: pipeline)
end end
2.times do create_list(:note_on_issue, 2, noteable: issuable, project: project)
create(:note_on_issue, noteable: issuable, project: project)
end
create(:award_emoji, :downvote, awardable: issuable) create(:award_emoji, :downvote, awardable: issuable)
create(:award_emoji, :upvote, awardable: issuable) create(:award_emoji, :upvote, awardable: issuable)
......
...@@ -435,9 +435,7 @@ describe IssuesFinder do ...@@ -435,9 +435,7 @@ describe IssuesFinder do
let(:params) { { label_name: described_class::FILTER_ANY } } let(:params) { { label_name: described_class::FILTER_ANY } }
it 'returns issues that have one or more label' do it 'returns issues that have one or more label' do
2.times do create_list(:label_link, 2, label: create(:label, project: project2), target: issue3)
create(:label_link, label: create(:label, project: project2), target: issue3)
end
expect(issues).to contain_exactly(issue2, issue3) expect(issues).to contain_exactly(issue2, issue3)
end end
......
...@@ -455,6 +455,23 @@ describe('getDateInPast', () => { ...@@ -455,6 +455,23 @@ describe('getDateInPast', () => {
}); });
}); });
describe('getDateInFuture', () => {
const date = new Date('2019-07-16T00:00:00.000Z');
const daysInFuture = 90;
it('returns the correct date in the future', () => {
const dateInFuture = datetimeUtility.getDateInFuture(date, daysInFuture);
const expectedDateInFuture = new Date('2019-10-14T00:00:00.000Z');
expect(dateInFuture).toStrictEqual(expectedDateInFuture);
});
it('does not modifiy the original date', () => {
datetimeUtility.getDateInFuture(date, daysInFuture);
expect(date).toStrictEqual(new Date('2019-07-16T00:00:00.000Z'));
});
});
describe('getDatesInRange', () => { describe('getDatesInRange', () => {
it('returns an empty array if 1st or 2nd argument is not a Date object', () => { it('returns an empty array if 1st or 2nd argument is not a Date object', () => {
const d1 = new Date('2019-01-01'); const d1 = new Date('2019-01-01');
......
...@@ -41,7 +41,7 @@ describe Gitlab::Ci::Config::Entry::Reports do ...@@ -41,7 +41,7 @@ describe Gitlab::Ci::Config::Entry::Reports do
:container_scanning | 'gl-container-scanning-report.json' :container_scanning | 'gl-container-scanning-report.json'
:dast | 'gl-dast-report.json' :dast | 'gl-dast-report.json'
:license_management | 'gl-license-management-report.json' :license_management | 'gl-license-management-report.json'
:license_scanning | 'gl-license-management-report.json' :license_scanning | 'gl-license-scanning-report.json'
:performance | 'performance.json' :performance | 'performance.json'
end end
......
...@@ -6,6 +6,10 @@ describe Gitlab::Metrics::Prometheus, :prometheus do ...@@ -6,6 +6,10 @@ describe Gitlab::Metrics::Prometheus, :prometheus do
let(:all_metrics) { Gitlab::Metrics } let(:all_metrics) { Gitlab::Metrics }
let(:registry) { all_metrics.registry } let(:registry) { all_metrics.registry }
after do
all_metrics.clear_errors!
end
describe '#reset_registry!' do describe '#reset_registry!' do
it 'clears existing metrics' do it 'clears existing metrics' do
registry.counter(:test, 'test metric') registry.counter(:test, 'test metric')
......
...@@ -13,7 +13,7 @@ describe EachBatch do ...@@ -13,7 +13,7 @@ describe EachBatch do
end end
before do before do
5.times { create(:user, updated_at: 1.day.ago) } create_list(:user, 5, updated_at: 1.day.ago)
end end
shared_examples 'each_batch handling' do |kwargs| shared_examples 'each_batch handling' do |kwargs|
......
...@@ -326,7 +326,7 @@ describe Issuable do ...@@ -326,7 +326,7 @@ describe Issuable do
context 'when all of the results are level on the sort key' do context 'when all of the results are level on the sort key' do
let!(:issues) do let!(:issues) do
10.times { create(:issue, project: project) } create_list(:issue, 10, project: project)
end end
it 'has no duplicates across pages' do it 'has no duplicates across pages' do
......
...@@ -1348,9 +1348,7 @@ describe Project do ...@@ -1348,9 +1348,7 @@ describe Project do
let(:project2) { create(:project, :public, group: group) } let(:project2) { create(:project, :public, group: group) }
before do before do
2.times do create_list(:note_on_commit, 2, project: project1)
create(:note_on_commit, project: project1)
end
create(:note_on_commit, project: project2) create(:note_on_commit, project: project2)
...@@ -1364,9 +1362,7 @@ describe Project do ...@@ -1364,9 +1362,7 @@ describe Project do
end end
it 'does not take system notes into account' do it 'does not take system notes into account' do
10.times do create_list(:note_on_commit, 10, project: project2, system: true)
create(:note_on_commit, project: project2, system: true)
end
expect(described_class.trending.to_a).to eq([project1, project2]) expect(described_class.trending.to_a).to eq([project1, project2])
end end
......
...@@ -11,13 +11,9 @@ describe TrendingProject do ...@@ -11,13 +11,9 @@ describe TrendingProject do
let(:internal_project) { create(:project, :internal) } let(:internal_project) { create(:project, :internal) }
before do before do
3.times do create_list(:note_on_commit, 3, project: public_project1)
create(:note_on_commit, project: public_project1)
end
2.times do create_list(:note_on_commit, 2, project: public_project2)
create(:note_on_commit, project: public_project2)
end
create(:note_on_commit, project: public_project3, created_at: 5.weeks.ago) create(:note_on_commit, project: public_project3, created_at: 5.weeks.ago)
create(:note_on_commit, project: private_project) create(:note_on_commit, project: private_project)
......
...@@ -244,7 +244,7 @@ describe API::Jobs do ...@@ -244,7 +244,7 @@ describe API::Jobs do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
end.count end.count
3.times { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) } create_list(:ci_build, 3, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline)
expect do expect do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
......
...@@ -254,9 +254,7 @@ describe API::Pipelines do ...@@ -254,9 +254,7 @@ describe API::Pipelines do
context 'when order_by and sort are specified' do context 'when order_by and sort are specified' do
context 'when order_by user_id' do context 'when order_by user_id' do
before do before do
3.times do create_list(:ci_pipeline, 3, project: project, user: create(:user))
create(:ci_pipeline, project: project, user: create(:user))
end
end end
context 'when sort parameter is valid' do context 'when sort parameter is valid' do
......
...@@ -6,7 +6,7 @@ describe 'search/_results' do ...@@ -6,7 +6,7 @@ describe 'search/_results' do
before do before do
controller.params[:action] = 'show' controller.params[:action] = 'show'
3.times { create(:issue) } create_list(:issue, 3)
@search_objects = Issue.page(1).per(2) @search_objects = Issue.page(1).per(2)
@scope = 'issues' @scope = 'issues'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment