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

simplify check for project association for acts_as_watchable

Ivan Kuchin47ca9772517f
diff --git a/lib_static/open_project/acts/watchable.rb b/lib_static/open_project/acts/watchable.rb
index ab277fbf301..1858d388b11 100644
--- a/lib_static/open_project/acts/watchable.rb
+++ b/lib_static/open_project/acts/watchable.rb
@@ -76,19 +76,17 @@ module OpenProject
end
def acts_as_watchable_enforce_project_association
- unless reflect_on_association(:project)
- message = <<-MESSAGE
+ return if reflect_on_association(:project)
- The #{self} model does not have an association to the Project model.
+ raise <<-MESSAGE
+ The #{self} model does not have an association to the Project model.
- acts_as_watchable requires the including model to have such an association.
+ acts_as_watchable requires the including model to have such an association.
- If no direct association exists, consider adding a
- has_one :project, through: ...
- association.
- MESSAGE
- raise message
- end
+ If no direct association exists, consider adding a
+ has_one :project, through: ...
+ association.
+ MESSAGE
end
end