debian-mirror-gitlab/spec/factories/notes.rb

90 lines
2.3 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require_relative '../support/repo_helpers'
2016-06-02 11:05:42 +05:30
include ActionDispatch::TestProcess
2014-09-02 18:07:02 +05:30
FactoryGirl.define do
factory :note do
project
note "Note"
author
on_issue
2014-09-02 18:07:02 +05:30
2015-09-11 14:41:01 +05:30
factory :note_on_commit, traits: [:on_commit]
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_project_snippet, traits: [:on_project_snippet]
factory :system_note, traits: [:system]
2014-09-02 18:07:02 +05:30
2016-08-24 12:49:21 +05:30
factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
position do
Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb",
new_path: "files/ruby/popen.rb",
old_line: nil,
new_line: 14,
diff_refs: noteable.diff_refs
)
end
2016-09-29 09:46:39 +05:30
trait :resolved do
resolved_at { Time.now }
resolved_by { create(:user) }
end
2016-08-24 12:49:21 +05:30
end
factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do
position do
Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb",
new_path: "files/ruby/popen.rb",
old_line: nil,
new_line: 14,
diff_refs: project.commit(commit_id).try(:diff_refs)
)
end
end
2014-09-02 18:07:02 +05:30
trait :on_commit do
noteable nil
noteable_type 'Commit'
2016-08-24 12:49:21 +05:30
noteable_id nil
2014-09-02 18:07:02 +05:30
commit_id RepoHelpers.sample_commit.id
end
2016-08-24 12:49:21 +05:30
trait :legacy_diff_note do
2014-09-02 18:07:02 +05:30
line_code "0_184_184"
end
trait :on_issue do
noteable { create(:issue, project: project) }
2014-09-02 18:07:02 +05:30
end
trait :on_merge_request do
noteable { create(:merge_request, source_project: project) }
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
trait :on_project_snippet do
noteable { create(:snippet, project: project) }
2015-04-26 12:48:37 +05:30
end
2015-09-11 14:41:01 +05:30
trait :system do
system true
end
2016-04-02 18:10:28 +05:30
trait :downvote do
note "thumbsdown"
end
trait :upvote do
note "thumbsup"
end
2014-09-02 18:07:02 +05:30
trait :with_attachment do
attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
end
end
end