openproject icon indicating copy to clipboard operation
openproject copied to clipboard

Fix and refactor acts as favorable and acts as watchable

Open toy opened this issue 1 year ago • 0 comments

Fixed:

  • Favorable::Registry was copied without changing the module inside from Watchable and method name from "acts_as_watchable"
  • Registries were using Watchable to check that only models that have acts_as_watchable called in them were allowed, but Watchable is included in ApplicationRecord, so Watchable::InstanceMethods should be used instead. Also the acts_as_watchable was registering model before including the module
  • Both registries were storing model classes, so in development new versions of those models were added when reloaded, but the registry still returned the first model class that was registered

Refactored:

  • No need to explicitly call Registry.add(Model) in initialisers, it is enough to just reference models to trigger autoload
  • Renamed Routes to RouteConstraint for clarity
  • Extract all methods from registries to RegistryMethods

toy avatar Jun 26 '24 17:06 toy