BigW Consortium Gitlab

notes.rb 1.47 KB
Newer Older
1 2
require_relative '../support/repo_helpers'

3 4
include ActionDispatch::TestProcess

5 6 7 8 9
FactoryGirl.define do
  factory :note do
    project
    note "Note"
    author
Grzegorz Bizon committed
10
    on_issue
11

12
    factory :note_on_commit,             traits: [:on_commit]
Douwe Maan committed
13
    factory :note_on_commit_diff,        traits: [:on_commit, :on_diff], class: LegacyDiffNote
14 15
    factory :note_on_issue,              traits: [:on_issue], aliases: [:votable_note]
    factory :note_on_merge_request,      traits: [:on_merge_request]
Douwe Maan committed
16
    factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff], class: LegacyDiffNote
17 18
    factory :note_on_project_snippet,    traits: [:on_project_snippet]
    factory :system_note,                traits: [:system]
19 20

    trait :on_commit do
21
      noteable nil
22
      noteable_id nil
Grzegorz Bizon committed
23
      noteable_type 'Commit'
24 25 26 27 28 29 30
      commit_id RepoHelpers.sample_commit.id
    end

    trait :on_diff do
      line_code "0_184_184"
    end

31 32
    trait :on_issue do
      noteable { create(:issue, project: project) }
33 34 35
    end

    trait :on_merge_request do
Grzegorz Bizon committed
36
      noteable { create(:merge_request, source_project: project) }
37 38
    end

39
    trait :on_project_snippet do
40
      noteable { create(:snippet, project: project) }
41 42
    end

43 44 45 46
    trait :system do
      system true
    end

47 48 49 50 51 52 53 54
    trait :downvote do
      note "thumbsdown"
    end

    trait :upvote do
      note "thumbsup"
    end

55 56 57 58 59
    trait :with_attachment do
      attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
    end
  end
end