Merge pull request #286 from internetee/various-improvements

Various improvements
This commit is contained in:
Timo Võhmar 2016-12-12 16:04:13 +02:00 committed by GitHub
commit d68abd90fa
4 changed files with 30 additions and 2 deletions

View file

@ -1,11 +1,19 @@
class DomainPresenter
delegate :name, :registrant_name, to: :domain
delegate :name, :registrant_name, :registrant_id, to: :domain
def initialize(domain:, view:)
@domain = domain
@view = view
end
def expire_time
view.l(domain.expire_time)
end
def expire_date
view.l(domain.expire_time, format: :date)
end
def on_hold_date
view.l(domain.on_hold_time, format: :date) if domain.on_hold_time
end

View file

@ -1 +0,0 @@
Registry::Application.config.autoload_paths += %W(#{Registry::Application.config.root}/app/validators/)

View file

@ -614,6 +614,7 @@ en:
delete: 'Delete'
are_you_sure: 'Are you sure?'
renew: 'Renew'
new: New
renew_domain: 'Renew domain'
cur_exp_date: 'curExpDate'
transfer: 'Transfer'
@ -952,3 +953,4 @@ en:
deleted: 'Deleted'
cant_match_version: 'Impossible match version with request'
user_not_authenticated: "user not authenticated"
actions: Actions

View file

@ -3,6 +3,24 @@ require 'rails_helper'
RSpec.describe DomainPresenter do
let(:presenter) { described_class.new(domain: domain, view: view) }
describe '#expire_time' do
let(:domain) { instance_double(Domain, expire_time: Time.zone.parse('05.07.2010')) }
it 'returns localized time' do
expect(view).to receive(:l).with(Time.zone.parse('05.07.2010')).and_return('expire time')
expect(presenter.expire_time).to eq('expire time')
end
end
describe '#expire_date' do
let(:domain) { instance_double(Domain, expire_time: Time.zone.parse('05.07.2010')) }
it 'returns localized date' do
expect(view).to receive(:l).with(Time.zone.parse('05.07.2010'), format: :date).and_return('expire date')
expect(presenter.expire_date).to eq('expire date')
end
end
describe '#on_hold_date' do
subject(:on_hold_date) { presenter.on_hold_date }
@ -100,6 +118,7 @@ RSpec.describe DomainPresenter do
domain_delegatable_attributes = %i(
name
registrant_name
registrant_id
)
domain_delegatable_attributes.each do |attribute_name|