-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: explicitly lookup session and store services
- Loading branch information
1 parent
1cca7aa
commit b8fd72f
Showing
11 changed files
with
74 additions
and
79 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
packages/ember-simple-auth/addon/initializers/setup-session-service.js
This file was deleted.
Oops, something went wrong.
7 changes: 1 addition & 6 deletions
7
packages/ember-simple-auth/addon/initializers/setup-session.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
import Ember from 'ember'; | ||
import InternalSession from '../internal-session'; | ||
import Ephemeral from '../session-stores/ephemeral'; | ||
import inject from '../utils/inject'; | ||
|
||
export default function setupSession(registry) { | ||
registry.register('session:main', InternalSession); | ||
|
||
let store = 'session-store:application'; | ||
if (Ember.testing) { | ||
store = 'session-store:test'; | ||
registry.register(store, Ephemeral); | ||
registry.register('session-store:test', Ephemeral); | ||
} | ||
|
||
inject(registry, 'session:main', 'store', store); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
packages/ember-simple-auth/tests/unit/initializers/setup-session-service-test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/ember-simple-auth/tests/unit/internal-session-store-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Ember from 'ember'; | ||
import { describe, beforeEach, it } from 'mocha'; | ||
import { setupTest } from 'ember-mocha'; | ||
import { expect } from 'chai'; | ||
import sinonjs from 'sinon'; | ||
import InternalSession from 'ember-simple-auth/internal-session'; | ||
import EphemeralStore from 'ember-simple-auth/session-stores/ephemeral'; | ||
|
||
describe('InternalSession store injection', () => { | ||
setupTest(); | ||
|
||
let sinon; | ||
let session; | ||
|
||
beforeEach(function() { | ||
sinon = sinonjs.createSandbox(); | ||
}); | ||
|
||
afterEach(function() { | ||
sinon.restore(); | ||
}); | ||
|
||
describe('session store injection', function () { | ||
afterEach(function () { | ||
Ember.testing = true; | ||
}); | ||
|
||
it('looks up the test session store when Ember.testing true', function() { | ||
Ember.testing = true; | ||
|
||
this.owner.register('session-store:test', EphemeralStore); | ||
session = InternalSession.create(this.owner.ownerInjection()); | ||
|
||
expect(session.get('store')).to.eql(this.owner.lookup('session-store:test')); | ||
}); | ||
|
||
it('looks up the application session store when Ember.testing false', function() { | ||
Ember.testing = false; | ||
sinon = sinonjs.createSandbox(); | ||
|
||
this.owner.register('session-store:test', EphemeralStore); | ||
session = InternalSession.create(this.owner.ownerInjection()); | ||
|
||
expect(session.get('store')).to.eql(this.owner.lookup('session-store:application')); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters