2014-08-01 14:54:44 +00:00
|
|
|
require_relative '../support/repo_helpers'
|
|
|
|
|
2016-02-17 03:55:24 +00:00
|
|
|
include ActionDispatch::TestProcess
|
|
|
|
|
2014-08-01 14:54:44 +00:00
|
|
|
FactoryGirl.define do
|
|
|
|
factory :note do
|
2017-01-25 01:30:56 +00:00
|
|
|
project factory: :empty_project
|
2014-08-01 14:54:44 +00:00
|
|
|
note "Note"
|
|
|
|
author
|
2016-05-18 17:38:52 +00:00
|
|
|
on_issue
|
2014-08-01 14:54:44 +00:00
|
|
|
|
2015-05-01 03:16:19 +00:00
|
|
|
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]
|
2017-01-05 13:36:06 +00:00
|
|
|
factory :note_on_personal_snippet, traits: [:on_personal_snippet]
|
2015-05-01 03:16:19 +00:00
|
|
|
factory :system_note, traits: [:system]
|
2014-08-01 14:54:44 +00:00
|
|
|
|
2017-01-25 19:52:12 +00:00
|
|
|
factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote do
|
|
|
|
association :project, :repository
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do
|
|
|
|
association :project, :repository
|
|
|
|
end
|
2016-06-20 17:20:39 +00:00
|
|
|
|
|
|
|
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
|
2017-01-25 19:52:12 +00:00
|
|
|
association :project, :repository
|
2016-06-20 17:20:39 +00:00
|
|
|
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-02 20:29:47 +00:00
|
|
|
|
|
|
|
trait :resolved do
|
|
|
|
resolved_at { Time.now }
|
|
|
|
resolved_by { create(:user) }
|
|
|
|
end
|
2016-06-20 17:20:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do
|
2017-01-25 01:30:56 +00:00
|
|
|
association :project, :repository
|
2016-06-20 17:20:39 +00:00
|
|
|
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-08-01 14:54:44 +00:00
|
|
|
trait :on_commit do
|
2017-01-25 19:52:12 +00:00
|
|
|
association :project, :repository
|
2016-04-26 09:11:58 +00:00
|
|
|
noteable nil
|
2016-05-18 17:38:52 +00:00
|
|
|
noteable_type 'Commit'
|
2016-06-20 17:20:39 +00:00
|
|
|
noteable_id nil
|
2014-08-01 14:54:44 +00:00
|
|
|
commit_id RepoHelpers.sample_commit.id
|
|
|
|
end
|
|
|
|
|
2016-06-20 17:20:39 +00:00
|
|
|
trait :legacy_diff_note do
|
2014-08-01 14:54:44 +00:00
|
|
|
line_code "0_184_184"
|
|
|
|
end
|
|
|
|
|
2016-05-04 09:17:16 +00:00
|
|
|
trait :on_issue do
|
|
|
|
noteable { create(:issue, project: project) }
|
2014-08-01 14:54:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :on_merge_request do
|
2016-05-18 16:21:14 +00:00
|
|
|
noteable { create(:merge_request, source_project: project) }
|
2014-08-01 14:54:44 +00:00
|
|
|
end
|
|
|
|
|
2015-03-05 18:38:23 +00:00
|
|
|
trait :on_project_snippet do
|
2016-12-09 01:56:31 +00:00
|
|
|
noteable { create(:project_snippet, project: project) }
|
2015-03-05 18:38:23 +00:00
|
|
|
end
|
|
|
|
|
2017-01-05 13:36:06 +00:00
|
|
|
trait :on_personal_snippet do
|
|
|
|
noteable { create(:personal_snippet) }
|
|
|
|
project nil
|
|
|
|
end
|
|
|
|
|
2015-05-01 03:16:19 +00:00
|
|
|
trait :system do
|
|
|
|
system true
|
|
|
|
end
|
|
|
|
|
2016-02-17 13:32:02 +00:00
|
|
|
trait :downvote do
|
|
|
|
note "thumbsdown"
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :upvote do
|
|
|
|
note "thumbsup"
|
|
|
|
end
|
|
|
|
|
2014-08-01 14:54:44 +00:00
|
|
|
trait :with_attachment do
|
|
|
|
attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|