2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2014-07-31 11:07:24 -04:00
|
|
|
factory :merge_request do
|
2017-03-23 12:37:14 -04:00
|
|
|
title { generate(:title) }
|
2017-01-25 14:52:12 -05:00
|
|
|
association :source_project, :repository, factory: :project
|
2014-07-31 11:07:24 -04:00
|
|
|
target_project { source_project }
|
2017-08-04 13:14:04 -04:00
|
|
|
author { source_project.creator }
|
2014-07-31 11:07:24 -04:00
|
|
|
|
2015-06-22 14:43:51 -04:00
|
|
|
# $ git log --pretty=oneline feature..master
|
2014-07-31 11:07:24 -04:00
|
|
|
# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
|
|
|
|
# 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files
|
|
|
|
# 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules
|
|
|
|
# d14d6c0abdd253381df51a723d58691b2ee1ab08 Remove ds_store files
|
|
|
|
# c1acaa58bbcbc3eafe538cb8274ba387047b69f8 Ignore DS files
|
2014-08-06 02:52:56 -04:00
|
|
|
#
|
|
|
|
# See also RepoHelpers.sample_compare
|
|
|
|
#
|
2014-07-31 11:07:24 -04:00
|
|
|
source_branch "master"
|
|
|
|
target_branch "feature"
|
|
|
|
|
2015-03-05 13:38:23 -05:00
|
|
|
merge_status "can_be_merged"
|
2014-07-31 11:07:24 -04:00
|
|
|
|
|
|
|
trait :with_diffs do
|
|
|
|
end
|
|
|
|
|
2017-10-07 00:25:17 -04:00
|
|
|
trait :with_image_diffs do
|
|
|
|
source_branch "add_images_and_changes"
|
|
|
|
target_branch "master"
|
|
|
|
end
|
|
|
|
|
2016-03-09 02:19:54 -05:00
|
|
|
trait :without_diffs do
|
|
|
|
source_branch "improve/awesome"
|
|
|
|
target_branch "master"
|
|
|
|
end
|
|
|
|
|
2014-08-06 02:52:56 -04:00
|
|
|
trait :conflict do
|
|
|
|
source_branch "feature_conflict"
|
|
|
|
target_branch "feature"
|
|
|
|
end
|
|
|
|
|
2016-03-01 06:32:20 -05:00
|
|
|
trait :merged do
|
|
|
|
state :merged
|
|
|
|
end
|
|
|
|
|
2018-05-08 17:44:32 -04:00
|
|
|
trait :merged_target do
|
|
|
|
source_branch "merged-target"
|
|
|
|
target_branch "improve/awesome"
|
|
|
|
end
|
|
|
|
|
2014-07-31 11:07:24 -04:00
|
|
|
trait :closed do
|
|
|
|
state :closed
|
|
|
|
end
|
|
|
|
|
2017-04-16 23:51:16 -04:00
|
|
|
trait :opened do
|
|
|
|
state :opened
|
|
|
|
end
|
|
|
|
|
2016-08-24 13:11:48 -04:00
|
|
|
trait :locked do
|
|
|
|
state :locked
|
|
|
|
end
|
|
|
|
|
2014-07-31 11:07:24 -04:00
|
|
|
trait :simple do
|
|
|
|
source_branch "feature"
|
|
|
|
target_branch "master"
|
|
|
|
end
|
|
|
|
|
2016-02-04 13:23:58 -05:00
|
|
|
trait :rebased do
|
|
|
|
source_branch "markdown"
|
|
|
|
target_branch "improve/awesome"
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :diverged do
|
|
|
|
source_branch "feature"
|
|
|
|
target_branch "master"
|
|
|
|
end
|
|
|
|
|
2017-02-17 08:56:13 -05:00
|
|
|
trait :merge_when_pipeline_succeeds do
|
|
|
|
merge_when_pipeline_succeeds true
|
2015-12-03 04:27:34 -05:00
|
|
|
merge_user author
|
|
|
|
end
|
|
|
|
|
2017-10-11 16:06:15 -04:00
|
|
|
trait :remove_source_branch do
|
|
|
|
merge_params do
|
|
|
|
{ 'force_remove_source_branch' => '1' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-09 07:30:07 -04:00
|
|
|
after(:build) do |merge_request|
|
|
|
|
target_project = merge_request.target_project
|
2017-08-09 09:41:45 -04:00
|
|
|
source_project = merge_request.source_project
|
2017-08-09 07:30:07 -04:00
|
|
|
|
2017-11-06 09:03:11 -05:00
|
|
|
# Fake `fetch_ref!` if we don't have repository
|
2017-08-09 07:30:07 -04:00
|
|
|
# We have too many existing tests replying on this behaviour
|
2017-08-09 09:41:45 -04:00
|
|
|
unless [target_project, source_project].all?(&:repository_exists?)
|
2017-11-06 09:03:11 -05:00
|
|
|
allow(merge_request).to receive(:fetch_ref!)
|
2017-08-09 07:30:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-01 06:32:20 -05:00
|
|
|
factory :merged_merge_request, traits: [:merged]
|
2014-07-31 11:07:24 -04:00
|
|
|
factory :closed_merge_request, traits: [:closed]
|
2017-07-19 10:03:50 -04:00
|
|
|
factory :reopened_merge_request, traits: [:opened]
|
2014-07-31 11:07:24 -04:00
|
|
|
factory :merge_request_with_diffs, traits: [:with_diffs]
|
2016-09-16 07:02:42 -04:00
|
|
|
factory :merge_request_with_diff_notes do
|
|
|
|
after(:create) do |mr|
|
|
|
|
create(:diff_note_on_merge_request, noteable: mr, project: mr.source_project)
|
|
|
|
end
|
|
|
|
end
|
2016-09-26 16:10:54 -04:00
|
|
|
|
|
|
|
factory :labeled_merge_request do
|
|
|
|
transient do
|
|
|
|
labels []
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |merge_request, evaluator|
|
|
|
|
merge_request.update_attributes(labels: evaluator.labels)
|
|
|
|
end
|
|
|
|
end
|
2014-07-31 11:07:24 -04:00
|
|
|
end
|
|
|
|
end
|