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

Fix failing QuotingTest#test_quoted_time_utc #32284

Merged

Conversation

bogdanvlviv
Copy link
Contributor

@bogdanvlviv bogdanvlviv commented Mar 18, 2018

This test fails in specific time.
Example:

f run this test on the machine with time 01:00 am UTC+2,
this test will fail.
Changing representing of 2000-01-01 01:00 am UTC+2 to UTC+0 change
the day, month and even year in our case,
so substitution "2000-01-01 " to "" isn't possible.

Failure:
ActiveRecord::ConnectionAdapters::QuotingTest#test_quoted_time_utc
Expected: "1999-12-31 23:01:27"
  Actual: "23:01:27"

Related to 7c479cb
r? @pixeltrix

@@ -72,7 +72,7 @@ def test_quoted_time_utc
t = Time.now.change(usec: 0)

expected = t.change(year: 2000, month: 1, day: 1)
expected = expected.getutc.to_s(:db).sub("2000-01-01 ", "")
expected = expected.getutc.to_s(:db).sub(/\A\d\d\d\d-\d\d-\d\d /, "")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change it to this:

expected = t.getutc.change(year: 2000, month: 1, day: 1)
expected = expected.to_s(:db).sub("2000-01-01 ", "")

It makes the expected value less permissive and the reduces the chance of it passing when it should fail - thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pixeltrix Fixed. Thanks for the clarifying this.

This test fails in specific time.
Example:

If run this test on the machine with time 01:00 am UTC+2,
this test will fail.
Changing representing of 2000-01-01 01:00 am UTC+2 to UTC+0 change
the day, month and even year in our case,
so substitution `"2000-01-01 "` to `""` isn't possible.

```
Failure:
ActiveRecord::ConnectionAdapters::QuotingTest#test_quoted_time_utc
Expected: "1999-12-31 23:01:27"
  Actual: "23:01:27"
```

Related to 7c479cb
@bogdanvlviv bogdanvlviv force-pushed the fix-failing-test-test_quoted_time_utc branch from c05f04a to 7daa6f4 Compare March 19, 2018 05:41
@pixeltrix pixeltrix merged commit 91cdb5a into rails:master Mar 19, 2018
@bogdanvlviv bogdanvlviv deleted the fix-failing-test-test_quoted_time_utc branch March 19, 2018 10:19
@pixeltrix
Copy link
Contributor

@bogdanvlviv thanks! I've backported to all 5.x branches.

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.

None yet

2 participants