Merge pull request #1562 from bertocq/fix/time_always_with_zone

Always use Time with zone
This commit is contained in:
Juanjo Bazán
2017-05-24 10:25:35 +02:00
committed by GitHub
5 changed files with 10 additions and 10 deletions

View File

@@ -50,10 +50,10 @@ class Poll
if dob.blank?
nil
else
now = Time.now.utc.to_date
now = Time.current.to_date
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)
end
end
end
end
end

View File

@@ -407,7 +407,7 @@ tags = Faker::Lorem.words(10)
title: Faker::Lorem.sentence(3).truncate(60),
external_url: Faker::Internet.url,
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
created_at: rand((Time.now - 1.week) .. Time.now),
created_at: rand((Time.current - 1.week) .. Time.current),
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
unfeasibility_explanation: Faker::Lorem.paragraph,
valuation_finished: [false, true].sample,
@@ -436,7 +436,7 @@ budget = Budget.where(phase: "finished").last
title: Faker::Lorem.sentence(3).truncate(60),
external_url: Faker::Internet.url,
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
created_at: rand((Time.now - 1.week) .. Time.now),
created_at: rand((Time.current - 1.week) .. Time.current),
feasibility: "feasible",
valuation_finished: true,
selected: true,

View File

@@ -1,5 +1,5 @@
module Age
def self.in_years(dob, now = Time.now.utc.to_date)
def self.in_years(dob, now = Time.current.to_date)
return nil unless dob.present?
# reference: http://stackoverflow.com/questions/819263/get-persons-age-in-ruby#comment21200772_819263
now.year - dob.year - ((now.month > dob.month || (now.month == dob.month && now.day >= dob.day)) ? 0 : 1)

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
feature 'Votes' do
background do
@manuela = create(:user, verified_at: Time.now)
@manuela = create(:user, verified_at: Time.current)
end
feature 'Investments' do

View File

@@ -65,9 +65,9 @@ describe DirectMessage do
describe "today" do
it "should return direct messages created today" do
direct_message1 = create(:direct_message, created_at: Time.zone.now.beginning_of_day + 3.hours)
direct_message2 = create(:direct_message, created_at: Time.zone.now)
direct_message3 = create(:direct_message, created_at: Time.zone.now.end_of_day)
direct_message1 = create(:direct_message, created_at: Time.current.beginning_of_day + 3.hours)
direct_message2 = create(:direct_message, created_at: Time.current)
direct_message3 = create(:direct_message, created_at: Time.current.end_of_day)
expect(DirectMessage.today.count).to eq 3
end
@@ -82,4 +82,4 @@ describe DirectMessage do
end
end
end