Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require users to provide the initial transition #223

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

bertdeblock
Copy link
Contributor

@bertdeblock bertdeblock commented Nov 22, 2022

The main motivation for this change is the removal of the ember-permissions instance initializer.
The initializer eagerly looks up the permissions service, which in turn eagerly looks up the router service, making it
impossible to stub any of the two in tests.

Before:

import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class ProtectedRoute extends Route {
  @service('permissions') permissionsService;

  beforeModel() {
    this.permissionsService.enableRouteValidation();
  }
}

After:

import Route from '@ember/routing/route';
import { service } from '@ember/service';

export default class ProtectedRoute extends Route {
  @service('permissions') permissionsService;

  beforeModel(transition) {
    this.permissionsService.enableRouteValidation(transition);
  }
}

@bertdeblock bertdeblock added enhancement New feature or request breaking labels Nov 22, 2022
@bertdeblock bertdeblock self-assigned this Nov 22, 2022
@bertdeblock bertdeblock force-pushed the require-users-to-pass-in-the-initial-transition branch from c4de5e2 to 72af063 Compare November 22, 2022 10:36
@bertdeblock bertdeblock force-pushed the require-users-to-pass-in-the-initial-transition branch from 72af063 to ce60cff Compare November 22, 2022 10:41
@bertdeblock bertdeblock merged commit 005c5ca into main Nov 22, 2022
@bertdeblock bertdeblock deleted the require-users-to-pass-in-the-initial-transition branch January 3, 2023 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant