merge_requests.rb 2.2 KB
Newer Older
1 2
FactoryGirl.define do
  factory :merge_request do
Rémy Coutable's avatar
Rémy Coutable committed
3
    title { generate(:title) }
4
    author
5
    association :source_project, :repository, factory: :project
6 7
    target_project { source_project }

8
    # $ git log --pretty=oneline feature..master
9 10 11 12 13
    # 5937ac0a7beb003549fc5fd26fc247adbce4a52e Add submodule from gitlab.com
    # 570e7b2abdd848b95f2f578043fc23bd6f6fd24d Change some files
    # 6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9 More submodules
    # d14d6c0abdd253381df51a723d58691b2ee1ab08 Remove ds_store files
    # c1acaa58bbcbc3eafe538cb8274ba387047b69f8 Ignore DS files
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14 15 16
    #
    # See also RepoHelpers.sample_compare
    #
17 18 19
    source_branch "master"
    target_branch "feature"

20
    merge_status "can_be_merged"
21 22 23 24

    trait :with_diffs do
    end

25 26 27 28 29
    trait :without_diffs do
      source_branch "improve/awesome"
      target_branch "master"
    end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
30 31 32 33 34
    trait :conflict do
      source_branch "feature_conflict"
      target_branch "feature"
    end

35 36 37 38
    trait :merged do
      state :merged
    end

39 40 41 42
    trait :closed do
      state :closed
    end

43 44 45 46
    trait :opened do
      state :opened
    end

47 48 49 50
    trait :reopened do
      state :reopened
    end

51 52 53 54
    trait :locked do
      state :locked
    end

55 56 57 58 59
    trait :simple do
      source_branch "feature"
      target_branch "master"
    end

60 61 62 63 64 65 66 67 68 69
    trait :rebased do
      source_branch "markdown"
      target_branch "improve/awesome"
    end

    trait :diverged do
      source_branch "feature"
      target_branch "master"
    end

70 71
    trait :merge_when_pipeline_succeeds do
      merge_when_pipeline_succeeds true
Zeger-Jan van de Weg's avatar
Zeger-Jan van de Weg committed
72 73 74
      merge_user author
    end

75
    factory :merged_merge_request, traits: [:merged]
76 77 78
    factory :closed_merge_request, traits: [:closed]
    factory :reopened_merge_request, traits: [:reopened]
    factory :merge_request_with_diffs, traits: [:with_diffs]
79 80 81 82 83
    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
84 85 86 87 88 89 90 91 92 93

    factory :labeled_merge_request do
      transient do
        labels []
      end

      after(:create) do |merge_request, evaluator|
        merge_request.update_attributes(labels: evaluator.labels)
      end
    end
94 95
  end
end