Fix subscription expiration condition (#2715)
* Fix subscription expiration condition * dry and add spec
This commit is contained in:
parent
b9b78549f3
commit
6f75c8451d
3 changed files with 20 additions and 3 deletions
|
@ -1,5 +1,19 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Subscription, type: :model do
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { Fabricate(:subscription, account: alice) }
|
||||
|
||||
describe '#expired?' do
|
||||
it 'return true when expires_at is past' do
|
||||
subject.expires_at = 2.days.ago
|
||||
expect(subject.expired?).to be true
|
||||
end
|
||||
|
||||
it 'return false when expires_at is future' do
|
||||
subject.expires_at = 2.days.from_now
|
||||
expect(subject.expired?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue