-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear cached time when setting expiration to null #1463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; I guess the error is most likely caused by something in the tests not being set up correctly (as the property function now needs the cookies service while it previously didn't).
addon/session-stores/cookie.js
Outdated
if (value < 90) { | ||
// When nulling expiry time on purpose, we need to clear the cached value. | ||
// Otherwise, `_calculateExpirationTime` will reuse it. | ||
if (this.get('_cookies') && value === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for this.get('_cookies')
should not actually be necessary.
addon/session-stores/cookie.js
Outdated
this.get('_cookies').clear(`${this.get('cookieName')}-expiration_time`); | ||
} | ||
|
||
if (value < 90 && value !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd make this an else if
for clarity.
The cookie service is called during init so we need to set the container in tests before that. How do we do that? |
This creates a cookie store that has the |
I'm unable to run fastboot tests locally, even on
|
Yeah, I can reproduce the FastBoot tests error - I'll fix that. |
Hm, I cannot reproduce this anymore now - both
as well as
work for me. Can you check whether |
I still have the error, even on a fresh clone. I'm on node |
Hm, that's very strange. What's your global ember-cli version? |
2.16.2 |
I get this though, if I run
Test results will be the same. |
Did you clean your |
I can run the tests with node 8 and npm 4, so I think there's an issue with npm 5. |
ba95782
to
cb493e3
Compare
Hm, ok - as that's almost certainly not an issue with ESA let's ignore it for now as you can run the tests now. |
addon/session-stores/cookie.js
Outdated
// When nulling expiry time on purpose, we need to clear the cached value. | ||
// Otherwise, `_calculateExpirationTime` will reuse it. | ||
if (value === null) { | ||
this.get('_cookies').clear(`${this.get('cookieName')}-expiration_time`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcoow I don't know why this is causing
1) Graceful regression tests does not error when using the adaptive store:
AssertionError: expected undefined to deeply equal [ Array(1) ]
which asserts
expect(response.headers['set-cookie']).to.deep.equal(['ember_simple_auth-session=%7B%22authenticated%22%3A%7B%7D%7D; path=/'])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try reproducing this outside of the tests - run ember s
and have a look at the response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good - the failing FastBoot test seems strange though…
addon/session-stores/cookie.js
Outdated
if (value < 90) { | ||
// When nulling expiry time on purpose, we need to clear the cached value. | ||
// Otherwise, `_calculateExpirationTime` will reuse it. | ||
if (value === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use isNone
here.
The failing FastBoot test is due to the store creation logic being pretty broken - in particular with the adaptive store that the graceful regression test uses. I tried to do a quick "fix" but that should all be properly refactored. I'll do that in a separate PR. |
@@ -26,7 +25,7 @@ describe('AdaptiveStore', () => { | |||
beforeEach(function() { | |||
store = Adaptive.extend({ | |||
_createStore(storeType, options) { | |||
return this._super(storeType, assign(options, { _isFastBoot: false })); | |||
return LocalStorage.create({ _isFastBoot: false }, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all very bad of course but will be fixed in #1490
@marcoow the issue is that
calculateExpirationTime
always uses the cached expiration time if there is one.I've decided to clear the cache when user nulls expiration time, however we get
Error: Assertion Failed: Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.
. Thoughts?#854