auth-deny-test.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Ember from 'ember';
  2. import { module, test } from 'qunit';
  3. import startApp from '../helpers/start-app';
  4. var application, container, service;
  5. module('Acceptance: Auth denyAuthenticated and denyAnonymous tests', {
  6. beforeEach: function() {
  7. application = startApp();
  8. container = application.__container__;
  9. service = container.lookup('service:auth');
  10. },
  11. afterEach: function() {
  12. Ember.run(application, 'destroy');
  13. }
  14. });
  15. test('guest can access protected route', function(assert) {
  16. assert.expect(1);
  17. visit('/forgotten-password');
  18. andThen(function() {
  19. assert.equal(currentPath(), 'forgotten-password.index');
  20. });
  21. });
  22. test('authenticated is denied access to protected route', function(assert) {
  23. assert.expect(2);
  24. service.set('isAuthenticated', true);
  25. visit('/forgotten-password');
  26. andThen(function() {
  27. assert.equal(currentPath(), 'error-403');
  28. var errorMessage = Ember.$.trim(find('.error-message .lead').text());
  29. assert.equal(errorMessage, 'Only guests can change forgotten password.');
  30. });
  31. });