gitlab-org--gitlab-foss/spec/factories/merge_requests.rb
Adam Buckland ace833b31d Add indication for closed or merged issuables in GFM
Example: for issues that are closed, the links will now show '[closed]'
following the issue number. This is done as post-process after the markdown has
been loaded from the cache as the status of the issue may change between
the cache being populated and the content being displayed.

In order to avoid N+1 queries problem when rendering notes ObjectRenderer
populates the cache of referenced issuables for all notes at once,
before the post processing phase.

As a part of this change, the Banzai BaseParser#grouped_objects_for_nodes
method has been refactored to return a Hash utilising the node itself as the
key, since this was a common pattern of usage for this method.
2017-04-07 14:31:43 -05:00

91 lines
2.1 KiB
Ruby

FactoryGirl.define do
factory :merge_request do
title { generate(:title) }
author
association :source_project, :repository, factory: :project
target_project { source_project }
# $ git log --pretty=oneline feature..master
# 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
# 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files
# 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules
# d14d6c0abdd253381df51a723d58691b2ee1ab08 Remove ds_store files
# c1acaa58bbcbc3eafe538cb8274ba387047b69f8 Ignore DS files
#
# See also RepoHelpers.sample_compare
#
source_branch "master"
target_branch "feature"
merge_status "can_be_merged"
trait :with_diffs do
end
trait :without_diffs do
source_branch "improve/awesome"
target_branch "master"
end
trait :conflict do
source_branch "feature_conflict"
target_branch "feature"
end
trait :merged do
state :merged
end
trait :closed do
state :closed
end
trait :reopened do
state :reopened
end
trait :locked do
state :locked
end
trait :simple do
source_branch "feature"
target_branch "master"
end
trait :rebased do
source_branch "markdown"
target_branch "improve/awesome"
end
trait :diverged do
source_branch "feature"
target_branch "master"
end
trait :merge_when_pipeline_succeeds do
merge_when_pipeline_succeeds true
merge_user author
end
factory :merged_merge_request, traits: [:merged]
factory :closed_merge_request, traits: [:closed]
factory :reopened_merge_request, traits: [:reopened]
factory :merge_request_with_diffs, traits: [:with_diffs]
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
factory :labeled_merge_request do
transient do
labels []
end
after(:create) do |merge_request, evaluator|
merge_request.update_attributes(labels: evaluator.labels)
end
end
end
end