summaryrefslogtreecommitdiff
path: root/spec/factories.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-22 21:03:52 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-22 21:03:52 +0200
commitc227aa44f9c54dd88f2ac8de7a3463a23f516dff (patch)
treeb274b673f3274e11db9aa2b7f1ca5b5a967a9fe8 /spec/factories.rb
parent4b3afe2325e063943bdec123154a576f6a300bce (diff)
downloadgitlab-ce-c227aa44f9c54dd88f2ac8de7a3463a23f516dff.tar.gz
Make changes to tests
* project_with_code -> project * project -> ermpty_project Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/factories.rb')
-rw-r--r--spec/factories.rb57
1 files changed, 11 insertions, 46 deletions
diff --git a/spec/factories.rb b/spec/factories.rb
index daf84173648..bf74063a30d 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -27,43 +27,16 @@ FactoryGirl.define do
factory :admin, traits: [:admin]
end
- factory :project do
+ factory :empty_project, class: 'Project' do
sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') }
namespace
creator
-
- trait :source do
- sequence(:name) { |n| "source project#{n}" }
- end
- trait :target do
- sequence(:name) { |n| "target project#{n}" }
- end
-
- factory :source_project, traits: [:source]
- factory :target_project, traits: [:target]
end
-
- factory :redmine_project, parent: :project do
- issues_tracker { "redmine" }
- issues_tracker_id { "project_name_in_redmine" }
- end
-
- factory :project_with_code, parent: :project do
+ factory :project, parent: :empty_project do
path { 'gitlabhq' }
- trait :source_path do
- path { 'source_gitlabhq' }
- end
-
- trait :target_path do
- path { 'target_gitlabhq' }
- end
-
- factory :source_project_with_code, traits: [:source, :source_path]
- factory :target_project_with_code, traits: [:target, :target_path]
-
after :create do |project|
TestEnv.clear_repo_dir(project.namespace, project.path)
TestEnv.reset_satellite_dir
@@ -71,6 +44,11 @@ FactoryGirl.define do
end
end
+ factory :redmine_project, parent: :project do
+ issues_tracker { "redmine" }
+ issues_tracker_id { "project_name_in_redmine" }
+ end
+
factory :group do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
@@ -109,25 +87,12 @@ FactoryGirl.define do
factory :merge_request do
title
author
- source_project factory: :source_project_with_code
- target_project factory: :target_project_with_code
+ source_project factory: :project
+ target_project { source_project }
source_branch "master"
target_branch "stable"
- # pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d)
trait :with_diffs do
- target_branch "master" # pretend bcf03b5d~3
- source_branch "stable" # pretend bcf03b5d
- st_commits do
- [
- source_project.repository.commit('bcf03b5d').to_hash,
- source_project.repository.commit('bcf03b5d~1').to_hash,
- source_project.repository.commit('bcf03b5d~2').to_hash
- ]
- end
- st_diffs do
- source_project.repo.diff("bcf03b5d~3", "bcf03b5d")
- end
end
trait :closed do
@@ -156,7 +121,7 @@ FactoryGirl.define do
factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment]
trait :on_commit do
- project factory: :project_with_code
+ project factory: :project
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit"
end
@@ -166,7 +131,7 @@ FactoryGirl.define do
end
trait :on_merge_request do
- project factory: :project_with_code
+ project factory: :project
noteable_id 1
noteable_type "MergeRequest"
end