notes.rb 2.06 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# == Schema Information
#
# Table name: notes
#
#  id            :integer          not null, primary key
#  note          :text
#  noteable_type :string(255)
#  author_id     :integer
#  created_at    :datetime
#  updated_at    :datetime
#  project_id    :integer
#  attachment    :string(255)
#  line_code     :string(255)
#  commit_id     :string(255)
#  noteable_id   :integer
#  system        :boolean          default(FALSE), not null
#  st_diff       :text
Stan Hu's avatar
Stan Hu committed
18
#  updated_by_id :integer
Stan Hu's avatar
Stan Hu committed
19
#  is_award      :boolean          default(FALSE), not null
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
20 21
#

22 23 24 25 26 27 28 29
require_relative '../support/repo_helpers'

FactoryGirl.define do
  factory :note do
    project
    note "Note"
    author

30 31 32 33
    factory :note_on_commit,             traits: [:on_commit]
    factory :note_on_commit_diff,        traits: [:on_commit, :on_diff]
    factory :note_on_issue,              traits: [:on_issue], aliases: [:votable_note]
    factory :note_on_merge_request,      traits: [:on_merge_request]
34
    factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
35 36
    factory :note_on_project_snippet,    traits: [:on_project_snippet]
    factory :system_note,                traits: [:system]
37 38
    factory :downvote_note,              traits: [:award, :downvote]
    factory :upvote_note,                traits: [:award, :upvote]
39 40

    trait :on_commit do
41
      project
42 43 44 45 46 47 48 49 50
      commit_id RepoHelpers.sample_commit.id
      noteable_type "Commit"
    end

    trait :on_diff do
      line_code "0_184_184"
    end

    trait :on_merge_request do
51
      project
52 53 54 55 56 57 58 59 60
      noteable_id 1
      noteable_type "MergeRequest"
    end

    trait :on_issue do
      noteable_id 1
      noteable_type "Issue"
    end

61 62 63 64 65
    trait :on_project_snippet do
      noteable_id 1
      noteable_type "Snippet"
    end

66 67 68 69
    trait :system do
      system true
    end

70 71 72 73 74 75 76 77 78 79 80 81
    trait :award do
      is_award true
    end

    trait :downvote do
      note "thumbsdown"
    end

    trait :upvote do
      note "thumbsup"
    end

82 83 84 85 86
    trait :with_attachment do
      attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
    end
  end
end