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
|
2015-05-20 19:22:00 -04:00
|
|
|
FFaker::Lorem.sentence
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
|
|
|
|
2014-12-12 08:55:06 -05:00
|
|
|
sequence :name do
|
2015-05-20 19:22:00 -04:00
|
|
|
FFaker::Name.name
|
2012-08-29 11:36:02 -04:00
|
|
|
end
|
|
|
|
|
2014-12-12 08:55:06 -05:00
|
|
|
sequence :file_name do
|
2015-05-20 19:22:00 -04:00
|
|
|
FFaker::Internet.user_name
|
2014-12-12 08:55:06 -05:00
|
|
|
end
|
|
|
|
|
2015-05-20 19:22:00 -04:00
|
|
|
sequence(:url) { FFaker::Internet.uri('http') }
|
2012-08-28 01:42:28 -04:00
|
|
|
|
2013-01-02 12:00:00 -05:00
|
|
|
factory :user, aliases: [:author, :assignee, :owner, :creator] do
|
2015-05-20 19:22:00 -04:00
|
|
|
email { FFaker::Internet.email }
|
2012-08-29 11:36:02 -04:00
|
|
|
name
|
2015-05-20 19:22:00 -04:00
|
|
|
sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" }
|
2013-11-25 13:07:55 -05:00
|
|
|
password "12345678"
|
2013-10-17 03:52:38 -04:00
|
|
|
confirmed_at { Time.now }
|
2014-12-12 08:55:06 -05:00
|
|
|
confirmation_token { nil }
|
2014-08-18 18:23:02 -04:00
|
|
|
can_create_group true
|
2012-08-28 01:42:28 -04:00
|
|
|
|
|
|
|
trait :admin do
|
|
|
|
admin true
|
|
|
|
end
|
|
|
|
|
2015-05-09 15:46:18 -04:00
|
|
|
trait :two_factor do
|
|
|
|
before(:create) do |user|
|
2015-06-19 14:59:42 -04:00
|
|
|
user.two_factor_enabled = true
|
2015-05-23 18:47:53 -04:00
|
|
|
user.otp_secret = User.generate_otp_secret(32)
|
2015-05-09 15:46:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-11-27 06:34:39 -05:00
|
|
|
factory :omniauth_user do
|
|
|
|
ignore do
|
|
|
|
extern_uid '123456'
|
|
|
|
provider 'ldapmain'
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |user, evaluator|
|
|
|
|
user.identities << create(:identity,
|
|
|
|
provider: evaluator.provider,
|
|
|
|
extern_uid: evaluator.extern_uid
|
|
|
|
)
|
|
|
|
end
|
2014-10-13 11:33:44 -04:00
|
|
|
end
|
|
|
|
|
2012-08-28 01:42:28 -04:00
|
|
|
factory :admin, traits: [:admin]
|
|
|
|
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-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
|
|
|
|
|
2014-09-15 03:57:02 -04:00
|
|
|
factory :project_member do
|
2012-08-28 01:42:28 -04:00
|
|
|
user
|
|
|
|
project
|
2014-09-15 03:57:02 -04:00
|
|
|
access_level { ProjectMember::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 :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
|
|
|
|
2014-02-11 13:15:13 -05:00
|
|
|
factory :another_key do
|
|
|
|
key do
|
|
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ"
|
|
|
|
end
|
2015-04-03 06:51:01 -04:00
|
|
|
|
|
|
|
factory :another_deploy_key, class: 'DeployKey' do
|
|
|
|
end
|
2014-02-11 13:15:13 -05:00
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|
2014-06-30 07:02:52 -04:00
|
|
|
|
2014-02-08 22:08:49 -05:00
|
|
|
factory :email do
|
|
|
|
user
|
|
|
|
email do
|
2015-05-20 19:22:00 -04:00
|
|
|
FFaker::Internet.email('alias')
|
2014-02-08 22:08:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :another_email do
|
|
|
|
email do
|
2015-05-20 19:22:00 -04:00
|
|
|
FFaker::Internet.email('another.alias')
|
2014-02-08 22:08:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
|
|
|
|
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"
|
|
|
|
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
|
2014-11-27 06:34:39 -05:00
|
|
|
|
|
|
|
factory :identity do
|
|
|
|
provider 'ldapmain'
|
|
|
|
extern_uid 'my-ldap-id'
|
|
|
|
end
|
2012-08-28 01:42:28 -04:00
|
|
|
end
|