You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add regression test: re-binding a singleton to a different path must keep it a singleton (#3516) #3527
#3520 fixed the Injector.map() lifecycle regression (#3516), but no spec pins the exact failure mode. The two existing re-bind tests both re-apply .asSingleton(), so neither would catch the flag being dropped:
"invalidates a cached singleton when the alias is re-bound to a different component path" → re-maps then calls .asSingleton() again
"keeps the cached singleton when the alias is re-registered with the same path (dev-reload pattern)" → same path
The regression was specifically: re-pointing an existing singleton to a different component without re-flagging silently degraded it to transient (map() deleted singletonFlags on the path re-map branch). A test that omits the second .asSingleton() is what pins the fix.
Suggested regression test
Add to vendor/wheels/tests/specs/di/InjectorSpec.cfc (Core API describe):
it("preserves the singleton lifecycle when re-bound to a different path WITHOUT re-flagging (##3516)", () => {
di.map("repointedSingleton").to("wheels.tests._assets.di.SimpleService").asSingleton();
di.getInstance("repointedSingleton");
// Re-point to a DIFFERENT component without re-applying .asSingleton().
// The lifecycle must survive the re-map (the test-double DI-swap pattern).
di.map("repointedSingleton").to("wheels.tests._assets.di.OptionalDependentService");
expect(di.isSingleton("repointedSingleton")).toBeTrue();
var first = di.getInstance("repointedSingleton");
var second = di.getInstance("repointedSingleton");
expect(first).toBe(second);
expect(structKeyExists(first, "hasDependency")).toBeTrue();
});
Fails on the pre-#3520 code (isSingleton() returns false) and passes after #3520.
Activity