]> git.openstreetmap.org Git - rails.git/commitdiff
Fix rubocop Rails/TimeZone warnings
authorTom Hughes <tom@compton.nu>
Tue, 1 Mar 2022 22:55:10 +0000 (22:55 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 1 Mar 2022 22:55:10 +0000 (22:55 +0000)
48 files changed:
.rubocop_todo.yml
app/controllers/api/changesets_controller.rb
app/controllers/api/notes_controller.rb
app/controllers/api/traces_controller.rb
app/controllers/friendships_controller.rb
app/controllers/messages_controller.rb
app/controllers/traces_controller.rb
app/controllers/user_blocks_controller.rb
app/controllers/users_controller.rb
app/helpers/changesets_helper.rb
app/helpers/user_blocks_helper.rb
app/models/access_token.rb
app/models/changeset.rb
app/models/issue.rb
app/models/node.rb
app/models/note.rb
app/models/oauth2_verifier.rb
app/models/oauth_token.rb
app/models/relation.rb
app/models/request_token.rb
app/models/user_block.rb
app/models/user_token.rb
app/models/way.rb
lib/gpx.rb
script/statistics
script/update-spam-blocks
test/controllers/api/changeset_comments_controller_test.rb
test/controllers/api/changesets_controller_test.rb
test/controllers/api/notes_controller_test.rb
test/controllers/browse_controller_test.rb
test/controllers/messages_controller_test.rb
test/controllers/user_blocks_controller_test.rb
test/factories/messages.rb
test/factories/node.rb
test/factories/old_node.rb
test/factories/old_relation.rb
test/factories/old_way.rb
test/factories/relation.rb
test/factories/tracepoints.rb
test/factories/traces.rb
test/factories/user.rb
test/factories/user_blocks.rb
test/factories/way.rb
test/helpers/application_helper_test.rb
test/helpers/user_blocks_helper_test.rb
test/integration/user_blocks_test.rb
test/models/message_test.rb
test/models/note_test.rb

index 0cdd004a0834e24d826760f31acbd68dd2c959e0..779b3a8fa29a8c52332618b9a8b9be81d27aee08 100644 (file)
@@ -183,13 +183,6 @@ Rails/OutputSafety:
     - 'lib/rich_text.rb'
     - 'test/helpers/application_helper_test.rb'
 
-# Offense count: 90
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: strict, flexible
-Rails/TimeZone:
-  Enabled: false
-
 # Offense count: 6
 # Cop supports --auto-correct.
 Rake/Desc:
index 63fda31bdc297e0e509437da3d6ada61584197bd..df27ab5ca7a1866ea6dfa0577a01d0893978573f 100644 (file)
@@ -307,11 +307,11 @@ module Api
         times = time.split(",")
         raise OSM::APIBadUserInput, "bad time range" if times.size != 2
 
-        from, to = times.collect { |t| Time.parse(t) }
+        from, to = times.collect { |t| Time.parse(t).utc }
         changesets.where("closed_at >= ? and created_at <= ?", from, to)
       else
         # if there is no comma, assume its a lower limit on time
-        changesets.where("closed_at >= ?", Time.parse(time))
+        changesets.where("closed_at >= ?", Time.parse(time).utc)
       end
       # stupid Time seems to throw both of these for bad parsing, so
       # we have to catch both and ensure the correct code path is taken.
@@ -329,7 +329,7 @@ module Api
         changesets
       else
         changesets.where("closed_at >= ? and num_changes <= ?",
-                         Time.now.getutc, Changeset::MAX_ELEMENTS)
+                         Time.now.utc, Changeset::MAX_ELEMENTS)
       end
     end
 
@@ -341,7 +341,7 @@ module Api
         changesets
       else
         changesets.where("closed_at < ? or num_changes > ?",
-                         Time.now.getutc, Changeset::MAX_ELEMENTS)
+                         Time.now.utc, Changeset::MAX_ELEMENTS)
       end
     end
 
index f480b9706102c9a549bc770b5c7064b6fdaa7253..8a41d5db804b2eac4a156404d7213b1d2fadc644 100644 (file)
@@ -277,16 +277,16 @@ module Api
       # Add any date filter
       if params[:from]
         begin
-          from = Time.parse(params[:from])
+          from = Time.parse(params[:from]).utc
         rescue ArgumentError
           raise OSM::APIBadUserInput, "Date #{params[:from]} is in a wrong format"
         end
 
         begin
           to = if params[:to]
-                 Time.parse(params[:to])
+                 Time.parse(params[:to]).utc
                else
-                 Time.now
+                 Time.now.utc
                end
         rescue ArgumentError
           raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
@@ -361,7 +361,7 @@ module Api
       elsif closed_since.positive?
         notes.where(:status => "open")
              .or(notes.where(:status => "closed")
-                      .where(notes.arel_table[:closed_at].gt(Time.now - closed_since.days)))
+                      .where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since.days)))
       else
         notes.where(:status => "open")
       end
index aa8a0600071c9c59546091011f568552f51d4767..6a0ec81ec72d82f698beebecd5773c92ede80ce0 100644 (file)
@@ -108,7 +108,7 @@ module Api
         :visibility => visibility,
         :inserted => false,
         :user => current_user,
-        :timestamp => Time.now.getutc,
+        :timestamp => Time.now.utc,
         :file => file
       )
 
index 93dffb4a366f6d3965aca3614147a57e54f65260..a08ce0b69882017a2719a3cf4309e0b910937e92 100644 (file)
@@ -19,7 +19,7 @@ class FriendshipsController < ApplicationController
         friendship.befriendee = @new_friend
         if current_user.is_friends_with?(@new_friend)
           flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name
-        elsif current_user.friendships.where("created_at >= ?", Time.now.getutc - 1.hour).count >= current_user.max_friends_per_hour
+        elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour
           flash.now[:error] = t "friendships.make_friend.limit_exceeded"
         elsif friendship.save
           flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
index a95e2e5878d6965f31f1ae7b425828c4721017fd..e801915d6e03d9933cd30e919ca8a73237ab5566 100644 (file)
@@ -24,9 +24,9 @@ class MessagesController < ApplicationController
     @message = Message.new(message_params)
     @message.recipient = @user
     @message.sender = current_user
-    @message.sent_on = Time.now.getutc
+    @message.sent_on = Time.now.utc
 
-    if current_user.sent_messages.where("sent_on >= ?", Time.now.getutc - 1.hour).count >= current_user.max_messages_per_hour
+    if current_user.sent_messages.where("sent_on >= ?", Time.now.utc - 1.hour).count >= current_user.max_messages_per_hour
       flash.now[:error] = t ".limit_exceeded"
       render :action => "new"
     elsif @message.save
index a9dbc85396cb675381b074c88cfe8503e020fbe1..741819f65a167c3c8a149955f0d742f19a343a47 100644 (file)
@@ -119,7 +119,7 @@ class TracesController < ApplicationController
                          :description => params[:trace][:description],
                          :visibility => params[:trace][:visibility],
                          :inserted => false, :user => current_user,
-                         :timestamp => Time.now.getutc)
+                         :timestamp => Time.now.utc)
       @trace.valid?
       @trace.errors.add(:gpx_file, "can't be blank")
 
@@ -266,7 +266,7 @@ class TracesController < ApplicationController
       :visibility => visibility,
       :inserted => false,
       :user => current_user,
-      :timestamp => Time.now.getutc,
+      :timestamp => Time.now.utc,
       :file => file
     )
 
index 63fca655750830184e5a0d221326b050426e5fce..63ebdad713b85f5b54785c5d8169a611f89d57dc 100644 (file)
@@ -32,7 +32,7 @@ class UserBlocksController < ApplicationController
   end
 
   def edit
-    params[:user_block_period] = ((@user_block.ends_at - Time.now.getutc) / 1.hour).ceil.to_s
+    params[:user_block_period] = ((@user_block.ends_at - Time.now.utc) / 1.hour).ceil.to_s
   end
 
   def create
@@ -41,7 +41,7 @@ class UserBlocksController < ApplicationController
         :user => @user,
         :creator => current_user,
         :reason => params[:user_block][:reason],
-        :ends_at => Time.now.getutc + @block_period.hours,
+        :ends_at => Time.now.utc + @block_period.hours,
         :needs_view => params[:user_block][:needs_view]
       )
 
@@ -62,7 +62,7 @@ class UserBlocksController < ApplicationController
         flash[:error] = t(".only_creator_can_edit")
         redirect_to :action => "edit"
       elsif @user_block.update(
-        :ends_at => Time.now.getutc + @block_period.hours,
+        :ends_at => Time.now.utc + @block_period.hours,
         :reason => params[:user_block][:reason],
         :needs_view => params[:user_block][:needs_view]
       )
index 39a191d841effafde6ca2a9d4b5a90f70270d57f..3489b4eda9e290c039f8cb61e4117b93bd08c267 100644 (file)
@@ -55,8 +55,8 @@ class UsersController < ApplicationController
     elsif current_user
       unless current_user.terms_agreed?
         current_user.consider_pd = params[:user][:consider_pd]
-        current_user.tou_agreed = Time.now.getutc
-        current_user.terms_agreed = Time.now.getutc
+        current_user.tou_agreed = Time.now.utc
+        current_user.terms_agreed = Time.now.utc
         current_user.terms_seen = true
 
         flash[:notice] = t "users.new.terms accepted" if current_user.save
@@ -73,8 +73,8 @@ class UsersController < ApplicationController
         current_user.description = "" if current_user.description.nil?
         current_user.creation_ip = request.remote_ip
         current_user.languages = http_accept_language.user_preferred_languages
-        current_user.terms_agreed = Time.now.getutc
-        current_user.tou_agreed = Time.now.getutc
+        current_user.terms_agreed = Time.now.utc
+        current_user.tou_agreed = Time.now.utc
         current_user.terms_seen = true
 
         if current_user.auth_uid.blank?
index 4c0236b6b2ab6e8bee86a4cd749be8f37b0ebc2d..5773240ff1d64fbce02d99dc0ac2695c45bf594d 100644 (file)
@@ -10,7 +10,7 @@ module ChangesetsHelper
   end
 
   def changeset_details(changeset)
-    if changeset.closed_at > Time.now
+    if changeset.closed_at > Time.now.utc
       action = :created
       time = time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")
       title = l(changeset.created_at)
index 95b6cb600c739786701c0cb95c6fe8470c4428a3..3a55e1cdedfcc12d9f3d02ca1135ed7f8f339feb 100644 (file)
@@ -8,7 +8,7 @@ module UserBlocksHelper
     if block.active?
       # if the block hasn't expired yet show the date, if the user just needs to login show that
       if block.needs_view?
-        if block.ends_at > Time.now.getutc
+        if block.ends_at > Time.now.utc
           t("user_blocks.helper.time_future_and_until_login_html", :time => friendly_date(block.ends_at))
         else
           t("user_blocks.helper.until_login")
index 53590a5946461c89e13dc22bc69b4a945a8cc94b..d2c0dba1ce85a93e39b7838f0e6b1bcbd24f88e5 100644 (file)
@@ -52,6 +52,6 @@ class AccessToken < OauthToken
   protected
 
   def set_authorized_at
-    self.authorized_at = Time.now
+    self.authorized_at = Time.now.utc
   end
 end
index 9ed22ee947c5cea350855a83c9280131614ebcf0..2659eaeeacf1ad6bf4c59f37a64da5c18bcc1703 100644 (file)
@@ -71,11 +71,11 @@ class Changeset < ApplicationRecord
     # note that this may not be a hard limit - due to timing changes and
     # concurrency it is possible that some changesets may be slightly
     # longer than strictly allowed or have slightly more changes in them.
-    ((closed_at > Time.now.getutc) && (num_changes <= MAX_ELEMENTS))
+    ((closed_at > Time.now.utc) && (num_changes <= MAX_ELEMENTS))
   end
 
   def set_closed_time_now
-    self.closed_at = Time.now.getutc if is_open?
+    self.closed_at = Time.now.utc if is_open?
   end
 
   def self.from_xml(xml, create: false)
@@ -95,7 +95,7 @@ class Changeset < ApplicationRecord
   def self.from_xml_node(pt, create: false)
     cs = Changeset.new
     if create
-      cs.created_at = Time.now.getutc
+      cs.created_at = Time.now.utc
       # initial close time is 1h ahead, but will be increased on each
       # modification.
       cs.closed_at = cs.created_at + IDLE_TIMEOUT
@@ -191,7 +191,7 @@ class Changeset < ApplicationRecord
       self.closed_at = if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
                          created_at + MAX_TIME_OPEN
                        else
-                         Time.now.getutc + IDLE_TIMEOUT
+                         Time.now.utc + IDLE_TIMEOUT
                        end
     end
   end
index 207af63c4b1481ad79179d671c390cd9b3d178e5..54947be303d569e76691e7959b17b7568a7e69ab 100644 (file)
@@ -70,7 +70,7 @@ class Issue < ApplicationRecord
     event :resolve do
       transitions :from => :open, :to => :resolved
       after do
-        self.resolved_at = Time.now.getutc
+        self.resolved_at = Time.now.utc
       end
     end
 
index 2ae62d68482701ea48b933fa05fa837ab1d125db..c2443974d822474f84917330a508a82d94fa1ba9 100644 (file)
@@ -236,7 +236,7 @@ class Node < ApplicationRecord
   private
 
   def save_with_history!
-    t = Time.now.getutc
+    t = Time.now.utc
 
     self.version += 1
     self.timestamp = t
index ea88599a4a9db66fbf4c2df046f171f850a25195..aeea0de0d8103224c64be540ef3ef6e1eb91415d 100644 (file)
@@ -45,7 +45,7 @@ class Note < ApplicationRecord
   # Close a note
   def close
     self.status = "closed"
-    self.closed_at = Time.now.getutc
+    self.closed_at = Time.now.utc
     save
   end
 
index 3eca1038c22333263f8d213974d90ba78066395f..1613eabeb516701976889d4550a8fa715126f074 100644 (file)
@@ -67,6 +67,6 @@ class Oauth2Verifier < OauthToken
   def generate_keys
     self.token = OAuth::Helper.generate_key(20)[0, 20]
     self.expires_at = 10.minutes.from_now
-    self.authorized_at = Time.now
+    self.authorized_at = Time.now.utc
   end
 end
index b4519efe21642a0b60693e6279d2eeb32d59fde7..ae15dc658e73ec726bc78d989505ad34ce8fac88 100644 (file)
@@ -52,7 +52,7 @@ class OauthToken < ApplicationRecord
   end
 
   def invalidate!
-    update(:invalidated_at => Time.now)
+    update(:invalidated_at => Time.now.utc)
   end
 
   def authorized?
index 0adf1012d67e1b03f00595c44c06c317cd7ada45..021082eda01243b73f93320e5e0624876c7b73ae 100644 (file)
@@ -263,7 +263,7 @@ class Relation < ApplicationRecord
   private
 
   def save_with_history!
-    t = Time.now.getutc
+    t = Time.now.utc
 
     self.version += 1
     self.timestamp = t
index f7c9501b56b3c84ce938a98b4966c4c3d8ac11d3..adeabb18497ff4fd7e0556df56aecd16579a9be1 100644 (file)
@@ -42,7 +42,7 @@ class RequestToken < OauthToken
     return false if authorized?
 
     self.user = user
-    self.authorized_at = Time.now
+    self.authorized_at = Time.now.utc
     self.verifier = OAuth::Helper.generate_key(20)[0, 20] unless oauth10?
     save
   end
index 46a8c282b3c18ba8d3b10f9554fe54cde8a1f8ae..7af1f9bdc2d009a562bb910a6d560c6e7ae1846a 100644 (file)
@@ -37,7 +37,7 @@ class UserBlock < ApplicationRecord
   ##
   # scope to match active blocks
   def self.active
-    where("needs_view or ends_at > ?", Time.now.getutc)
+    where("needs_view or ends_at > ?", Time.now.utc)
   end
 
   ##
@@ -50,7 +50,7 @@ class UserBlock < ApplicationRecord
   # returns true if the block is currently active (i.e: the user can't
   # use the API).
   def active?
-    needs_view || ends_at > Time.now.getutc
+    needs_view || ends_at > Time.now.utc
   end
 
   ##
@@ -65,7 +65,7 @@ class UserBlock < ApplicationRecord
   # is the user object who is revoking the ban.
   def revoke!(revoker)
     update(
-      :ends_at => Time.now.getutc,
+      :ends_at => Time.now.utc,
       :revoker_id => revoker.id,
       :needs_view => false
     )
index 8c9bf4aeb36de68479d11533e406f9106877da4b..f927563a948694b80197a2cdf1523f9f9ec126e4 100644 (file)
@@ -24,7 +24,7 @@ class UserToken < ApplicationRecord
   after_initialize :set_defaults
 
   def expired?
-    expiry < Time.now
+    expiry < Time.now.utc
   end
 
   private
index 767289d583ddc3b3a3769b37e4ba2714ad00aebb..08dc5ed305142ab5a45b4625839ab7ebbbf7ef24 100644 (file)
@@ -227,7 +227,7 @@ class Way < ApplicationRecord
   private
 
   def save_with_history!
-    t = Time.now.getutc
+    t = Time.now.utc
 
     self.version += 1
     self.timestamp = t
index 3dc448e4632cd85c9221d701f1c8386eca2b8151..274ece7d9a3160e6eba8f194fcbe6eb7956bffbc 100644 (file)
@@ -22,7 +22,7 @@ module GPX
           elsif reader.name == "ele" && point
             point.altitude = reader.read_string.to_f
           elsif reader.name == "time" && point
-            point.timestamp = Time.parse(reader.read_string)
+            point.timestamp = Time.parse(reader.read_string).utc
           end
         when XML::Reader::TYPE_END_ELEMENT
           if reader.name == "trkpt" && point && point.valid?
index ffc672b0bdf3f34925f6eb919ac855a2c67529e6..05ed637a866eb8a4152bf0657295f92089894d11 100755 (executable)
@@ -2,7 +2,7 @@
 
 require File.join(File.dirname(__FILE__), "..", "config", "environment")
 
-start_time = Time.now
+start_time = Time.now.utc
 
 puts "<html>"
 puts "<head>"
@@ -87,7 +87,7 @@ rescue StandardError => e
   puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
 end
 
-puts "<p>Report took #{Time.new - start_time} seconds to run</p>"
+puts "<p>Report took #{Time.now.utc - start_time} seconds to run</p>"
 puts "</body>"
 puts "</html>"
 
index 40f2cb03c5715f4b89dece59964ad7ebb13bd16b..b5656f6ac0b5b7aad20208084b990789985fdc9b 100755 (executable)
@@ -6,7 +6,7 @@ require "generator"
 addresses = User.count(
   :conditions => {
     :status => %w[suspended deleted],
-    :creation_time => Time.now - 28.days..Time.now
+    :creation_time => Time.now.utc - 28.days..Time.now.utc
   },
   :group => :creation_ip
 )
index 64871baa3c4fed59e8fe705792a291641baf71e0..ce7c08a659d8b63269b7d8fb353d486e1eb6f15a 100644 (file)
@@ -214,7 +214,7 @@ module Api
       assert_response :forbidden
 
       # Try again, after agreement with the terms
-      user.terms_agreed = Time.now
+      user.terms_agreed = Time.now.utc
       user.save!
 
       assert_difference "ChangesetComment.count", 1 do
@@ -237,7 +237,7 @@ module Api
       assert_response :forbidden
 
       # Try again, after agreement with the terms
-      user.terms_agreed = Time.now
+      user.terms_agreed = Time.now.utc
       user.save!
 
       assert_difference "ChangesetComment.count", 1 do
index f3de0682b53ad1ca28da38b400f1436f1fb7dd7f..e61831fbd2feec5dd25cedee8848322537331a33 100644 (file)
@@ -206,7 +206,7 @@ module Api
       # test that it really is closed now
       cs = Changeset.find(changeset.id)
       assert_not(cs.is_open?,
-                 "changeset should be closed now (#{cs.closed_at} > #{Time.now.getutc}.")
+                 "changeset should be closed now (#{cs.closed_at} > #{Time.now.utc}.")
     end
 
     ##
index fe9127029e8125cf9b09a03f066b6903e587c8c4..7dbcdc816e8ae965b007e8445a0b5572633c99d4 100644 (file)
@@ -345,7 +345,7 @@ module Api
       end
       assert_response :gone
 
-      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now)
+      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc)
 
       assert_no_difference "NoteComment.count" do
         post comment_note_path(:id => closed_note_with_comment, :text => "This is an additional comment"), :headers => auth_header
@@ -406,14 +406,14 @@ module Api
       post close_note_path(:id => hidden_note_with_comment), :headers => auth_header
       assert_response :gone
 
-      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now)
+      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc)
 
       post close_note_path(:id => closed_note_with_comment), :headers => auth_header
       assert_response :conflict
     end
 
     def test_reopen_success
-      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now)
+      closed_note_with_comment = create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc)
       user = create(:user)
 
       post reopen_note_path(:id => closed_note_with_comment, :text => "This is a reopen comment", :format => "json")
@@ -748,8 +748,8 @@ module Api
     end
 
     def test_index_closed
-      create(:note_with_comments, :status => "closed", :closed_at => Time.now - 5.days)
-      create(:note_with_comments, :status => "closed", :closed_at => Time.now - 100.days)
+      create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc - 5.days)
+      create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc - 100.days)
       create(:note_with_comments, :status => "hidden")
       create(:note_with_comments)
 
index 9a77e803417c2ac1b7b73f3d182c7ab3baf36e5c..7ad16dcd982ee8020a583c3cbcf5bc97414a0057 100644 (file)
@@ -153,7 +153,7 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest
 
   def test_read_closed_note
     user = create(:user)
-    closed_note = create(:note_with_comments, :status => "closed", :closed_at => Time.now, :comments_count => 2) do |note|
+    closed_note = create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc, :comments_count => 2) do |note|
       create(:note_comment, :event => "closed", :note => note, :author => user)
     end
 
index c3d7645789f22f744ed632100e446cb791b48619..1193d3b25ec90187279e63b4ecb7a1d84dace48a 100644 (file)
@@ -191,7 +191,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
     m = Message.last
     assert_equal user.id, m.from_user_id
     assert_equal recipient_user.id, m.to_user_id
-    assert_in_delta Time.now, m.sent_on, 2
+    assert_in_delta Time.now.utc, m.sent_on, 2
     assert_equal "Test Message", m.title
     assert_equal "Test message body", m.body
     assert_equal "markdown", m.body_format
index 3e2be801da33e903bf4db4d874ae67c3051ed43c..16a77624c75ee8dabc02fb62bb85242e44ee6631 100644 (file)
@@ -240,9 +240,9 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to user_block_path(:id => id)
     assert_equal "Created a block on user #{target_user.display_name}.", flash[:notice]
     b = UserBlock.find(id)
-    assert_in_delta Time.now, b.created_at, 1
-    assert_in_delta Time.now, b.updated_at, 1
-    assert_in_delta Time.now + 12.hours, b.ends_at, 1
+    assert_in_delta Time.now.utc, b.created_at, 1
+    assert_in_delta Time.now.utc, b.updated_at, 1
+    assert_in_delta Time.now.utc + 12.hours, b.ends_at, 1
     assert_not b.needs_view
     assert_equal "Vandalism", b.reason
     assert_equal "markdown", b.reason_format
@@ -311,7 +311,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to user_block_path(active_block)
     assert_equal "Block updated.", flash[:notice]
     b = UserBlock.find(active_block.id)
-    assert_in_delta Time.now, b.updated_at, 1
+    assert_in_delta Time.now.utc, b.updated_at, 1
     assert b.needs_view
     assert_equal "Vandalism", b.reason
 
@@ -356,13 +356,13 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "revoke"
     b = UserBlock.find(active_block.id)
-    assert b.ends_at - Time.now > 100
+    assert b.ends_at - Time.now.utc > 100
 
     # Check that revoking a block works using POST
     post revoke_user_block_path(:id => active_block, :confirm => true)
     assert_redirected_to user_block_path(active_block)
     b = UserBlock.find(active_block.id)
-    assert_in_delta Time.now, b.ends_at, 1
+    assert_in_delta Time.now.utc, b.ends_at, 1
 
     # We should get an error if the block doesn't exist
     get revoke_user_block_path(:id => 99999)
index 57a434fa1e739fb8ec32ee56922419631d32f95c..cd148c7896a2f80720258ab27262a66127a767a4 100644 (file)
@@ -2,7 +2,7 @@ FactoryBot.define do
   factory :message do
     sequence(:title) { |n| "Message #{n}" }
     sequence(:body) { |n| "Body text for message #{n}" }
-    sent_on { Time.now }
+    sent_on { Time.now.utc }
 
     association :sender, :factory => :user
     association :recipient, :factory => :user
index ae32926cdc0a2c81be54e89f36756249e71badc1..392d67a846d0401f6243681cf451294add3859c7 100644 (file)
@@ -6,7 +6,7 @@ FactoryBot.define do
     changeset
 
     visible { true }
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     version { 1 }
 
     trait :deleted do
index e129b62f7b7a5b6118f6cf9f136964c193aecb65..a2ca0a2ee3c7780389d2f11ead22ba60455574a8 100644 (file)
@@ -7,7 +7,7 @@ FactoryBot.define do
     association :current_node, :factory => :node
 
     visible { true }
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     version { 1 }
   end
 end
index 8fdb23f58e3b65752aed5e819edca7aaec4b6be7..1bc1b36cf0c94e7fe2ee2978d10e0df88eaca640 100644 (file)
@@ -1,6 +1,6 @@
 FactoryBot.define do
   factory :old_relation do
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     visible { true }
     version { 1 }
 
index 4fc0721d798d14e2c64d9c5579aee9360df4dc44..265a477d3022c278a5ee11fbd93a2b69397980b5 100644 (file)
@@ -1,6 +1,6 @@
 FactoryBot.define do
   factory :old_way do
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     visible { true }
     version { 1 }
 
index 8bb00e287e4045e3ada93f7a154b9f26412660e1..6d43df0a37290dbfb3750b6d3c36f52e2b0d769a 100644 (file)
@@ -1,6 +1,6 @@
 FactoryBot.define do
   factory :relation do
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     visible { true }
     version { 1 }
 
index 4ba152f6e05c73244b9860483a31afddf4676f40..86d2aea57a630a601969df31dd2703409ad1bdeb 100644 (file)
@@ -4,7 +4,7 @@ FactoryBot.define do
     latitude { 1 * GeoRecord::SCALE }
     longitude { 1 * GeoRecord::SCALE }
     # tile { QuadTile.tile_for_point(1,1) }
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
 
     trace
   end
index 687339e7f49a5ae1ce9212ba626b94ea51b78979..88c57745b1db17e41e00a738b126f5b375402efd 100644 (file)
@@ -5,7 +5,7 @@ FactoryBot.define do
 
     user
 
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     inserted { true }
     size { 10 }
 
index 07f1ef679b8a6470bee38c3c986f185e7157a007..cdc606cf1d66f6087514156b5192fc6e55eb3238 100644 (file)
@@ -11,7 +11,7 @@ FactoryBot.define do
     end
 
     terms_seen { true }
-    terms_agreed { Time.now.getutc }
+    terms_agreed { Time.now.utc }
     data_public { true }
 
     trait :with_home_location do
index 53864bb0eb6fc5bbf75cf19b36e8d8b50875a6f1..fefbba45ace1b61fbd3932ea1851ba6e5a69fd67 100644 (file)
@@ -1,7 +1,7 @@
 FactoryBot.define do
   factory :user_block do
     sequence(:reason) { |n| "User Block #{n}" }
-    ends_at { Time.now + 1.day }
+    ends_at { Time.now.utc + 1.day }
 
     user
     association :creator, :factory => :moderator_user
@@ -11,7 +11,7 @@ FactoryBot.define do
     end
 
     trait :expired do
-      ends_at { Time.now - 1.day }
+      ends_at { Time.now.utc - 1.day }
     end
 
     trait :revoked do
index 1b6b18dc98a0aedae7821791d9831c0c3c4549ce..f2093e305ca8c32807939c06a362c7bf4b534dc0 100644 (file)
@@ -1,6 +1,6 @@
 FactoryBot.define do
   factory :way do
-    timestamp { Time.now }
+    timestamp { Time.now.utc }
     visible { true }
     version { 1 }
 
index 43e27c5295bc1cf4adbd01414b1b5e8e2e7deaea..d3e4d4f072b3006a53bed6a36f95063f665d95d5 100644 (file)
@@ -56,19 +56,19 @@ class ApplicationHelperTest < ActionView::TestCase
   end
 
   def test_friendly_date
-    date = friendly_date(Time.new(2014, 3, 5, 18, 58, 23))
+    date = friendly_date(Time.new(2014, 3, 5, 18, 58, 23).utc)
     assert_match %r{^<span title=" *5 March 2014 at 18:58">.*</span>$}, date
 
-    date = friendly_date(Time.now - 1.hour)
+    date = friendly_date(Time.now.utc - 1.hour)
     assert_match %r{^<span title=".*">about 1 hour</span>$}, date
 
-    date = friendly_date(Time.now - 2.days)
+    date = friendly_date(Time.now.utc - 2.days)
     assert_match %r{^<span title=".*">2 days</span>$}, date
 
-    date = friendly_date(Time.now - 3.weeks)
+    date = friendly_date(Time.now.utc - 3.weeks)
     assert_match %r{^<span title=".*">21 days</span>$}, date
 
-    date = friendly_date(Time.now - 4.months)
+    date = friendly_date(Time.now.utc - 4.months)
     assert_match %r{^<span title=".*">4 months</span>$}, date
   end
 
index c4afa6c83b6e7e991d8ad8b869903af75d7932f9..0c2ab42b5810ad13683a5e317ea43fd81964ecdf 100644 (file)
@@ -4,13 +4,13 @@ class UserBlocksHelperTest < ActionView::TestCase
   include ApplicationHelper
 
   def test_block_status
-    block = create(:user_block, :needs_view, :ends_at => Time.now.getutc)
+    block = create(:user_block, :needs_view, :ends_at => Time.now.utc)
     assert_equal "Active until the user logs in.", block_status(block)
 
-    block = create(:user_block, :needs_view, :ends_at => Time.now.getutc + 1.hour)
+    block = create(:user_block, :needs_view, :ends_at => Time.now.utc + 1.hour)
     assert_match %r{^Ends in <span title=".*">about 1 hour</span> and after the user has logged in\.$}, block_status(block)
 
-    block = create(:user_block, :ends_at => Time.now.getutc + 1.hour)
+    block = create(:user_block, :ends_at => Time.now.utc + 1.hour)
     assert_match %r{^Ends in <span title=".*">about 1 hour</span>\.$}, block_status(block)
   end
 
index ecadaad534f8a0d732114d860a73d1110a4fd2c5..96dd879ee08273309e9cba75cffad8ec131e5551 100644 (file)
@@ -15,7 +15,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
       :user_id => blocked_user.id,
       :creator_id => create(:moderator_user).id,
       :reason => "testing",
-      :ends_at => Time.now.getutc + 5.minutes
+      :ends_at => Time.now.utc + 5.minutes
     )
     get "/api/#{Settings.api_version}/user/details", :headers => basic_authorization_header(blocked_user.display_name, "test")
     assert_response :forbidden
@@ -29,7 +29,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
       :user_id => blocked_user.id,
       :creator_id => moderator.id,
       :reason => "testing",
-      :ends_at => Time.now.getutc + 5.minutes
+      :ends_at => Time.now.utc + 5.minutes
     )
     get "/api/#{Settings.api_version}/user/details", :headers => basic_authorization_header(blocked_user.display_name, "test")
     assert_response :forbidden
index 3a25c1a4b53162e6bf0acc1220cbaeacbe0dfe8b..1a12410916775e2ed67cb1ff67069c0f68161b18 100644 (file)
@@ -75,7 +75,7 @@ class MessageTest < ActiveSupport::TestCase
       from "from@example.com"
       to "to@example.com"
       subject "Test message"
-      date Time.now
+      date Time.now.utc
       content_type "text/plain; charset=utf-8"
       body "This is a test & a message"
     end
@@ -95,7 +95,7 @@ class MessageTest < ActiveSupport::TestCase
       from "from@example.com"
       to "to@example.com"
       subject "Test message"
-      date Time.now
+      date Time.now.utc
       content_type "text/html; charset=utf-8"
       body "<p>This is a <b>test</b> &amp; a message</p>"
     end
@@ -115,7 +115,7 @@ class MessageTest < ActiveSupport::TestCase
       from "from@example.com"
       to "to@example.com"
       subject "Test message"
-      date Time.now
+      date Time.now.utc
 
       text_part do
         content_type "text/plain; charset=utf-8"
@@ -139,7 +139,7 @@ class MessageTest < ActiveSupport::TestCase
       from "from@example.com"
       to "to@example.com"
       subject "Test message"
-      date Time.now
+      date Time.now.utc
 
       html_part do
         content_type "text/html; charset=utf-8"
@@ -162,7 +162,7 @@ class MessageTest < ActiveSupport::TestCase
       from "from@example.com"
       to "to@example.com"
       subject "[OpenStreetMap] Test message"
-      date Time.now
+      date Time.now.utc
       content_type "text/plain; charset=utf-8"
       body "This is a test & a message"
     end
index 2385125b5487e85bf64ad7637e3847f9d2c7170a..b74cebcc4cc4d2da028f451eb97e0a5bf57ff0ce 100644 (file)
@@ -28,7 +28,7 @@ class NoteTest < ActiveSupport::TestCase
   end
 
   def test_reopen
-    note = create(:note, :status => "closed", :closed_at => Time.now)
+    note = create(:note, :status => "closed", :closed_at => Time.now.utc)
     assert_equal "closed", note.status
     assert_not_nil note.closed_at
     note.reopen
@@ -43,7 +43,7 @@ class NoteTest < ActiveSupport::TestCase
   end
 
   def test_closed?
-    assert create(:note, :status => "closed", :closed_at => Time.now).closed?
+    assert create(:note, :status => "closed", :closed_at => Time.now.utc).closed?
     assert_not create(:note, :status => "open", :closed_at => nil).closed?
   end