From dbfb463f77eae8cb3db84ba947689bf44633a9cd Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 24 Dec 2017 12:52:37 +0100 Subject: [PATCH] session-stores/cookie: Inline `_warn()` method `warn(...arguments)` unfortunately can't be used like this at the moment since `...arguments` won't be transpiled properly. see https://github.com/chadhietala/babel-plugin-debug-macros/issues/47 --- addon/session-stores/cookie.js | 6 +----- .../unit/session-stores/shared/cookie-store-behavior.js | 9 +++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/addon/session-stores/cookie.js b/addon/session-stores/cookie.js index 31f66ad4e..b1415de4b 100644 --- a/addon/session-stores/cookie.js +++ b/addon/session-stores/cookie.js @@ -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' }); } }), @@ -293,8 +293,4 @@ export default BaseStore.extend({ this._write(data, expiration); } }, - - _warn() { - warn(...arguments); - } }); diff --git a/tests/unit/session-stores/shared/cookie-store-behavior.js b/tests/unit/session-stores/shared/cookie-store-behavior.js index 8636c85cb..8761ea9b0 100644 --- a/tests/unit/session-stores/shared/cookie-store-behavior.js +++ b/tests/unit/session-stores/shared/cookie-store-behavior.js @@ -1,3 +1,4 @@ +import Ember from 'ember'; import { next, run } from '@ember/runloop'; import { describe, @@ -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; @@ -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() { @@ -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(); });