Skip to content

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

have a specific method to check if a factory default value is overridden

ulferts76e4d215fb08
diff --git a/lib/open_project/patches/factory_bot_evaluator.rb b/lib/open_project/patches/factory_bot_evaluator.rb
index 13dbc07438f..37e0d89f421 100644
--- a/lib/open_project/patches/factory_bot_evaluator.rb
+++ b/lib/open_project/patches/factory_bot_evaluator.rb
@@ -28,7 +28,9 @@
module OpenProject::Patches
module FactoryBotEvaluator
- attr_reader :overrides
+ def overrides?(key)
+ @overrides.key?(key)
+ end
end
end
diff --git a/spec/factories/notification_factory.rb b/spec/factories/notification_factory.rb
index b942d6c7279..effe7c75b19 100644
--- a/spec/factories/notification_factory.rb
+++ b/spec/factories/notification_factory.rb
@@ -17,8 +17,8 @@ FactoryBot.define do
# * it is not a date alert
# * the values haven't been overridden (including setting them to nil).
unless notification.reason_date_alert_due_date? || notification.reason_date_alert_start_date?
- notification.journal ||= notification.resource.journals.last unless evaluator.overrides.key?(:journal)
- notification.actor ||= notification.journal.try(:user) unless evaluator.overrides.key?(:actor)
+ notification.journal ||= notification.resource.journals.last unless evaluator.overrides?(:journal)
+ notification.actor ||= notification.journal.try(:user) unless evaluator.overrides?(:actor)
end
end
end
diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rb
index 6cd50c18a3d..2086b4c12e7 100644
--- a/spec/factories/work_package_factory.rb
+++ b/spec/factories/work_package_factory.rb
@@ -73,8 +73,8 @@ FactoryBot.define do
end
end
- callback(:after_stub) do |wp, arguments|
- unless wp.type_id || arguments.instance_variable_get(:@overrides).has_key?(:type) || wp.project.nil?
+ callback(:after_stub) do |wp, evaluator|
+ unless wp.type_id || evaluator.overrides?(:type) || wp.project.nil?
wp.type = wp.project.types.first
end
end