Skip to content

Commit 346feef

Browse files
authored
MONGOID-5433 Replace calls of Time#to_s(format) with Time#to_formatted_s (#5406)
1 parent 8cf67ea commit 346feef

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/mongoid/cacheable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Cacheable
1515
# plural model name.
1616
#
1717
# If new_record? - will append /new
18-
# If not - will append /id-updated_at.to_s(cache_timestamp_format)
18+
# If not - will append /id-updated_at.to_formatted_s(cache_timestamp_format)
1919
# Without updated_at - will append /id
2020
#
2121
# This is usually called inside a cache() block
@@ -26,7 +26,7 @@ module Cacheable
2626
# @return [ String ] the string with or without updated_at
2727
def cache_key
2828
return "#{model_key}/new" if new_record?
29-
return "#{model_key}/#{_id}-#{updated_at.utc.to_s(cache_timestamp_format)}" if do_or_do_not(:updated_at)
29+
return "#{model_key}/#{_id}-#{updated_at.utc.to_formatted_s(cache_timestamp_format)}" if do_or_do_not(:updated_at)
3030
"#{model_key}/#{_id}"
3131
end
3232
end

spec/mongoid/cacheable_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
context "with the default cache_timestamp_format" do
4646

4747
let!(:updated_at) do
48-
document.updated_at.utc.to_s(:nsec)
48+
document.updated_at.utc.to_formatted_s(:nsec)
4949
end
5050

5151
it "has the id and updated_at key name" do
@@ -64,7 +64,7 @@
6464
end
6565

6666
let!(:updated_at) do
67-
document.updated_at.utc.to_s(:number)
67+
document.updated_at.utc.to_formatted_s(:number)
6868
end
6969

7070
it "has the id and updated_at key name" do
@@ -103,7 +103,7 @@
103103
end
104104

105105
let!(:updated_at) do
106-
agent.updated_at.utc.to_s(:nsec)
106+
agent.updated_at.utc.to_formatted_s(:nsec)
107107
end
108108

109109
it "has the id and updated_at key name" do

0 commit comments

Comments
 (0)