Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Martin Lensment 2015-04-06 16:40:08 +03:00
commit cca934453b
16 changed files with 34 additions and 31 deletions

View file

@ -29,7 +29,7 @@ class Certificate < ActiveRecord::Base
@cached_status = SIGNED
if parsed_crt.not_before > Time.now.utc && parsed_crt.not_after < Time.now.utc
if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc
@cached_status = EXPIRED
end

View file

@ -81,9 +81,9 @@ class Contact < ActiveRecord::Base
end
def destroy_orphans
logger.info "#{Time.now.utc} - Destroying orphaned contacts\n"
logger.info "#{Time.zone.now.utc} - Destroying orphaned contacts\n"
count = find_orphans.destroy_all.count
logger.info "#{Time.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
end
end

View file

@ -49,7 +49,7 @@ class Domain < ActiveRecord::Base
before_create :set_validity_dates
before_save :touch_always_version
def touch_always_version
self.updated_at = Time.now
self.updated_at = Time.zone.now
end
after_save :manage_automatic_statuses
after_save :update_whois_body
@ -205,7 +205,7 @@ class Domain < ActiveRecord::Base
def set_validity_dates
self.registered_at = Time.zone.now
self.valid_from = Date.today
self.valid_from = Time.zone.now.to_date
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
end

View file

@ -92,7 +92,7 @@ class Epp::Domain < Domain
at[:name] = frame.css('name').text if new_record?
at[:registrar_id] = current_user.registrar.try(:id)
at[:registered_at] = Time.now if new_record?
at[:registered_at] = Time.zone.now if new_record?
period = frame.css('period').text
at[:period] = (period.to_i == 0) ? 1 : period.to_i
@ -593,7 +593,7 @@ class Epp::Domain < Domain
transaction do
kr = keyrelays.build(
pa_date: Time.now,
pa_date: Time.zone.now,
key_data_flags: parsed_frame.css('flags').text,
key_data_protocol: parsed_frame.css('protocol').text,
key_data_alg: parsed_frame.css('alg').text,
@ -632,7 +632,7 @@ class Epp::Domain < Domain
def validate_exp_dates(cur_exp_date)
begin
return if cur_exp_date.to_date == valid_to
return if cur_exp_date.to_date == valid_to.to_date
rescue
add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match'))
return

View file

@ -45,7 +45,7 @@ class Keyrelay < ActiveRecord::Base
end
def status
if Time.now > expiry
if Time.zone.now > expiry
return 'expired'
else
return 'pending'

View file

@ -12,7 +12,7 @@ class ZonefileSetting < ActiveRecord::Base
def self.generate_zonefile(origin)
filename = "#{origin}.zone"
STDOUT << "#{Time.now.utc} - Generating zonefile #{filename}\n"
STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n"
zf = ActiveRecord::Base.connection.execute(
"select generate_zonefile('#{origin}')"
@ -20,7 +20,7 @@ class ZonefileSetting < ActiveRecord::Base
File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
STDOUT << "#{Time.now.utc} - Successfully generated zonefile #{filename}\n"
STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n"
end
def to_s

View file

@ -1,7 +1,7 @@
xml.epp_head do
xml.greeting do
xml.svID 'EPP server (EIS)'
xml.svDate Time.now.utc.iso8601
xml.svDate Time.zone.now.utc.iso8601
xml.svcMenu do
xml.version '1.0'
xml.lang 'en'

View file

@ -1,6 +1,6 @@
# Be sure to restart your server when you modify settings.
app_name: .EE Registry
app_name: '.EE Registry'
zonefile_export_dir: 'export/zonefiles'
# Contact epp will not accept org value by default
@ -10,8 +10,8 @@ contact_org_enabled: 'false'
# You can use `rake secret` to generate a secure secret key.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
secret_key_base: please-change-it-you-can-generate-it-with-rake-secret
devise_secret: please-change-it-you-can-generate-it-with-rake-secret
secret_key_base: 'please-change-it-you-can-generate-it-with-rake-secret'
devise_secret: 'please-change-it-you-can-generate-it-with-rake-secret'
# Used by admin server, you can leave those empty for when running EPP server:
openssl_config_path: '/etc/ssl/openssl.cnf'

View file

@ -21,7 +21,7 @@ module Registry
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.time_zone = 'UTC' # NB! It should be defined, otherwise ActiveRecord usese other class.
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]

View file

@ -17,7 +17,7 @@ class PaperSession
class << self
attr_writer :session
def session
@session ||= Time.now.to_s(:db)
@session ||= Time.zone.now.to_s(:db)
end
end
end

View file

@ -56,7 +56,7 @@ namespace :import do
desc 'Import registrars'
task registrars: :environment do
start = Time.now.to_f
start = Time.zone.now.to_f
puts '-----> Importing registrars...'
registrars = []
@ -92,12 +92,12 @@ namespace :import do
Registrar.import registrars, validate: false
puts "-----> Imported #{count} new registrars in #{(Time.now.to_f - start).round(2)} seconds"
puts "-----> Imported #{count} new registrars in #{(Time.zone.now.to_f - start).round(2)} seconds"
end
desc 'Import contacts'
task contacts: :environment do
start = Time.now.to_f
start = Time.zone.now.to_f
puts '-----> Importing contacts...'
# 1;"RC";"born number" # not used
@ -183,12 +183,12 @@ namespace :import do
end
Contact.import contact_columns, contacts, validate: false
puts "-----> Imported #{count} new contacts in #{(Time.now.to_f - start).round(2)} seconds"
puts "-----> Imported #{count} new contacts in #{(Time.zone.now.to_f - start).round(2)} seconds"
end
desc 'Import domains'
task domains: :environment do
start = Time.now.to_f
start = Time.zone.now.to_f
puts '-----> Importing domains...'
domain_columns = %w(
@ -449,6 +449,6 @@ namespace :import do
x.save(validate: false)
end
puts "-----> Imported #{count} new domains in #{(Time.now.to_f - start).round(2)} seconds"
puts "-----> Imported #{count} new domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
end
end

View file

@ -140,7 +140,7 @@ describe 'EPP Contact', epp: true do
id.text.length.should == 8
# 5 seconds for what-ever weird lag reasons might happen
cr_date.text.to_time.should be_within(5).of(Time.now)
cr_date.text.to_time.should be_within(5).of(Time.zone.now)
end
it 'successfully saves custom code' do

View file

@ -308,7 +308,7 @@ describe 'EPP Domain', epp: true do
response = epp_plain_request(xml, :xml)
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Domain.first.valid_to.should == Date.today + 1.year
Domain.first.valid_to.should == 1.year.since.to_date
end
it 'does not create a domain with invalid period' do
@ -1682,7 +1682,7 @@ describe 'EPP Domain', epp: true do
### RENEW ###
it 'renews a domain' do
exp_date = (Date.today + 1.year)
exp_date = 1.year.since.to_date
xml = @epp_xml.domain.renew(
name: { value: domain.name },
curExpDate: { value: exp_date.to_s },
@ -1690,6 +1690,9 @@ describe 'EPP Domain', epp: true do
)
response = epp_plain_request(xml, :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
ex_date = response[:parsed].css('renData exDate').text
name = response[:parsed].css('renData name').text
ex_date.should == "#{(exp_date + 1.year)} 00:00:00 UTC"
@ -1709,7 +1712,7 @@ describe 'EPP Domain', epp: true do
end
it 'returns an error when period is invalid' do
exp_date = (Date.today + 1.year)
exp_date = (1.year.since.to_date)
xml = @epp_xml.domain.renew(
name: { value: domain.name },
@ -1718,8 +1721,8 @@ describe 'EPP Domain', epp: true do
)
response = epp_plain_request(xml, :xml)
response[:results][0][:result_code].should == '2004'
response[:results][0][:msg].should == 'Period must add up to 1, 2 or 3 years [period]'
response[:results][0][:result_code].should == '2004'
response[:results][0][:value].should == '4'
end

View file

@ -1,5 +1,5 @@
Fabricator(:keyrelay) do
pa_date { DateTime.now }
pa_date { Time.zone.now }
expiry_relative 'P1W'
key_data_public_key 'abc'
key_data_flags 0

View file

@ -62,7 +62,7 @@ describe Keyrelay do
end
it 'is in expired status' do
kr = Fabricate(:keyrelay, pa_date: DateTime.now - 2.weeks)
kr = Fabricate(:keyrelay, pa_date: Time.zone.now - 2.weeks)
expect(kr.status).to eq('expired')
end

View file

@ -7,7 +7,7 @@ class EppDoc
def start(example_count)
@output.puts '# EPP REQUEST - RESPONSE EXAMPLES'
@output.puts "GENERATED AT: #{Time.now} "
@output.puts "GENERATED AT: #{Time.zone.now} "
@output.puts "EXAMPLE COUNT: #{example_count.count} "
@output.puts "\n---\n\n"
end