Skip to content

Commit

Permalink
Fix incorrect arguments for Time.zone.local
Browse files Browse the repository at this point in the history
These usages were intended for Time.zone.parse and have been changed
accordingly.

In Ruby 3.1.x an error occurs when a String is passed to
Time.zone.local:

irb(main):001:0> Time.zone.local("2017-07-27 16:01:01").utc
/Users/kevin.dew/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.0.2.3/lib/active_support/values/time_zone.rb:355:in `utc': invalid value for Integer(): "2017-07-27 16:01:01" (ArgumentError)

It's worth noting that this didn't actually behave correctly before. The
string argument just seemed to be converted into "2017":

irb(main):001:0> Time.zone.local("2017-07-27 16:01:01")
=> Sun, 01 Jan 2017 00:00:00.000000000 UTC +00:00
  • Loading branch information
kevindew committed Jul 20, 2022
1 parent c1d9b70 commit 8a3389d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/queries/get_expanded_links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

context "when generate is false" do
context "and there are expanded links stored" do
let(:updated_at) { Time.zone.local("2017-07-27 16:01:01").utc }
let(:updated_at) { Time.zone.parse("2017-07-27 16:01:01").utc }
let(:expanded_links) do
{
link_type: { content_id: SecureRandom.uuid },
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/expanded_links_endpoint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.describe "GET /v2/expanded-links/:id", type: :request do
let(:content_id) { SecureRandom.uuid }
let(:updated_at) { Time.zone.local("2017-07-27 16:44:00") }
let(:updated_at) { Time.zone.parse("2017-07-27 16:44:00") }

context "when requested without a locale" do
let(:expanded_links) do
Expand Down

0 comments on commit 8a3389d

Please sign in to comment.