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

Raise error when trying to call acts_as_favorable without registering

Oliver Günther5cbd60409eae
diff --git a/lib_static/open_project/acts/favorable.rb b/lib_static/open_project/acts/favorable.rb
index 7c830bd8d11..3a039013a97 100644
--- a/lib_static/open_project/acts/favorable.rb
+++ b/lib_static/open_project/acts/favorable.rb
@@ -48,6 +48,10 @@ module OpenProject
def acts_as_favorable
return if included_modules.include?(::OpenProject::Acts::Favorable::InstanceMethods)
+ unless ::OpenProject::Acts::Favorable::Registry.exists?(self)
+ raise ArgumentError.new("You need to register #{name} to the acts_as_favorable initializer")
+ end
+
class_eval do
has_many :favorites, as: :favored, dependent: :delete_all, validate: false
has_many :favoring_users, through: :favorites, source: :user, validate: false