fix build list factory

same as https://github.com/warpc/rosa-build/pull/799/files#diff-26
This commit is contained in:
Alexander Machehin 2013-01-09 16:23:34 +06:00
parent 71125eac81
commit 508ec266f0
1 changed files with 12 additions and 4 deletions

View File

@ -4,7 +4,11 @@ FactoryGirl.define do
association :user association :user
#association :project #association :project
association :save_to_platform, :factory => :platform_with_repos association :save_to_platform, :factory => :platform_with_repos
project { |bl| FactoryGirl.create(:project_with_commit, :repositories => [bl.save_to_platform.repositories.first]) } project { |bl|
pr = FactoryGirl.create(:project_with_commit)
bl.save_to_platform.repositories.first.projects << pr
pr
}
association :arch association :arch
build_for_platform {|bl| bl.save_to_platform} build_for_platform {|bl| bl.save_to_platform}
save_to_repository {|bl| bl.save_to_platform.repositories.first} save_to_repository {|bl| bl.save_to_platform.repositories.first}
@ -16,7 +20,7 @@ FactoryGirl.define do
factory :build_list_with_attaching_project, :parent => :build_list do factory :build_list_with_attaching_project, :parent => :build_list do
before(:create) { |bl| attach_project_to_build_list bl } before(:create) { |bl| attach_project_to_build_list bl }
end end
factory :build_list_core, :parent => :build_list do factory :build_list_core, :parent => :build_list do
bs_id { FactoryGirl.generate(:integer) } bs_id { FactoryGirl.generate(:integer) }
@ -27,7 +31,11 @@ FactoryGirl.define do
end end
factory :build_list_by_group_project, :parent => :build_list_core do factory :build_list_by_group_project, :parent => :build_list_core do
project { |bl| FactoryGirl.create(:group_project_with_commit, :repositories => [bl.save_to_platform.repositories.first]) } project { |bl|
pr = FactoryGirl.create(:group_project_with_commit)
bl.save_to_platform.repositories.first.projects << pr
pr
}
end end
factory :build_list_package, :class => BuildList::Package do factory :build_list_package, :class => BuildList::Package do
@ -45,4 +53,4 @@ end
def attach_project_to_build_list(bl) def attach_project_to_build_list(bl)
bl.save_to_platform ||= FactoryGirl.create(:platform_with_repos) bl.save_to_platform ||= FactoryGirl.create(:platform_with_repos)
bl.project.repositories << bl.save_to_platform.repositories.first bl.project.repositories << bl.save_to_platform.repositories.first
end end