diff options
Diffstat (limited to 'spec/factories')
37 files changed, 243 insertions, 28 deletions
diff --git a/spec/factories/abuse_reports.rb b/spec/factories/abuse_reports.rb index 8d287ded292..d0e8c778518 100644 --- a/spec/factories/abuse_reports.rb +++ b/spec/factories/abuse_reports.rb @@ -10,8 +10,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :abuse_report do reporter factory: :user diff --git a/spec/factories/broadcast_messages.rb b/spec/factories/broadcast_messages.rb index 978a7d4cecb..373ca75467e 100644 --- a/spec/factories/broadcast_messages.rb +++ b/spec/factories/broadcast_messages.rb @@ -12,8 +12,6 @@ # font :string(255) # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :broadcast_message do message "MyText" diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index a7a54d44521..cd49e559b7d 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -1,3 +1,5 @@ +include ActionDispatch::TestProcess + FactoryGirl.define do factory :ci_build, class: Ci::Build do name 'test' diff --git a/spec/factories/ci/commits.rb b/spec/factories/ci/commits.rb index b42cafa518a..645cd7ae766 100644 --- a/spec/factories/ci/commits.rb +++ b/spec/factories/ci/commits.rb @@ -16,7 +16,6 @@ # gl_project_id :integer # -# Read about factories at https://github.com/thoughtbot/factory_girl FactoryGirl.define do factory :ci_empty_commit, class: Ci::Commit do sha '97de212e80737a608d939f648d959671fb0a0142' diff --git a/spec/factories/ci/runner_projects.rb b/spec/factories/ci/runner_projects.rb index 008d1c5d961..83fccad679f 100644 --- a/spec/factories/ci/runner_projects.rb +++ b/spec/factories/ci/runner_projects.rb @@ -9,8 +9,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :ci_runner_project, class: Ci::RunnerProject do runner_id 1 diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb index 265663e8453..5b645fab32e 100644 --- a/spec/factories/ci/runners.rb +++ b/spec/factories/ci/runners.rb @@ -17,8 +17,6 @@ # architecture :string(255) # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :ci_runner, class: Ci::Runner do sequence :description do |n| diff --git a/spec/factories/ci/trigger_requests.rb b/spec/factories/ci/trigger_requests.rb index 2c0d004d267..6d47d05f8ad 100644 --- a/spec/factories/ci/trigger_requests.rb +++ b/spec/factories/ci/trigger_requests.rb @@ -1,5 +1,3 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :ci_trigger_request, class: Ci::TriggerRequest do factory :ci_trigger_request_with_variables do diff --git a/spec/factories/ci/triggers.rb b/spec/factories/ci/triggers.rb index fd3afdb1ec2..a27b04424e5 100644 --- a/spec/factories/ci/triggers.rb +++ b/spec/factories/ci/triggers.rb @@ -1,5 +1,3 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :ci_trigger_without_token, class: Ci::Trigger do factory :ci_trigger do diff --git a/spec/factories/ci/variables.rb b/spec/factories/ci/variables.rb index 8f62d64411b..856a8e725eb 100644 --- a/spec/factories/ci/variables.rb +++ b/spec/factories/ci/variables.rb @@ -12,8 +12,6 @@ # gl_project_id :integer # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :ci_variable, class: Ci::Variable do sequence(:key) { |n| "VARIABLE_#{n}" } diff --git a/spec/factories/deploy_keys_projects.rb b/spec/factories/deploy_keys_projects.rb new file mode 100644 index 00000000000..27cece487bd --- /dev/null +++ b/spec/factories/deploy_keys_projects.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :deploy_keys_project do + deploy_key + project + end +end diff --git a/spec/factories/emails.rb b/spec/factories/emails.rb new file mode 100644 index 00000000000..ed072213153 --- /dev/null +++ b/spec/factories/emails.rb @@ -0,0 +1,14 @@ +FactoryGirl.define do + factory :email do + user + email do + FFaker::Internet.email('alias') + end + + factory :another_email do + email do + FFaker::Internet.email('another.alias') + end + end + end +end diff --git a/spec/factories/events.rb b/spec/factories/events.rb new file mode 100644 index 00000000000..90788f30ac9 --- /dev/null +++ b/spec/factories/events.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :event do + factory :closed_issue_event do + project + action { Event::CLOSED } + target factory: :closed_issue + author factory: :user + end + end +end diff --git a/spec/factories/forked_project_links.rb b/spec/factories/forked_project_links.rb index 906e4106b32..252bf2747e1 100644 --- a/spec/factories/forked_project_links.rb +++ b/spec/factories/forked_project_links.rb @@ -9,8 +9,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :forked_project_link do association :forked_to_project, factory: :project diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb new file mode 100644 index 00000000000..4a3a155d7ff --- /dev/null +++ b/spec/factories/groups.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :group do + sequence(:name) { |n| "group#{n}" } + path { name.downcase.gsub(/\s/, '_') } + type 'Group' + end +end diff --git a/spec/factories/identities.rb b/spec/factories/identities.rb new file mode 100644 index 00000000000..26ef6f18698 --- /dev/null +++ b/spec/factories/identities.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :identity do + provider 'ldapmain' + extern_uid 'my-ldap-id' + end +end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb new file mode 100644 index 00000000000..722095de590 --- /dev/null +++ b/spec/factories/issues.rb @@ -0,0 +1,18 @@ +FactoryGirl.define do + factory :issue do + title + author + project + + trait :closed do + state :closed + end + + trait :reopened do + state :reopened + end + + factory :closed_issue, traits: [:closed] + factory :reopened_issue, traits: [:reopened] + end +end diff --git a/spec/factories/keys.rb b/spec/factories/keys.rb new file mode 100644 index 00000000000..d69c5b38d0a --- /dev/null +++ b/spec/factories/keys.rb @@ -0,0 +1,24 @@ +FactoryGirl.define do + factory :key do + title + key do + "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com" + end + + factory :deploy_key, class: 'DeployKey' do + end + + factory :personal_key do + user + end + + factory :another_key do + key do + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ" + end + + factory :another_deploy_key, class: 'DeployKey' do + end + end + end +end diff --git a/spec/factories/label_links.rb b/spec/factories/label_links.rb index bd304b5db6b..2939d4307c5 100644 --- a/spec/factories/label_links.rb +++ b/spec/factories/label_links.rb @@ -10,8 +10,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :label_link do label diff --git a/spec/factories/labels.rb b/spec/factories/labels.rb index 8b12ee11af5..6e70af10af3 100644 --- a/spec/factories/labels.rb +++ b/spec/factories/labels.rb @@ -11,8 +11,6 @@ # template :boolean default(FALSE) # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :label do title "Bug" diff --git a/spec/factories/lfs_objects.rb b/spec/factories/lfs_objects.rb index 2da107ba24b..327858ce435 100644 --- a/spec/factories/lfs_objects.rb +++ b/spec/factories/lfs_objects.rb @@ -10,7 +10,7 @@ # file :string(255) # -# Read about factories at https://github.com/thoughtbot/factory_girl +include ActionDispatch::TestProcess FactoryGirl.define do factory :lfs_object do diff --git a/spec/factories/lfs_objects_projects.rb b/spec/factories/lfs_objects_projects.rb index 3772236a77a..50b45843c99 100644 --- a/spec/factories/lfs_objects_projects.rb +++ b/spec/factories/lfs_objects_projects.rb @@ -9,8 +9,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :lfs_objects_project do lfs_object diff --git a/spec/factories/milestones.rb b/spec/factories/milestones.rb new file mode 100644 index 00000000000..e9e85962fe4 --- /dev/null +++ b/spec/factories/milestones.rb @@ -0,0 +1,12 @@ +FactoryGirl.define do + factory :milestone do + title + project + + trait :closed do + state :closed + end + + factory :closed_milestone, traits: [:closed] + end +end diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb new file mode 100644 index 00000000000..1b1fc4ce80d --- /dev/null +++ b/spec/factories/namespaces.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :namespace do + sequence(:name) { |n| "namespace#{n}" } + path { name.downcase.gsub(/\s/, '_') } + owner + end +end diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 32c202891d8..e5dcb159014 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -21,6 +21,8 @@ require_relative '../support/repo_helpers' +include ActionDispatch::TestProcess + FactoryGirl.define do factory :note do project diff --git a/spec/factories/personal_snippets.rb b/spec/factories/personal_snippets.rb new file mode 100644 index 00000000000..b493a6968ff --- /dev/null +++ b/spec/factories/personal_snippets.rb @@ -0,0 +1,15 @@ +FactoryGirl.define do + factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do + trait :public do + visibility_level PersonalSnippet::PUBLIC + end + + trait :internal do + visibility_level PersonalSnippet::INTERNAL + end + + trait :private do + visibility_level PersonalSnippet::PRIVATE + end + end +end diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb new file mode 100644 index 00000000000..94dd935a039 --- /dev/null +++ b/spec/factories/project_hooks.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :project_hook do + url { FFaker::Internet.uri('http') } + end +end diff --git a/spec/factories/project_members.rb b/spec/factories/project_members.rb new file mode 100644 index 00000000000..70fb7595c74 --- /dev/null +++ b/spec/factories/project_members.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :project_member do + user + project + access_level { ProjectMember::MASTER } + end +end diff --git a/spec/factories/project_snippets.rb b/spec/factories/project_snippets.rb new file mode 100644 index 00000000000..154442bd3db --- /dev/null +++ b/spec/factories/project_snippets.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :project_snippet do + project + author + title + content + file_name + end +end diff --git a/spec/factories/protected_branches.rb b/spec/factories/protected_branches.rb new file mode 100644 index 00000000000..28ed8078157 --- /dev/null +++ b/spec/factories/protected_branches.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :protected_branch do + name + project + end +end diff --git a/spec/factories/releases.rb b/spec/factories/releases.rb index 43d09b17534..7f331c37256 100644 --- a/spec/factories/releases.rb +++ b/spec/factories/releases.rb @@ -10,8 +10,6 @@ # updated_at :datetime # -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :release do tag "v1.1.0" diff --git a/spec/factories/sent_notifications.rb b/spec/factories/sent_notifications.rb new file mode 100644 index 00000000000..78eb929c6e7 --- /dev/null +++ b/spec/factories/sent_notifications.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :sent_notification do + project + recipient factory: :user + noteable factory: :issue + reply_key "0123456789abcdef" * 2 + end +end diff --git a/spec/factories/service_hooks.rb b/spec/factories/service_hooks.rb new file mode 100644 index 00000000000..6dd6af63f3e --- /dev/null +++ b/spec/factories/service_hooks.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :service_hook do + url { FFaker::Internet.uri('http') } + service + end +end diff --git a/spec/factories/services.rb b/spec/factories/services.rb new file mode 100644 index 00000000000..f7c285cff3a --- /dev/null +++ b/spec/factories/services.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :service do + type "" + title "GitLab CI" + project + end +end diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb new file mode 100644 index 00000000000..b9127b3d75e --- /dev/null +++ b/spec/factories/snippets.rb @@ -0,0 +1,16 @@ +FactoryGirl.define do + sequence :title, aliases: [:content] do + FFaker::Lorem.sentence + end + + sequence :file_name do + FFaker::Internet.user_name + end + + factory :snippet do + author + title + content + file_name + end +end diff --git a/spec/factories/spam_logs.rb b/spec/factories/spam_logs.rb index d90e5d6bf26..a4f6d291269 100644 --- a/spec/factories/spam_logs.rb +++ b/spec/factories/spam_logs.rb @@ -1,5 +1,3 @@ -# Read about factories at https://github.com/thoughtbot/factory_girl - FactoryGirl.define do factory :spam_log do user diff --git a/spec/factories/system_hooks.rb b/spec/factories/system_hooks.rb new file mode 100644 index 00000000000..c786e9cb79b --- /dev/null +++ b/spec/factories/system_hooks.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :system_hook do + url { FFaker::Internet.uri('http') } + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb new file mode 100644 index 00000000000..785c2a3d811 --- /dev/null +++ b/spec/factories/users.rb @@ -0,0 +1,50 @@ +FactoryGirl.define do + sequence(:name) { FFaker::Name.name } + + factory :user, aliases: [:author, :assignee, :recipient, :owner, :creator] do + email { FFaker::Internet.email } + name + sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" } + password "12345678" + confirmed_at { Time.now } + confirmation_token { nil } + can_create_group true + + trait :admin do + admin true + end + + trait :two_factor do + before(:create) do |user| + user.two_factor_enabled = true + user.otp_secret = User.generate_otp_secret(32) + user.otp_grace_period_started_at = Time.now + user.generate_otp_backup_codes! + end + end + + trait :with_avatar do + avatar { fixture_file_upload(Rails.root.join(*%w(spec fixtures dk.png)), 'image/png') } + avatar_crop_x 0 + avatar_crop_y 0 + avatar_crop_size 256 + end + + factory :omniauth_user do + transient 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 + end + + factory :admin, traits: [:admin] + end +end |