diff options
Diffstat (limited to 'spec/factories/merge_requests.rb')
-rw-r--r-- | spec/factories/merge_requests.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index e5381071228..e69743122cc 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -24,6 +24,14 @@ FactoryBot.define do trait :with_diffs do end + trait :jira_title do + title { generate(:jira_title) } + end + + trait :jira_branch do + source_branch { generate(:jira_branch) } + end + trait :with_image_diffs do source_branch { "add_images_and_changes" } target_branch { "master" } @@ -52,7 +60,7 @@ FactoryBot.define do after(:build) do |merge_request, evaluator| metrics = merge_request.build_metrics - metrics.merged_at = 1.week.ago + metrics.merged_at = 1.week.from_now metrics.merged_by = evaluator.merged_by metrics.pipeline = create(:ci_empty_pipeline) end @@ -159,6 +167,18 @@ FactoryBot.define do end end + trait :with_codequality_reports do + after(:build) do |merge_request| + merge_request.head_pipeline = build( + :ci_pipeline, + :success, + :with_codequality_reports, + project: merge_request.source_project, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha) + end + end + trait :unique_branches do source_branch { generate(:branch) } target_branch { generate(:branch) } @@ -237,7 +257,7 @@ FactoryBot.define do target_branch { 'pages-deploy-target' } transient do - deployment { create(:deployment, :review_app) } + deployment { association(:deployment, :review_app) } end after(:build) do |merge_request, evaluator| @@ -256,7 +276,7 @@ FactoryBot.define do source_project = merge_request.source_project # Fake `fetch_ref!` if we don't have repository - # We have too many existing tests replying on this behaviour + # We have too many existing tests relying on this behaviour unless [target_project, source_project].all?(&:repository_exists?) allow(merge_request).to receive(:fetch_ref!) end |