Skip to content
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

Serialize updated at without to s #1381

Conversation

briandunn
Copy link
Contributor

The project I'm on has an overridden ::Time::DATE_FORMATS[:default] that does not include the seconds in the serialized time string. This broke batch detection in a way that was very difficult to track down. This PR uses iso8601 To serialize reliably.

@briandunn
Copy link
Contributor Author

@MaicolBen Here is a passing version.

@jeremy-ebler-vineti
Copy link

#to_s is an alias of to_formatted_s, which interacts with Time::DATE_FORMATS and Rails' I18n. It makes sense to explicitly use a standardized format, like iso8601.

@@ -1,12 +1,14 @@
module DeviseTokenAuth::Concerns::TokensSerialization
extend self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

def serialize_updated_at(token)
updated_at_key = ['updated_at', :updated_at].find(&token.method(:[]))

if token[updated_at_key].respond_to?(:iso8601)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can write this better:

return token unless token[updated_at_key].respond_to?(:iso8601)

token.merge updated_at_key => token[updated_at_key].iso8601

@@ -55,16 +57,48 @@
assert_equal(ts.dump({}), '{}')
end

it 'deserialize tokens' do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this spec? are we having breaking changes here?

@@ -34,7 +34,7 @@ end

group :test do
gem "rails-controller-testing"
gem "simplecov", require: false
gem "simplecov", "< 0.18", require: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this change but it's ok

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newer simplecov is incompatible with codeclimate. codeclimate/test-reporter#413

Copy link
Collaborator

@MaicolBen MaicolBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briandunn can you check my comments and rebase?

@MaicolBen
Copy link
Collaborator

I rebased it in #1423

@MaicolBen MaicolBen closed this Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants