Refactor domain expiration email

#186
This commit is contained in:
Artur Beljajev 2016-10-29 00:53:00 +03:00
parent 0cc3a53deb
commit f127716a39
5 changed files with 36 additions and 22 deletions

View file

@ -1,13 +1,10 @@
require 'rails_helper'
RSpec.describe DomainCron do
before :example do
Fabricate(:zonefile_setting, origin: 'ee')
@domain = Fabricate(:domain)
end
it 'should expire domains' do
Fabricate(:zonefile_setting, origin: 'ee')
@domain = Fabricate(:domain)
Setting.expire_warning_period = 1
Setting.redemption_grace_period = 1
@ -28,6 +25,9 @@ RSpec.describe DomainCron do
end
it 'should start redemption grace period' do
Fabricate(:zonefile_setting, origin: 'ee')
@domain = Fabricate(:domain)
old_valid_to = Time.zone.now - 10.days
@domain.valid_to = old_valid_to
@domain.statuses = [DomainStatus::EXPIRED]
@ -38,4 +38,15 @@ RSpec.describe DomainCron do
@domain.reload
@domain.statuses.include?(DomainStatus::EXPIRED).should == true
end
describe '::start_expire_period', db: false do
before :example do
travel_to Time.zone.parse('05.07.2010')
end
it 'logs start time' do
expect(Rails.logger).to receive(:info).with('Expiring domains')
described_class.start_expire_period
end
end
end