OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
simplify work_package factory
Christophe Bliarde1607a61161b
diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rbindex e56eef11802..a7e5e8935c4 100644--- a/spec/factories/work_package_factory.rb+++ b/spec/factories/work_package_factory.rb@@ -27,17 +27,19 @@#++FactoryBot.define do- factory :abstract_work_package_factory, class: 'WorkPackage' do+ factory :work_package dotransient docustom_values { nil }- abstract_factory { raise "You can't instantiate this abstract factory." }endpriority+ project factory: :project_with_typesstatussequence(:subject) { |n| "WorkPackage No. #{n}" }description { |i| "Description for '#{i.subject}'" }author factory: :user+ created_at { Time.zone.now }+ updated_at { Time.zone.now }duration doif start_date && due_datedue_date - start_date + 1@@ -46,46 +48,26 @@ FactoryBot.define doendend- after(:build) do |_, evaluator|- evaluator.abstract_factory- end-- after(:stub) do |_, evaluator|- evaluator.abstract_factory- end-- factory :work_package do- transient do- abstract_factory { false }- end-- project factory: :project_with_types+ callback(:after_build) do |work_package, evaluator|+ work_package.type = work_package.project.types.first unless work_package.type- callback(:after_build) do |work_package, evaluator|- work_package.type = work_package.project.types.first unless work_package.type+ custom_values = evaluator.custom_values || {}- custom_values = evaluator.custom_values || {}-- if custom_values.is_a? Hash- custom_values.each_pair do |custom_field_id, value|- work_package.custom_values.build custom_field_id:, value:- end- else- custom_values.each { |cv| work_package.custom_values << cv }+ if custom_values.is_a? Hash+ custom_values.each_pair do |custom_field_id, value|+ work_package.custom_values.build custom_field_id:, value:end+ else+ custom_values.each { |cv| work_package.custom_values << cv }endend- factory :stubbed_work_package, parent: :abstract_work_package_factory do- transient do- abstract_factory { false }- end-- project { build_stubbed(:project_with_types) }+ callback(:after_stub) do |wp, arguments|+ wp.type = wp.project.types.first unless wp.type_id || arguments.instance_variable_get(:@overrides).has_key?(:type)+ end- callback(:after_stub) do |wp, arguments|- wp.type = wp.project.types.first unless wp.type_id || arguments.instance_variable_get(:@overrides).has_key?(:type)- end+ factory :stubbed_work_package do+ "this factory is not necessary anymore and should be removed"endendend