Consider domains having current time at "expire_time" attribute expired

Fixes #238
This commit is contained in:
Artur Beljajev 2016-11-08 10:07:41 +02:00
parent aa29c781f6
commit 877e6999dc
2 changed files with 4 additions and 4 deletions

View file

@ -7,7 +7,7 @@ module Concerns::Domain::Expirable
class_methods do
def expired
where("#{attribute_alias(:expire_time)} < ?", Time.zone.now)
where("#{attribute_alias(:expire_time)} <= ?", Time.zone.now)
end
end
@ -16,7 +16,7 @@ module Concerns::Domain::Expirable
end
def expired?
expire_time.past?
expire_time <= Time.zone.now
end
def expirable?

View file

@ -15,7 +15,7 @@ RSpec.describe Domain, db: false do
end
it 'returns expired domains' do
expect(described_class.expired.ids).to eq([1])
expect(described_class.expired.ids).to eq([1, 2])
end
end
@ -53,7 +53,7 @@ RSpec.describe Domain, db: false do
context 'when :expire_time is now' do
let(:domain) { described_class.new(expire_time: Time.zone.parse('05.07.2010 00:00')) }
specify { expect(domain).to_not be_expired }
specify { expect(domain).to be_expired }
end
context 'when :expire_time is in the future' do