2013-06-26 10:32:34 -04:00
|
|
|
include ActionDispatch::TestProcess
|
|
|
|
|
2012-08-28 01:42:28 -04:00
|
|
|
FactoryGirl.define do
|
|
|
|
sequence :sentence, aliases: [:title, :content] do
|
|
|
|
Faker::Lorem.sentence
|
|
|
|
end
|
|
|
|
|
2012-08-29 11:36:02 -04:00
|
|
|
sequence :name, aliases: [:file_name] do
|
|
|
|
Faker::Name.name
|
|
|
|
end
|
|
|
|
|
2012-08-28 01:42:28 -04:00
|
|
|
sequence(:url) { Faker::Internet.uri('http') }
|
|
|
|
|
2013-01-02 12:00:00 -05:00
|
|
|
factory :user, aliases: [:author, :assignee, :owner, :creator] do
|
2012-08-28 01:42:28 -04:00
|
|
|
email { Faker::Internet.email }
|
2012-08-29 11:36:02 -04:00
|
|
|
name
|
2013-01-28 10:46:24 -05:00
|
|
|
sequence(:username) { |n| "#{Faker::Internet.user_name}#{n}" }
|
2012-08-28 01:42:28 -04:00
|
|
|
password "123456"
|
2012-09-04 00:04:36 -04:00
|
|
|
password_confirmation { password }
|
2012-08-28 01:42:28 -04:00
|
|
|
|
|
|
|
trait :admin do
|
|
|
|
admin true
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :admin, traits: [:admin]
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :project do
|
|
|
|
sequence(:name) { |n| "project#{n}" }
|
2013-04-01 09:56:25 -04:00
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
2013-01-02 12:00:00 -05:00
|
|
|
creator
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
2013-02-11 06:41:12 -05:00
|
|
|
factory :redmine_project, parent: :project do
|
|
|
|
issues_tracker { "redmine" }
|
2013-02-11 09:17:43 -05:00
|
|
|
issues_tracker_id { "project_name_in_redmine" }
|
2013-02-11 06:41:12 -05:00
|
|
|
end
|
|
|
|
|
2013-04-01 09:56:25 -04:00
|
|
|
factory :project_with_code, parent: :project do
|
|
|
|
path { 'gitlabhq' }
|
2013-06-22 11:57:34 -04:00
|
|
|
|
|
|
|
after :create do |project|
|
|
|
|
repos_path = Rails.root.join('tmp', 'test-git-base-path')
|
|
|
|
seed_repo = Rails.root.join('tmp', 'repositories', 'gitlabhq')
|
|
|
|
target_repo = File.join(repos_path, project.path_with_namespace + '.git')
|
|
|
|
system("ln -s #{seed_repo} #{target_repo}")
|
|
|
|
end
|
2013-04-01 09:56:25 -04:00
|
|
|
end
|
|
|
|
|
2012-11-23 13:53:24 -05:00
|
|
|
factory :group do
|
2012-10-02 11:20:46 -04:00
|
|
|
sequence(:name) { |n| "group#{n}" }
|
2012-11-23 13:31:09 -05:00
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
2012-10-02 11:20:46 -04:00
|
|
|
owner
|
2012-11-23 13:53:24 -05:00
|
|
|
type 'Group'
|
|
|
|
end
|
2012-11-22 14:41:16 -05:00
|
|
|
|
2012-11-23 13:53:24 -05:00
|
|
|
factory :namespace do
|
2013-01-02 12:32:34 -05:00
|
|
|
sequence(:name) { |n| "namespace#{n}" }
|
2012-11-23 13:53:24 -05:00
|
|
|
path { name.downcase.gsub(/\s/, '_') }
|
|
|
|
owner
|
2012-10-02 11:20:46 -04:00
|
|
|
end
|
|
|
|
|
2012-08-28 01:42:28 -04:00
|
|
|
factory :users_project do
|
|
|
|
user
|
|
|
|
project
|
2012-12-22 12:52:28 -05:00
|
|
|
project_access { UsersProject::MASTER }
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :issue do
|
|
|
|
title
|
|
|
|
author
|
|
|
|
project
|
|
|
|
|
|
|
|
trait :closed do
|
2013-02-18 04:10:58 -05:00
|
|
|
state :closed
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :reopened do
|
|
|
|
state :reopened
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :closed_issue, traits: [:closed]
|
2013-02-18 04:10:58 -05:00
|
|
|
factory :reopened_issue, traits: [:reopened]
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :merge_request do
|
|
|
|
title
|
|
|
|
author
|
2013-04-01 11:24:05 -04:00
|
|
|
project factory: :project_with_code
|
2012-08-28 01:42:28 -04:00
|
|
|
source_branch "master"
|
|
|
|
target_branch "stable"
|
2012-10-09 18:25:29 -04:00
|
|
|
|
2012-11-24 18:04:13 -05:00
|
|
|
# pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d)
|
|
|
|
trait :with_diffs do
|
2013-01-14 18:27:26 -05:00
|
|
|
target_branch "master" # pretend bcf03b5d~3
|
|
|
|
source_branch "stable" # pretend bcf03b5d
|
2012-11-24 18:04:13 -05:00
|
|
|
st_commits do
|
2013-04-03 03:06:31 -04:00
|
|
|
[
|
|
|
|
project.repository.commit('bcf03b5d').to_hash,
|
|
|
|
project.repository.commit('bcf03b5d~1').to_hash,
|
|
|
|
project.repository.commit('bcf03b5d~2').to_hash
|
|
|
|
]
|
2012-11-24 18:04:13 -05:00
|
|
|
end
|
|
|
|
st_diffs do
|
|
|
|
project.repo.diff("bcf03b5d~3", "bcf03b5d")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-18 03:40:56 -05:00
|
|
|
trait :closed do
|
|
|
|
state :closed
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :reopened do
|
|
|
|
state :reopened
|
|
|
|
end
|
|
|
|
|
2012-10-09 18:25:29 -04:00
|
|
|
factory :closed_merge_request, traits: [:closed]
|
2013-02-18 03:40:56 -05:00
|
|
|
factory :reopened_merge_request, traits: [:reopened]
|
2012-11-24 18:04:13 -05:00
|
|
|
factory :merge_request_with_diffs, traits: [:with_diffs]
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :note do
|
|
|
|
project
|
|
|
|
note "Note"
|
2012-10-29 22:27:36 -04:00
|
|
|
author
|
|
|
|
|
|
|
|
factory :note_on_commit, traits: [:on_commit]
|
2013-01-02 15:31:48 -05:00
|
|
|
factory :note_on_commit_diff, traits: [:on_commit, :on_diff]
|
2012-10-29 22:27:36 -04:00
|
|
|
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
|
|
|
|
factory :note_on_merge_request, traits: [:on_merge_request]
|
2013-01-02 15:31:48 -05:00
|
|
|
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
|
2013-06-26 10:32:34 -04:00
|
|
|
factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment]
|
2012-10-29 22:27:36 -04:00
|
|
|
|
|
|
|
trait :on_commit do
|
2013-04-01 10:27:44 -04:00
|
|
|
project factory: :project_with_code
|
2012-12-22 19:03:57 -05:00
|
|
|
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
|
2012-10-29 22:27:36 -04:00
|
|
|
noteable_type "Commit"
|
|
|
|
end
|
|
|
|
|
2013-01-02 15:31:48 -05:00
|
|
|
trait :on_diff do
|
2012-10-29 22:27:36 -04:00
|
|
|
line_code "0_184_184"
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :on_merge_request do
|
2013-04-01 10:27:44 -04:00
|
|
|
project factory: :project_with_code
|
2012-10-29 22:27:36 -04:00
|
|
|
noteable_id 1
|
|
|
|
noteable_type "MergeRequest"
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :on_issue do
|
2012-12-22 19:03:57 -05:00
|
|
|
noteable_id 1
|
2012-10-29 22:27:36 -04:00
|
|
|
noteable_type "Issue"
|
|
|
|
end
|
2013-06-26 10:32:34 -04:00
|
|
|
|
|
|
|
trait :with_attachment do
|
|
|
|
attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") }
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :event do
|
2012-09-27 16:23:11 -04:00
|
|
|
factory :closed_issue_event do
|
|
|
|
project
|
2013-02-13 06:48:16 -05:00
|
|
|
action { Event::CLOSED }
|
2012-09-27 16:23:11 -04:00
|
|
|
target factory: :closed_issue
|
|
|
|
author factory: :user
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :key do
|
|
|
|
title
|
2012-08-28 21:15:21 -04:00
|
|
|
key do
|
2012-09-21 12:22:43 -04:00
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
|
2012-08-28 21:15:21 -04:00
|
|
|
end
|
2012-08-28 06:57:00 -04:00
|
|
|
|
2013-05-06 08:09:26 -04:00
|
|
|
factory :deploy_key, class: 'DeployKey' do
|
2012-08-28 06:57:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :personal_key do
|
|
|
|
user
|
|
|
|
end
|
2012-09-21 12:22:43 -04:00
|
|
|
|
|
|
|
factory :key_with_a_space_in_the_middle do
|
|
|
|
key do
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
|
|
|
|
end
|
|
|
|
end
|
2013-02-15 04:31:05 -05:00
|
|
|
|
|
|
|
factory :invalid_key do
|
|
|
|
key do
|
|
|
|
"ssh-rsa this_is_invalid_key=="
|
|
|
|
end
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :milestone do
|
|
|
|
title
|
|
|
|
project
|
2013-02-18 04:38:29 -05:00
|
|
|
|
|
|
|
trait :closed do
|
|
|
|
state :closed
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :closed_milestone, traits: [:closed]
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :system_hook do
|
|
|
|
url
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :project_hook do
|
|
|
|
url
|
|
|
|
end
|
|
|
|
|
2013-03-24 14:31:14 -04:00
|
|
|
factory :project_snippet do
|
2012-08-28 01:42:28 -04:00
|
|
|
project
|
|
|
|
author
|
|
|
|
title
|
|
|
|
content
|
2012-08-29 11:36:02 -04:00
|
|
|
file_name
|
|
|
|
end
|
|
|
|
|
2013-03-24 18:18:03 -04:00
|
|
|
factory :personal_snippet do
|
|
|
|
author
|
|
|
|
title
|
|
|
|
content
|
|
|
|
file_name
|
|
|
|
end
|
|
|
|
|
2013-03-24 14:31:14 -04:00
|
|
|
factory :snippet do
|
|
|
|
author
|
|
|
|
title
|
|
|
|
content
|
|
|
|
file_name
|
|
|
|
end
|
|
|
|
|
2012-08-29 11:36:02 -04:00
|
|
|
factory :protected_branch do
|
|
|
|
name
|
|
|
|
project
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
2012-11-19 13:24:05 -05:00
|
|
|
|
|
|
|
factory :service do
|
|
|
|
type ""
|
|
|
|
title "GitLab CI"
|
|
|
|
token "x56olispAND34ng"
|
|
|
|
project
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :service_hook do
|
|
|
|
url
|
|
|
|
service
|
|
|
|
end
|
2013-05-06 08:09:26 -04:00
|
|
|
|
|
|
|
factory :deploy_keys_project do
|
|
|
|
deploy_key
|
|
|
|
project
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|