Fix rubocop Rails/TimeZone warnings
This commit is contained in:
parent
304eb3b75c
commit
b5f06e06c1
48 changed files with 89 additions and 96 deletions
|
@ -183,13 +183,6 @@ Rails/OutputSafety:
|
||||||
- 'lib/rich_text.rb'
|
- 'lib/rich_text.rb'
|
||||||
- 'test/helpers/application_helper_test.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
|
# Offense count: 6
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Rake/Desc:
|
Rake/Desc:
|
||||||
|
|
|
@ -307,11 +307,11 @@ module Api
|
||||||
times = time.split(",")
|
times = time.split(",")
|
||||||
raise OSM::APIBadUserInput, "bad time range" if times.size != 2
|
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)
|
changesets.where("closed_at >= ? and created_at <= ?", from, to)
|
||||||
else
|
else
|
||||||
# if there is no comma, assume its a lower limit on time
|
# 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
|
end
|
||||||
# stupid Time seems to throw both of these for bad parsing, so
|
# 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.
|
# we have to catch both and ensure the correct code path is taken.
|
||||||
|
@ -329,7 +329,7 @@ module Api
|
||||||
changesets
|
changesets
|
||||||
else
|
else
|
||||||
changesets.where("closed_at >= ? and num_changes <= ?",
|
changesets.where("closed_at >= ? and num_changes <= ?",
|
||||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
Time.now.utc, Changeset::MAX_ELEMENTS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ module Api
|
||||||
changesets
|
changesets
|
||||||
else
|
else
|
||||||
changesets.where("closed_at < ? or num_changes > ?",
|
changesets.where("closed_at < ? or num_changes > ?",
|
||||||
Time.now.getutc, Changeset::MAX_ELEMENTS)
|
Time.now.utc, Changeset::MAX_ELEMENTS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -277,16 +277,16 @@ module Api
|
||||||
# Add any date filter
|
# Add any date filter
|
||||||
if params[:from]
|
if params[:from]
|
||||||
begin
|
begin
|
||||||
from = Time.parse(params[:from])
|
from = Time.parse(params[:from]).utc
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise OSM::APIBadUserInput, "Date #{params[:from]} is in a wrong format"
|
raise OSM::APIBadUserInput, "Date #{params[:from]} is in a wrong format"
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
to = if params[:to]
|
to = if params[:to]
|
||||||
Time.parse(params[:to])
|
Time.parse(params[:to]).utc
|
||||||
else
|
else
|
||||||
Time.now
|
Time.now.utc
|
||||||
end
|
end
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
|
raise OSM::APIBadUserInput, "Date #{params[:to]} is in a wrong format"
|
||||||
|
@ -361,7 +361,7 @@ module Api
|
||||||
elsif closed_since.positive?
|
elsif closed_since.positive?
|
||||||
notes.where(:status => "open")
|
notes.where(:status => "open")
|
||||||
.or(notes.where(:status => "closed")
|
.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
|
else
|
||||||
notes.where(:status => "open")
|
notes.where(:status => "open")
|
||||||
end
|
end
|
||||||
|
|
|
@ -108,7 +108,7 @@ module Api
|
||||||
:visibility => visibility,
|
:visibility => visibility,
|
||||||
:inserted => false,
|
:inserted => false,
|
||||||
:user => current_user,
|
:user => current_user,
|
||||||
:timestamp => Time.now.getutc,
|
:timestamp => Time.now.utc,
|
||||||
:file => file
|
:file => file
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class FriendshipsController < ApplicationController
|
||||||
friendship.befriendee = @new_friend
|
friendship.befriendee = @new_friend
|
||||||
if current_user.is_friends_with?(@new_friend)
|
if current_user.is_friends_with?(@new_friend)
|
||||||
flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name
|
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"
|
flash.now[:error] = t "friendships.make_friend.limit_exceeded"
|
||||||
elsif friendship.save
|
elsif friendship.save
|
||||||
flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
|
flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name
|
||||||
|
|
|
@ -24,9 +24,9 @@ class MessagesController < ApplicationController
|
||||||
@message = Message.new(message_params)
|
@message = Message.new(message_params)
|
||||||
@message.recipient = @user
|
@message.recipient = @user
|
||||||
@message.sender = current_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"
|
flash.now[:error] = t ".limit_exceeded"
|
||||||
render :action => "new"
|
render :action => "new"
|
||||||
elsif @message.save
|
elsif @message.save
|
||||||
|
|
|
@ -119,7 +119,7 @@ class TracesController < ApplicationController
|
||||||
:description => params[:trace][:description],
|
:description => params[:trace][:description],
|
||||||
:visibility => params[:trace][:visibility],
|
:visibility => params[:trace][:visibility],
|
||||||
:inserted => false, :user => current_user,
|
:inserted => false, :user => current_user,
|
||||||
:timestamp => Time.now.getutc)
|
:timestamp => Time.now.utc)
|
||||||
@trace.valid?
|
@trace.valid?
|
||||||
@trace.errors.add(:gpx_file, "can't be blank")
|
@trace.errors.add(:gpx_file, "can't be blank")
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ class TracesController < ApplicationController
|
||||||
:visibility => visibility,
|
:visibility => visibility,
|
||||||
:inserted => false,
|
:inserted => false,
|
||||||
:user => current_user,
|
:user => current_user,
|
||||||
:timestamp => Time.now.getutc,
|
:timestamp => Time.now.utc,
|
||||||
:file => file
|
:file => file
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class UserBlocksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -41,7 +41,7 @@ class UserBlocksController < ApplicationController
|
||||||
:user => @user,
|
:user => @user,
|
||||||
:creator => current_user,
|
:creator => current_user,
|
||||||
:reason => params[:user_block][:reason],
|
: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]
|
:needs_view => params[:user_block][:needs_view]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class UserBlocksController < ApplicationController
|
||||||
flash[:error] = t(".only_creator_can_edit")
|
flash[:error] = t(".only_creator_can_edit")
|
||||||
redirect_to :action => "edit"
|
redirect_to :action => "edit"
|
||||||
elsif @user_block.update(
|
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],
|
:reason => params[:user_block][:reason],
|
||||||
:needs_view => params[:user_block][:needs_view]
|
:needs_view => params[:user_block][:needs_view]
|
||||||
)
|
)
|
||||||
|
|
|
@ -55,8 +55,8 @@ class UsersController < ApplicationController
|
||||||
elsif current_user
|
elsif current_user
|
||||||
unless current_user.terms_agreed?
|
unless current_user.terms_agreed?
|
||||||
current_user.consider_pd = params[:user][:consider_pd]
|
current_user.consider_pd = params[:user][:consider_pd]
|
||||||
current_user.tou_agreed = Time.now.getutc
|
current_user.tou_agreed = Time.now.utc
|
||||||
current_user.terms_agreed = Time.now.getutc
|
current_user.terms_agreed = Time.now.utc
|
||||||
current_user.terms_seen = true
|
current_user.terms_seen = true
|
||||||
|
|
||||||
flash[:notice] = t "users.new.terms accepted" if current_user.save
|
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.description = "" if current_user.description.nil?
|
||||||
current_user.creation_ip = request.remote_ip
|
current_user.creation_ip = request.remote_ip
|
||||||
current_user.languages = http_accept_language.user_preferred_languages
|
current_user.languages = http_accept_language.user_preferred_languages
|
||||||
current_user.terms_agreed = Time.now.getutc
|
current_user.terms_agreed = Time.now.utc
|
||||||
current_user.tou_agreed = Time.now.getutc
|
current_user.tou_agreed = Time.now.utc
|
||||||
current_user.terms_seen = true
|
current_user.terms_seen = true
|
||||||
|
|
||||||
if current_user.auth_uid.blank?
|
if current_user.auth_uid.blank?
|
||||||
|
|
|
@ -10,7 +10,7 @@ module ChangesetsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeset_details(changeset)
|
def changeset_details(changeset)
|
||||||
if changeset.closed_at > Time.now
|
if changeset.closed_at > Time.now.utc
|
||||||
action = :created
|
action = :created
|
||||||
time = time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")
|
time = time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")
|
||||||
title = l(changeset.created_at)
|
title = l(changeset.created_at)
|
||||||
|
|
|
@ -8,7 +8,7 @@ module UserBlocksHelper
|
||||||
if block.active?
|
if block.active?
|
||||||
# if the block hasn't expired yet show the date, if the user just needs to login show that
|
# 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.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))
|
t("user_blocks.helper.time_future_and_until_login_html", :time => friendly_date(block.ends_at))
|
||||||
else
|
else
|
||||||
t("user_blocks.helper.until_login")
|
t("user_blocks.helper.until_login")
|
||||||
|
|
|
@ -52,6 +52,6 @@ class AccessToken < OauthToken
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_authorized_at
|
def set_authorized_at
|
||||||
self.authorized_at = Time.now
|
self.authorized_at = Time.now.utc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,11 +71,11 @@ class Changeset < ApplicationRecord
|
||||||
# note that this may not be a hard limit - due to timing changes and
|
# note that this may not be a hard limit - due to timing changes and
|
||||||
# concurrency it is possible that some changesets may be slightly
|
# concurrency it is possible that some changesets may be slightly
|
||||||
# longer than strictly allowed or have slightly more changes in them.
|
# 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
|
end
|
||||||
|
|
||||||
def set_closed_time_now
|
def set_closed_time_now
|
||||||
self.closed_at = Time.now.getutc if is_open?
|
self.closed_at = Time.now.utc if is_open?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml(xml, create: false)
|
def self.from_xml(xml, create: false)
|
||||||
|
@ -95,7 +95,7 @@ class Changeset < ApplicationRecord
|
||||||
def self.from_xml_node(pt, create: false)
|
def self.from_xml_node(pt, create: false)
|
||||||
cs = Changeset.new
|
cs = Changeset.new
|
||||||
if create
|
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
|
# initial close time is 1h ahead, but will be increased on each
|
||||||
# modification.
|
# modification.
|
||||||
cs.closed_at = cs.created_at + IDLE_TIMEOUT
|
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)
|
self.closed_at = if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
|
||||||
created_at + MAX_TIME_OPEN
|
created_at + MAX_TIME_OPEN
|
||||||
else
|
else
|
||||||
Time.now.getutc + IDLE_TIMEOUT
|
Time.now.utc + IDLE_TIMEOUT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,7 +70,7 @@ class Issue < ApplicationRecord
|
||||||
event :resolve do
|
event :resolve do
|
||||||
transitions :from => :open, :to => :resolved
|
transitions :from => :open, :to => :resolved
|
||||||
after do
|
after do
|
||||||
self.resolved_at = Time.now.getutc
|
self.resolved_at = Time.now.utc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,7 @@ class Node < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def save_with_history!
|
def save_with_history!
|
||||||
t = Time.now.getutc
|
t = Time.now.utc
|
||||||
|
|
||||||
self.version += 1
|
self.version += 1
|
||||||
self.timestamp = t
|
self.timestamp = t
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Note < ApplicationRecord
|
||||||
# Close a note
|
# Close a note
|
||||||
def close
|
def close
|
||||||
self.status = "closed"
|
self.status = "closed"
|
||||||
self.closed_at = Time.now.getutc
|
self.closed_at = Time.now.utc
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,6 @@ class Oauth2Verifier < OauthToken
|
||||||
def generate_keys
|
def generate_keys
|
||||||
self.token = OAuth::Helper.generate_key(20)[0, 20]
|
self.token = OAuth::Helper.generate_key(20)[0, 20]
|
||||||
self.expires_at = 10.minutes.from_now
|
self.expires_at = 10.minutes.from_now
|
||||||
self.authorized_at = Time.now
|
self.authorized_at = Time.now.utc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ class OauthToken < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def invalidate!
|
def invalidate!
|
||||||
update(:invalidated_at => Time.now)
|
update(:invalidated_at => Time.now.utc)
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorized?
|
def authorized?
|
||||||
|
|
|
@ -263,7 +263,7 @@ class Relation < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def save_with_history!
|
def save_with_history!
|
||||||
t = Time.now.getutc
|
t = Time.now.utc
|
||||||
|
|
||||||
self.version += 1
|
self.version += 1
|
||||||
self.timestamp = t
|
self.timestamp = t
|
||||||
|
|
|
@ -42,7 +42,7 @@ class RequestToken < OauthToken
|
||||||
return false if authorized?
|
return false if authorized?
|
||||||
|
|
||||||
self.user = user
|
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?
|
self.verifier = OAuth::Helper.generate_key(20)[0, 20] unless oauth10?
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ class UserBlock < ApplicationRecord
|
||||||
##
|
##
|
||||||
# scope to match active blocks
|
# scope to match active blocks
|
||||||
def self.active
|
def self.active
|
||||||
where("needs_view or ends_at > ?", Time.now.getutc)
|
where("needs_view or ends_at > ?", Time.now.utc)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -50,7 +50,7 @@ class UserBlock < ApplicationRecord
|
||||||
# returns true if the block is currently active (i.e: the user can't
|
# returns true if the block is currently active (i.e: the user can't
|
||||||
# use the API).
|
# use the API).
|
||||||
def active?
|
def active?
|
||||||
needs_view || ends_at > Time.now.getutc
|
needs_view || ends_at > Time.now.utc
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -65,7 +65,7 @@ class UserBlock < ApplicationRecord
|
||||||
# is the user object who is revoking the ban.
|
# is the user object who is revoking the ban.
|
||||||
def revoke!(revoker)
|
def revoke!(revoker)
|
||||||
update(
|
update(
|
||||||
:ends_at => Time.now.getutc,
|
:ends_at => Time.now.utc,
|
||||||
:revoker_id => revoker.id,
|
:revoker_id => revoker.id,
|
||||||
:needs_view => false
|
:needs_view => false
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UserToken < ApplicationRecord
|
||||||
after_initialize :set_defaults
|
after_initialize :set_defaults
|
||||||
|
|
||||||
def expired?
|
def expired?
|
||||||
expiry < Time.now
|
expiry < Time.now.utc
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -227,7 +227,7 @@ class Way < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def save_with_history!
|
def save_with_history!
|
||||||
t = Time.now.getutc
|
t = Time.now.utc
|
||||||
|
|
||||||
self.version += 1
|
self.version += 1
|
||||||
self.timestamp = t
|
self.timestamp = t
|
||||||
|
|
|
@ -22,7 +22,7 @@ module GPX
|
||||||
elsif reader.name == "ele" && point
|
elsif reader.name == "ele" && point
|
||||||
point.altitude = reader.read_string.to_f
|
point.altitude = reader.read_string.to_f
|
||||||
elsif reader.name == "time" && point
|
elsif reader.name == "time" && point
|
||||||
point.timestamp = Time.parse(reader.read_string)
|
point.timestamp = Time.parse(reader.read_string).utc
|
||||||
end
|
end
|
||||||
when XML::Reader::TYPE_END_ELEMENT
|
when XML::Reader::TYPE_END_ELEMENT
|
||||||
if reader.name == "trkpt" && point && point.valid?
|
if reader.name == "trkpt" && point && point.valid?
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), "..", "config", "environment")
|
require File.join(File.dirname(__FILE__), "..", "config", "environment")
|
||||||
|
|
||||||
start_time = Time.now
|
start_time = Time.now.utc
|
||||||
|
|
||||||
puts "<html>"
|
puts "<html>"
|
||||||
puts "<head>"
|
puts "<head>"
|
||||||
|
@ -87,7 +87,7 @@ rescue StandardError => e
|
||||||
puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
|
puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
|
||||||
end
|
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 "</body>"
|
||||||
puts "</html>"
|
puts "</html>"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ require "generator"
|
||||||
addresses = User.count(
|
addresses = User.count(
|
||||||
:conditions => {
|
:conditions => {
|
||||||
:status => %w[suspended deleted],
|
: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
|
:group => :creation_ip
|
||||||
)
|
)
|
||||||
|
|
|
@ -214,7 +214,7 @@ module Api
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# Try again, after agreement with the terms
|
# Try again, after agreement with the terms
|
||||||
user.terms_agreed = Time.now
|
user.terms_agreed = Time.now.utc
|
||||||
user.save!
|
user.save!
|
||||||
|
|
||||||
assert_difference "ChangesetComment.count", 1 do
|
assert_difference "ChangesetComment.count", 1 do
|
||||||
|
@ -237,7 +237,7 @@ module Api
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
||||||
# Try again, after agreement with the terms
|
# Try again, after agreement with the terms
|
||||||
user.terms_agreed = Time.now
|
user.terms_agreed = Time.now.utc
|
||||||
user.save!
|
user.save!
|
||||||
|
|
||||||
assert_difference "ChangesetComment.count", 1 do
|
assert_difference "ChangesetComment.count", 1 do
|
||||||
|
|
|
@ -206,7 +206,7 @@ module Api
|
||||||
# test that it really is closed now
|
# test that it really is closed now
|
||||||
cs = Changeset.find(changeset.id)
|
cs = Changeset.find(changeset.id)
|
||||||
assert_not(cs.is_open?,
|
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
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -345,7 +345,7 @@ module Api
|
||||||
end
|
end
|
||||||
assert_response :gone
|
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
|
assert_no_difference "NoteComment.count" do
|
||||||
post comment_note_path(:id => closed_note_with_comment, :text => "This is an additional comment"), :headers => auth_header
|
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
|
post close_note_path(:id => hidden_note_with_comment), :headers => auth_header
|
||||||
assert_response :gone
|
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
|
post close_note_path(:id => closed_note_with_comment), :headers => auth_header
|
||||||
assert_response :conflict
|
assert_response :conflict
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reopen_success
|
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)
|
user = create(:user)
|
||||||
|
|
||||||
post reopen_note_path(:id => closed_note_with_comment, :text => "This is a reopen comment", :format => "json")
|
post reopen_note_path(:id => closed_note_with_comment, :text => "This is a reopen comment", :format => "json")
|
||||||
|
@ -748,8 +748,8 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_closed
|
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.utc - 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 - 100.days)
|
||||||
create(:note_with_comments, :status => "hidden")
|
create(:note_with_comments, :status => "hidden")
|
||||||
create(:note_with_comments)
|
create(:note_with_comments)
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
def test_read_closed_note
|
def test_read_closed_note
|
||||||
user = create(:user)
|
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)
|
create(:note_comment, :event => "closed", :note => note, :author => user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
|
||||||
m = Message.last
|
m = Message.last
|
||||||
assert_equal user.id, m.from_user_id
|
assert_equal user.id, m.from_user_id
|
||||||
assert_equal recipient_user.id, m.to_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", m.title
|
||||||
assert_equal "Test message body", m.body
|
assert_equal "Test message body", m.body
|
||||||
assert_equal "markdown", m.body_format
|
assert_equal "markdown", m.body_format
|
||||||
|
|
|
@ -240,9 +240,9 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
||||||
assert_redirected_to user_block_path(:id => id)
|
assert_redirected_to user_block_path(:id => id)
|
||||||
assert_equal "Created a block on user #{target_user.display_name}.", flash[:notice]
|
assert_equal "Created a block on user #{target_user.display_name}.", flash[:notice]
|
||||||
b = UserBlock.find(id)
|
b = UserBlock.find(id)
|
||||||
assert_in_delta Time.now, b.created_at, 1
|
assert_in_delta Time.now.utc, b.created_at, 1
|
||||||
assert_in_delta Time.now, b.updated_at, 1
|
assert_in_delta Time.now.utc, b.updated_at, 1
|
||||||
assert_in_delta Time.now + 12.hours, b.ends_at, 1
|
assert_in_delta Time.now.utc + 12.hours, b.ends_at, 1
|
||||||
assert_not b.needs_view
|
assert_not b.needs_view
|
||||||
assert_equal "Vandalism", b.reason
|
assert_equal "Vandalism", b.reason
|
||||||
assert_equal "markdown", b.reason_format
|
assert_equal "markdown", b.reason_format
|
||||||
|
@ -311,7 +311,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
||||||
assert_redirected_to user_block_path(active_block)
|
assert_redirected_to user_block_path(active_block)
|
||||||
assert_equal "Block updated.", flash[:notice]
|
assert_equal "Block updated.", flash[:notice]
|
||||||
b = UserBlock.find(active_block.id)
|
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 b.needs_view
|
||||||
assert_equal "Vandalism", b.reason
|
assert_equal "Vandalism", b.reason
|
||||||
|
|
||||||
|
@ -356,13 +356,13 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "revoke"
|
assert_template "revoke"
|
||||||
b = UserBlock.find(active_block.id)
|
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
|
# Check that revoking a block works using POST
|
||||||
post revoke_user_block_path(:id => active_block, :confirm => true)
|
post revoke_user_block_path(:id => active_block, :confirm => true)
|
||||||
assert_redirected_to user_block_path(active_block)
|
assert_redirected_to user_block_path(active_block)
|
||||||
b = UserBlock.find(active_block.id)
|
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
|
# We should get an error if the block doesn't exist
|
||||||
get revoke_user_block_path(:id => 99999)
|
get revoke_user_block_path(:id => 99999)
|
||||||
|
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
||||||
factory :message do
|
factory :message do
|
||||||
sequence(:title) { |n| "Message #{n}" }
|
sequence(:title) { |n| "Message #{n}" }
|
||||||
sequence(:body) { |n| "Body text for message #{n}" }
|
sequence(:body) { |n| "Body text for message #{n}" }
|
||||||
sent_on { Time.now }
|
sent_on { Time.now.utc }
|
||||||
|
|
||||||
association :sender, :factory => :user
|
association :sender, :factory => :user
|
||||||
association :recipient, :factory => :user
|
association :recipient, :factory => :user
|
||||||
|
|
|
@ -6,7 +6,7 @@ FactoryBot.define do
|
||||||
changeset
|
changeset
|
||||||
|
|
||||||
visible { true }
|
visible { true }
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
|
|
||||||
trait :deleted do
|
trait :deleted do
|
||||||
|
|
|
@ -7,7 +7,7 @@ FactoryBot.define do
|
||||||
association :current_node, :factory => :node
|
association :current_node, :factory => :node
|
||||||
|
|
||||||
visible { true }
|
visible { true }
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :old_relation do
|
factory :old_relation do
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
visible { true }
|
visible { true }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :old_way do
|
factory :old_way do
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
visible { true }
|
visible { true }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :relation do
|
factory :relation do
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
visible { true }
|
visible { true }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ FactoryBot.define do
|
||||||
latitude { 1 * GeoRecord::SCALE }
|
latitude { 1 * GeoRecord::SCALE }
|
||||||
longitude { 1 * GeoRecord::SCALE }
|
longitude { 1 * GeoRecord::SCALE }
|
||||||
# tile { QuadTile.tile_for_point(1,1) }
|
# tile { QuadTile.tile_for_point(1,1) }
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
|
|
||||||
trace
|
trace
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
user
|
user
|
||||||
|
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
inserted { true }
|
inserted { true }
|
||||||
size { 10 }
|
size { 10 }
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
terms_seen { true }
|
terms_seen { true }
|
||||||
terms_agreed { Time.now.getutc }
|
terms_agreed { Time.now.utc }
|
||||||
data_public { true }
|
data_public { true }
|
||||||
|
|
||||||
trait :with_home_location do
|
trait :with_home_location do
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :user_block do
|
factory :user_block do
|
||||||
sequence(:reason) { |n| "User Block #{n}" }
|
sequence(:reason) { |n| "User Block #{n}" }
|
||||||
ends_at { Time.now + 1.day }
|
ends_at { Time.now.utc + 1.day }
|
||||||
|
|
||||||
user
|
user
|
||||||
association :creator, :factory => :moderator_user
|
association :creator, :factory => :moderator_user
|
||||||
|
@ -11,7 +11,7 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :expired do
|
trait :expired do
|
||||||
ends_at { Time.now - 1.day }
|
ends_at { Time.now.utc - 1.day }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :revoked do
|
trait :revoked do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :way do
|
factory :way do
|
||||||
timestamp { Time.now }
|
timestamp { Time.now.utc }
|
||||||
visible { true }
|
visible { true }
|
||||||
version { 1 }
|
version { 1 }
|
||||||
|
|
||||||
|
|
|
@ -56,19 +56,19 @@ class ApplicationHelperTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_friendly_date
|
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
|
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
|
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
|
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
|
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
|
assert_match %r{^<span title=".*">4 months</span>$}, date
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ class UserBlocksHelperTest < ActionView::TestCase
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def test_block_status
|
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)
|
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)
|
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)
|
assert_match %r{^Ends in <span title=".*">about 1 hour</span>\.$}, block_status(block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
|
||||||
:user_id => blocked_user.id,
|
:user_id => blocked_user.id,
|
||||||
:creator_id => create(:moderator_user).id,
|
:creator_id => create(:moderator_user).id,
|
||||||
:reason => "testing",
|
: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")
|
get "/api/#{Settings.api_version}/user/details", :headers => basic_authorization_header(blocked_user.display_name, "test")
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
@ -29,7 +29,7 @@ class UserBlocksTest < ActionDispatch::IntegrationTest
|
||||||
:user_id => blocked_user.id,
|
:user_id => blocked_user.id,
|
||||||
:creator_id => moderator.id,
|
:creator_id => moderator.id,
|
||||||
:reason => "testing",
|
: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")
|
get "/api/#{Settings.api_version}/user/details", :headers => basic_authorization_header(blocked_user.display_name, "test")
|
||||||
assert_response :forbidden
|
assert_response :forbidden
|
||||||
|
|
|
@ -75,7 +75,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
from "from@example.com"
|
from "from@example.com"
|
||||||
to "to@example.com"
|
to "to@example.com"
|
||||||
subject "Test message"
|
subject "Test message"
|
||||||
date Time.now
|
date Time.now.utc
|
||||||
content_type "text/plain; charset=utf-8"
|
content_type "text/plain; charset=utf-8"
|
||||||
body "This is a test & a message"
|
body "This is a test & a message"
|
||||||
end
|
end
|
||||||
|
@ -95,7 +95,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
from "from@example.com"
|
from "from@example.com"
|
||||||
to "to@example.com"
|
to "to@example.com"
|
||||||
subject "Test message"
|
subject "Test message"
|
||||||
date Time.now
|
date Time.now.utc
|
||||||
content_type "text/html; charset=utf-8"
|
content_type "text/html; charset=utf-8"
|
||||||
body "<p>This is a <b>test</b> & a message</p>"
|
body "<p>This is a <b>test</b> & a message</p>"
|
||||||
end
|
end
|
||||||
|
@ -115,7 +115,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
from "from@example.com"
|
from "from@example.com"
|
||||||
to "to@example.com"
|
to "to@example.com"
|
||||||
subject "Test message"
|
subject "Test message"
|
||||||
date Time.now
|
date Time.now.utc
|
||||||
|
|
||||||
text_part do
|
text_part do
|
||||||
content_type "text/plain; charset=utf-8"
|
content_type "text/plain; charset=utf-8"
|
||||||
|
@ -139,7 +139,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
from "from@example.com"
|
from "from@example.com"
|
||||||
to "to@example.com"
|
to "to@example.com"
|
||||||
subject "Test message"
|
subject "Test message"
|
||||||
date Time.now
|
date Time.now.utc
|
||||||
|
|
||||||
html_part do
|
html_part do
|
||||||
content_type "text/html; charset=utf-8"
|
content_type "text/html; charset=utf-8"
|
||||||
|
@ -162,7 +162,7 @@ class MessageTest < ActiveSupport::TestCase
|
||||||
from "from@example.com"
|
from "from@example.com"
|
||||||
to "to@example.com"
|
to "to@example.com"
|
||||||
subject "[OpenStreetMap] Test message"
|
subject "[OpenStreetMap] Test message"
|
||||||
date Time.now
|
date Time.now.utc
|
||||||
content_type "text/plain; charset=utf-8"
|
content_type "text/plain; charset=utf-8"
|
||||||
body "This is a test & a message"
|
body "This is a test & a message"
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ class NoteTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reopen
|
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_equal "closed", note.status
|
||||||
assert_not_nil note.closed_at
|
assert_not_nil note.closed_at
|
||||||
note.reopen
|
note.reopen
|
||||||
|
@ -43,7 +43,7 @@ class NoteTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_closed?
|
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?
|
assert_not create(:note, :status => "open", :closed_at => nil).closed?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue