changes Time.now to Time.current

This commit is contained in:
Juanjo Bazán
2016-12-27 18:26:03 +01:00
parent 5ec12e4b5b
commit ab61d94d2d
5 changed files with 12 additions and 12 deletions

View File

@@ -10,21 +10,21 @@ class Poll < ActiveRecord::Base
validate :date_range validate :date_range
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.now, Time.now) } scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) }
scope :incoming, -> { where('? < starts_at', Time.now) } scope :incoming, -> { where('? < starts_at', Time.current) }
scope :expired, -> { where('ends_at < ?', Time.now) } scope :expired, -> { where('ends_at < ?', Time.current) }
scope :sort_for_list, -> { order(:starts_at) } scope :sort_for_list, -> { order(:starts_at) }
def current?(timestamp = DateTime.now) def current?(timestamp = DateTime.current)
starts_at <= timestamp && timestamp <= ends_at starts_at <= timestamp && timestamp <= ends_at
end end
def incoming?(timestamp = DateTime.now) def incoming?(timestamp = DateTime.current)
timestamp < starts_at timestamp < starts_at
end end
def expired?(timestamp = DateTime.now) def expired?(timestamp = DateTime.current)
ends_at < timestamp ends_at < timestamp
end end

View File

@@ -49,8 +49,8 @@ class Signature < ActiveRecord::Base
user_params = { user_params = {
document_number: document_number, document_number: document_number,
created_from_signature: true, created_from_signature: true,
verified_at: Time.now, verified_at: Time.current,
erased_at: Time.now, erased_at: Time.current,
password: random_password, password: random_password,
terms_of_service: '1', terms_of_service: '1',
email: nil email: nil

View File

@@ -203,7 +203,7 @@ tags = Faker::Lorem.words(25)
responsible_name: Faker::Name.name, responsible_name: Faker::Name.name,
external_url: Faker::Internet.url, external_url: Faker::Internet.url,
description: description, description: description,
created_at: rand((Time.now - 1.week) .. Time.now), created_at: rand((Time.current - 1.week) .. Time.current),
tag_list: tags.sample(3).join(','), tag_list: tags.sample(3).join(','),
geozone: Geozone.reorder("RANDOM()").first, geozone: Geozone.reorder("RANDOM()").first,
terms_of_service: "1", terms_of_service: "1",
@@ -461,7 +461,7 @@ puts "Commenting Poll Questions"
author = User.reorder("RANDOM()").first author = User.reorder("RANDOM()").first
question = Poll::Question.reorder("RANDOM()").first question = Poll::Question.reorder("RANDOM()").first
Comment.create!(user: author, Comment.create!(user: author,
created_at: rand(question.created_at .. Time.now), created_at: rand(question.created_at .. Time.current),
commentable: question, commentable: question,
body: Faker::Lorem.sentence) body: Faker::Lorem.sentence)
end end

View File

@@ -310,7 +310,7 @@ FactoryGirl.define do
factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do
association :officer, factory: :poll_officer association :officer, factory: :poll_officer
association :booth_assignment, factory: :poll_booth_assignment association :booth_assignment, factory: :poll_booth_assignment
date Time.now.to_date date Time.current.to_date
end end
factory :poll_voter, class: 'Poll::Voter' do factory :poll_voter, class: 'Poll::Voter' do

View File

@@ -104,7 +104,7 @@ feature 'Residence' do
end end
scenario 'Error when trying to verify a deregistered account' do scenario 'Error when trying to verify a deregistered account' do
create(:user, document_number: '12345678Z', document_type: '1', erased_at: Time.now) create(:user, document_number: '12345678Z', document_type: '1', erased_at: Time.current)
login_as(create(:user)) login_as(create(:user))