mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 12:13:58 -06:00
DEV: prevents route action to crash in tests (#28409)
`routeAction` is testing at runtime that a route exists when in debug mode. However in the case of components tested in isolation there's no existing route which was causing an exception, this commit prevents this check in this case as it's irrelevant.
This commit is contained in:
parent
2f8dc64caf
commit
ea8516b38d
@ -5,6 +5,7 @@ import { assert, runInDebug } from "@ember/debug";
|
||||
import { computed, get } from "@ember/object";
|
||||
import { getOwner } from "@ember/owner";
|
||||
import { join } from "@ember/runloop";
|
||||
import { isTesting } from "discourse-common/config/environment";
|
||||
|
||||
function getCurrentRouteInfos(router) {
|
||||
let routerLib = router._routerMicrolib || router.router;
|
||||
@ -30,6 +31,7 @@ function getRouteWithAction(router, actionName) {
|
||||
function routeAction(actionName, router, ...params) {
|
||||
assert("[ember-route-action-helper] Unable to lookup router", router);
|
||||
|
||||
if (!isTesting() || router.currentRoute) {
|
||||
runInDebug(() => {
|
||||
let { handler } = getRouteWithAction(router, actionName);
|
||||
assert(
|
||||
@ -37,6 +39,7 @@ function routeAction(actionName, router, ...params) {
|
||||
handler
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return function (...invocationArgs) {
|
||||
let { action, handler } = getRouteWithAction(router, actionName);
|
||||
|
Loading…
Reference in New Issue
Block a user