mirror of
https://github.com/tildeverse/lobsters
synced 2024-06-25 01:37:05 +00:00
rubocop: Rails/TimeZone, 339
Pretty strictly-worded warning about preventing bugs. I guess it doens't hurt to have timestamps saved as UTC instead of US/Central.
This commit is contained in:
parent
ccca17b045
commit
c004ffd6a0
|
@ -36,7 +36,7 @@ class CommentsController < ApplicationController
|
|||
(pc = Comment.where(:story_id => story.id,
|
||||
:user_id => @user.id,
|
||||
:parent_comment_id => comment.parent_comment_id).first)
|
||||
if (Time.now - pc.created_at) < 5.minutes && !@user.is_moderator?
|
||||
if (Time.current - pc.created_at) < 5.minutes && !@user.is_moderator?
|
||||
comment.errors.add(:comment, "^You have already posted a comment " <<
|
||||
"here recently.")
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ class LoginController < ApplicationController
|
|||
@title = "Reset Password"
|
||||
|
||||
if (m = params[:token].to_s.match(/^(\d+)-/)) &&
|
||||
(Time.now - Time.at(m[1].to_i)) < 24.hours
|
||||
(Time.current - Time.at.utc(m[1].to_i)) < 24.hours
|
||||
@reset_user = User.where(:password_reset_token => params[:token].to_s).first
|
||||
end
|
||||
|
||||
|
|
|
@ -68,6 +68,6 @@ private
|
|||
story_ids = @replies.pluck(:story_id).uniq
|
||||
ReadRibbon
|
||||
.where(user_id: @user.id, story_id: story_ids)
|
||||
.update_all(updated_at: Time.now)
|
||||
.update_all(updated_at: Time.current)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -146,7 +146,7 @@ module ApplicationHelper
|
|||
|
||||
def time_ago_in_words_label(time, options = {})
|
||||
ago = ""
|
||||
secs = (Time.now - time).to_i
|
||||
secs = (Time.current - time).to_i
|
||||
if secs <= 5
|
||||
ago = "just now"
|
||||
elsif secs < 60
|
||||
|
|
|
@ -327,7 +327,7 @@ class Comment < ActiveRecord::Base
|
|||
|
||||
def is_downvotable?
|
||||
if self.created_at && self.score > DOWNVOTABLE_MIN_SCORE
|
||||
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||
Time.current - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -338,7 +338,7 @@ class Comment < ActiveRecord::Base
|
|||
if self.is_moderated?
|
||||
return false
|
||||
else
|
||||
return (Time.now.to_i - (self.updated_at ? self.updated_at.to_i :
|
||||
return (Time.current.to_i - (self.updated_at ? self.updated_at.to_i :
|
||||
self.created_at.to_i) < (60 * MAX_EDIT_MINS))
|
||||
end
|
||||
else
|
||||
|
|
|
@ -14,7 +14,7 @@ class Hat < ActiveRecord::Base
|
|||
m.action = "Doffed hat \"#{self.hat}\": #{reason}"
|
||||
m.save!
|
||||
|
||||
self.doffed_at = Time.now
|
||||
self.doffed_at = Time.current
|
||||
self.save!
|
||||
end
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
return -((order * sign) + base +
|
||||
((self.created_at || Time.now).to_f / HOTNESS_WINDOW)).round(7)
|
||||
((self.created_at || Time.current).to_f / HOTNESS_WINDOW)).round(7)
|
||||
end
|
||||
|
||||
def can_be_seen_by_user?(user)
|
||||
|
@ -398,7 +398,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
def is_downvotable?
|
||||
if self.created_at && self.score >= DOWNVOTABLE_MIN_SCORE
|
||||
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||
Time.current - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||
else
|
||||
false
|
||||
end
|
||||
|
@ -411,7 +411,7 @@ class Story < ActiveRecord::Base
|
|||
if self.is_moderated?
|
||||
return false
|
||||
else
|
||||
return (Time.now.to_i - self.created_at.to_i < (60 * MAX_EDIT_MINS))
|
||||
return (Time.current.to_i - self.created_at.to_i < (60 * MAX_EDIT_MINS))
|
||||
end
|
||||
else
|
||||
return false
|
||||
|
@ -439,7 +439,7 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def is_unavailable=(what)
|
||||
self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ? Time.now : nil)
|
||||
self.unavailable_at = (what.to_i == 1 && !self.is_unavailable ? Time.current : nil)
|
||||
end
|
||||
|
||||
def is_undeletable_by_user?(user)
|
||||
|
@ -713,7 +713,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
def update_availability
|
||||
if self.is_unavailable && !self.unavailable_at
|
||||
self.unavailable_at = Time.now
|
||||
self.unavailable_at = Time.current
|
||||
elsif self.unavailable_at && !self.is_unavailable
|
||||
self.unavailable_at = nil
|
||||
end
|
||||
|
|
|
@ -168,7 +168,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def disable_invite_by_user_for_reason!(disabler, reason)
|
||||
User.transaction do
|
||||
self.disabled_invite_at = Time.now
|
||||
self.disabled_invite_at = Time.current
|
||||
self.disabled_invite_by_user_id = disabler.id
|
||||
self.disabled_invite_reason = reason
|
||||
self.save!
|
||||
|
@ -198,7 +198,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
def ban_by_user_for_reason!(banner, reason)
|
||||
User.transaction do
|
||||
self.banned_at = Time.now
|
||||
self.banned_at = Time.current
|
||||
self.banned_by_user_id = banner.id
|
||||
self.banned_reason = reason
|
||||
|
||||
|
@ -320,7 +320,7 @@ class User < ActiveRecord::Base
|
|||
self.session_token = nil
|
||||
self.check_session_token
|
||||
|
||||
self.deleted_at = Time.now
|
||||
self.deleted_at = Time.current
|
||||
self.save!
|
||||
end
|
||||
end
|
||||
|
@ -374,7 +374,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def initiate_password_reset_for_ip(ip)
|
||||
self.password_reset_token = "#{Time.now.to_i}-#{Utils.random_str(30)}"
|
||||
self.password_reset_token = "#{Time.current.to_i}-#{Utils.random_str(30)}"
|
||||
self.save!
|
||||
|
||||
PasswordReset.password_reset_link(self, ip).deliver_now
|
||||
|
@ -393,7 +393,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def is_new?
|
||||
Time.now - self.created_at <= NEW_USER_DAYS.days
|
||||
Time.current - self.created_at <= NEW_USER_DAYS.days
|
||||
end
|
||||
|
||||
def is_heavy_self_promoter?
|
||||
|
|
|
@ -139,7 +139,7 @@ Comment.where(
|
|||
false
|
||||
).order(:id).each do |c|
|
||||
# allow some time for newer comments to be edited before sending them out
|
||||
if (Time.now - (c.updated_at || c.created_at)) < 2.minutes
|
||||
if (Time.current - (c.updated_at || c.created_at)) < 2.minutes
|
||||
break
|
||||
end
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ describe User do
|
|||
end
|
||||
|
||||
it "shows a user is recent or not" do
|
||||
user = User.make!(:created_at => Time.now)
|
||||
u = User.make!(:created_at => Time.now - 8.days)
|
||||
user = User.make!(:created_at => Time.current)
|
||||
u = User.make!(:created_at => Time.current - 8.days)
|
||||
expect(user.is_new?).to be true
|
||||
expect(u.is_new?).to be false
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ User.blueprint(:banned) do
|
|||
password { "blah blah" }
|
||||
password_confirmation { object.password }
|
||||
username { "username#{sn}" }
|
||||
banned_at { Time.now }
|
||||
banned_at { Time.current }
|
||||
end
|
||||
|
||||
Tag.blueprint do
|
||||
|
|
Loading…
Reference in New Issue
Block a user