Refactor #19085
closedTokenTest expiry fails on MySQL with Rails 5.0, it should be removed
Description
Under Rails 5.0, the following test fails when using a MySQL database:
1) Failure: TokenTest#test_0001_a token expires when set to expire [/home/dcleal/code/foreman/foreman/test/models/token_test.rb:12]: --- expected +++ actual @@ -1 +1 @@ -Thu, 30 Mar 2017 08:35:18 UTC +00:00 +2017-03-30 08:35:18 UTC
On MySQL, the default precision of datetime fields is to the second, not nanoseconds (on PostgreSQL and SQlite). The test compares the value of Time.now.utc
to the value of Token#expires, which if the model attribute has been rounded to the second, will not be equal.
This is reproducible on 4.2 by changing the test to persist and reload the Token. It differs on 5.0 as the attribute getter on the unpersisted model immediately returns the rounded value, so the comparison fails.
This can be fixed trivially (using #to_i to compare times), but I think the test should be removed as it's quite worthless - it only tests persistence of the expires attribute through Token.new
. Real testing of token expiry occurs in test/models/host_test.rb.
Updated by The Foreman Bot over 7 years ago
- Status changed from Assigned to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4423 added
Updated by Dominic Cleal over 7 years ago
- Blocks Feature #19050: Add support for running under Ruby on Rails 5.0 added
Updated by The Foreman Bot over 7 years ago
- Pull request https://github.com/theforeman/foreman/pull/4422 added
Updated by Dominic Cleal over 7 years ago
- Pull request deleted (
https://github.com/theforeman/foreman/pull/4422)
Updated by Dominic Cleal over 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 9a785fcef2b417b8fc2299a0cbbac2b24cfed8ff.
Updated by Marek Hulán almost 7 years ago
- Translation missing: en.field_release set to 240