Skip to content

Commit fc9ba55

Browse files
committed
add first test
1 parent 16af9f0 commit fc9ba55

5 files changed

Lines changed: 37 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"ember-cli-qunit": "0.0.5",
5353
"ember-cli-simple-auth": "^0.7.2",
5454
"ember-cli-simple-auth-devise": "^0.7.2",
55+
"ember-cli-simple-auth-testing": "^0.7.2",
5556
"ember-export-application-global": "^1.0.0",
5657
"express": "^4.8.5",
5758
"glob": "^4.0.5"

tests/.jshintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"predef": [
3+
"authenticateSession",
4+
"invalidateSession",
35
"document",
46
"window",
57
"location",

tests/acceptance/auth-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Ember from 'ember';
2+
import startApp from '../helpers/start-app';
3+
4+
var application;
5+
6+
module('Acceptance: Auth', {
7+
setup: function() {
8+
application = startApp();
9+
},
10+
teardown: function() {
11+
Ember.run(application, 'destroy');
12+
}
13+
});
14+
15+
test('redirects to /login when I try to see content as not authenticated user', function() {
16+
expect(2);
17+
18+
invalidateSession();
19+
visit('/');
20+
21+
andThen(function() {
22+
equal(currentPath(), 'login');
23+
24+
visit('/users');
25+
26+
andThen(()=>{
27+
equal(currentPath(), 'login');
28+
});
29+
});
30+
});

tests/dummy/config/environment.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ module.exports = function(environment) {
4747
ENV.APP.LOG_VIEW_LOOKUPS = false;
4848

4949
ENV.APP.rootElement = '#ember-testing';
50+
ENV['simple-auth'] = {
51+
store: 'simple-auth-session-store:ephemeral'
52+
}
5053
}
5154

5255
if (environment === 'production') {

tests/helpers/start-app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Ember from 'ember';
22
import Application from '../../app';
33
import Router from '../../router';
44
import config from '../../config/environment';
5+
import 'simple-auth-testing/test-helpers';
56

67
export default function startApp(attrs) {
78
var App;

0 commit comments

Comments
 (0)