openproject
openproject copied to clipboard
Fix and refactor acts as favorable and acts as watchable
Fixed:
Favorable::Registrywas copied without changing the module inside fromWatchableand method name from"acts_as_watchable"- Registries were using
Watchableto check that only models that haveacts_as_watchablecalled in them were allowed, butWatchableis included inApplicationRecord, soWatchable::InstanceMethodsshould be used instead. Also theacts_as_watchablewas 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
RoutestoRouteConstraintfor clarity - Extract all methods from registries to
RegistryMethods