Skip to content

Commit

Permalink
session-stores/cookie: Inline _warn() method
Browse files Browse the repository at this point in the history
`warn(...arguments)` unfortunately can't be used like this at the moment since `...arguments` won't be transpiled properly.

see ember-cli/babel-plugin-debug-macros#47
  • Loading branch information
Turbo87 committed Dec 24, 2017
1 parent f161085 commit 36c78a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions addon/session-stores/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default BaseStore.extend({
if (isNone(value)) {
this.get('_cookies').clear(`${this.get('cookieName')}-expiration_time`);
} else if (value < 90) {
this._warn('The recommended minimum value for `cookieExpirationTime` is 90 seconds. If your value is less than that, the cookie may expire before its expiration time is extended (expiration time is extended every 60 seconds).', false, { id: 'ember-simple-auth.cookieExpirationTime' });
warn('The recommended minimum value for `cookieExpirationTime` is 90 seconds. If your value is less than that, the cookie may expire before its expiration time is extended (expiration time is extended every 60 seconds).', false, { id: 'ember-simple-auth.cookieExpirationTime' });
}
}),

Expand Down Expand Up @@ -293,8 +293,4 @@ export default BaseStore.extend({
this._write(data, expiration);
}
},

_warn() {
warn(...arguments);
}
});
6 changes: 3 additions & 3 deletions tests/unit/session-stores/shared/cookie-store-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ export default function(options) {

describe('#persist', function() {
beforeEach(function() {
sinon.spy(CookieSessionStore.prototype, '_warn');
sinon.spy(Ember, 'warn');
});

afterEach(function() {
CookieSessionStore.prototype._warn.restore();
Ember.warn.restore();
});

it('respects the configured cookieName', function() {
Expand Down Expand Up @@ -103,7 +103,7 @@ export default function(options) {
cookieExpirationTime: 60
});

expect(CookieSessionStore.prototype._warn).to.have.been.calledWith('The recommended minimum value for `cookieExpirationTime` is 90 seconds. If your value is less than that, the cookie may expire before its expiration time is extended (expiration time is extended every 60 seconds).');
expect(Ember.warn).to.have.been.calledWith('The recommended minimum value for `cookieExpirationTime` is 90 seconds. If your value is less than that, the cookie may expire before its expiration time is extended (expiration time is extended every 60 seconds).');

done();
});
Expand Down

0 comments on commit 36c78a7

Please sign in to comment.