diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-08-02 15:43:24 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-08-02 15:43:24 -0400 |
commit | e2c3dca371f8dca8814a5924fe8ed271f0ec6399 (patch) | |
tree | ee9d46fb5bf3bee7e9d06b93ac2e3edd13704690 /spec | |
parent | 64d6a48b56f92b0d0f24e1fd2c6369d15e08a8f4 (diff) | |
download | gitlab-ce-e2c3dca371f8dca8814a5924fe8ed271f0ec6399.tar.gz |
Remove `:empty_project` factory, implement `:repository` trait
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/projects.rb | 91 |
1 files changed, 43 insertions, 48 deletions
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index a04befe809a..1c0ed63a37d 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -5,7 +5,7 @@ FactoryGirl.define do # # Project does not have bare repository. # Use this factory if you don't need repository in tests - factory :empty_project, class: 'Project' do + factory :project, class: 'Project' do sequence(:name) { |n| "project#{n}" } path { name.downcase.gsub(/\s/, '_') } namespace @@ -54,8 +54,44 @@ FactoryGirl.define do avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) } end + # Project with test repository + # + # Repository source is at https://gitlab.com/gitlab-org/gitlab-test trait :repository do - # no-op... for now! + path { 'gitlabhq' } + + test_repo + + transient do + create_template nil + end + + after :create do |project, evaluator| + if evaluator.create_template + args = evaluator.create_template + + project.add_user(args[:user], args[:access]) + + project.repository.create_file( + args[:user], + ".gitlab/#{args[:path]}/bug.md", + 'something valid', + message: 'test 3', + branch_name: 'master') + project.repository.create_file( + args[:user], + ".gitlab/#{args[:path]}/template_test.md", + 'template_test', + message: 'test 1', + branch_name: 'master') + project.repository.create_file( + args[:user], + ".gitlab/#{args[:path]}/feature_proposal.md", + 'feature_proposal', + message: 'test 2', + branch_name: 'master') + end + end end trait :empty_repo do @@ -146,59 +182,18 @@ FactoryGirl.define do # # This is a case when you just created a project # but not pushed any code there yet - factory :project_empty_repo, parent: :empty_project do + factory :project_empty_repo, parent: :project do empty_repo end # Project with broken repository # # Project with an invalid repository state - factory :project_broken_repo, parent: :empty_project do + factory :project_broken_repo, parent: :project do broken_repo end - # Project with test repository - # - # Test repository source can be found at - # https://gitlab.com/gitlab-org/gitlab-test - factory :project, parent: :empty_project do - path { 'gitlabhq' } - - test_repo - - transient do - create_template nil - end - - after :create do |project, evaluator| - if evaluator.create_template - args = evaluator.create_template - - project.add_user(args[:user], args[:access]) - - project.repository.create_file( - args[:user], - ".gitlab/#{args[:path]}/bug.md", - 'something valid', - message: 'test 3', - branch_name: 'master') - project.repository.create_file( - args[:user], - ".gitlab/#{args[:path]}/template_test.md", - 'template_test', - message: 'test 1', - branch_name: 'master') - project.repository.create_file( - args[:user], - ".gitlab/#{args[:path]}/feature_proposal.md", - 'feature_proposal', - message: 'test 2', - branch_name: 'master') - end - end - end - - factory :forked_project_with_submodules, parent: :empty_project do + factory :forked_project_with_submodules, parent: :project do path { 'forked-gitlabhq' } after :create do |project| @@ -228,11 +223,11 @@ FactoryGirl.define do jira_service end - factory :kubernetes_project, parent: :empty_project do + factory :kubernetes_project, parent: :project do kubernetes_service end - factory :prometheus_project, parent: :empty_project do + factory :prometheus_project, parent: :project do after :create do |project| project.create_prometheus_service( active: true, |