about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-05-03 01:21:22 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-02 18:21:22 +0200
commit6f75c8451d5668cc1505b192f29cf2f0dda48f7e (patch)
treed24e2d263e8fb9ad61ec198d42f25c0425d9c380 /spec
parentb9b78549f362b63ebb788a570fb647c570af2249 (diff)
Fix subscription expiration condition (#2715)
* Fix subscription expiration condition

* dry and add spec
Diffstat (limited to 'spec')
-rw-r--r--spec/models/subscription_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/subscription_spec.rb b/spec/models/subscription_spec.rb
index 9cb3d41ce..11fd8fadc 100644
--- a/spec/models/subscription_spec.rb
+++ b/spec/models/subscription_spec.rb
@@ -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