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 dbfb463
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 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);
}
});
9 changes: 5 additions & 4 deletions tests/unit/session-stores/shared/cookie-store-behavior.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Ember from 'ember';
import { next, run } from '@ember/runloop';
import {
describe,
Expand All @@ -8,7 +9,6 @@ import {
import { expect } from 'chai';
import sinon from 'sinon';
import FakeCookieService from '../../../helpers/fake-cookie-service';
import CookieSessionStore from 'ember-simple-auth/session-stores/cookie';

export default function(options) {
let store;
Expand Down Expand Up @@ -39,11 +39,12 @@ export default function(options) {

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

afterEach(function() {
CookieSessionStore.prototype._warn.restore();
// eslint-disable-next-line ember/local-modules
Ember.warn.restore();
});

it('respects the configured cookieName', function() {
Expand Down Expand Up @@ -103,7 +104,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 dbfb463

Please sign in to comment.