]> cat aescling's git repositories - mastodon.git/commitdiff
Implement tests for Account#possibly_stale? (#5591)
authorysksn <bluewhale1982@gmail.com>
Sun, 5 Nov 2017 08:20:05 +0000 (17:20 +0900)
committerYamagishi Kazutoshi <ykzts@desire.sh>
Sun, 5 Nov 2017 08:20:05 +0000 (17:20 +0900)
spec/models/account_spec.rb

index aef0c3082175c45e5c9643d128206de8d1288a3a..2144bffee11e59192ebb64949060536da756f13e 100644 (file)
@@ -123,6 +123,34 @@ RSpec.describe Account, type: :model do
     end
   end
 
+  describe '#possibly_stale?' do
+    let(:account) { Fabricate(:account, last_webfingered_at: last_webfingered_at) }
+
+    context 'last_webfingered_at is nil' do
+      let(:last_webfingered_at) { nil }
+
+      it 'returns true' do
+        expect(account.possibly_stale?).to be true
+      end
+    end
+
+    context 'last_webfingered_at is more than 24 hours before' do
+      let(:last_webfingered_at) { 25.hours.ago }
+
+      it 'returns true' do
+        expect(account.possibly_stale?).to be true
+      end
+    end
+
+    context 'last_webfingered_at is less than 24 hours before' do
+      let(:last_webfingered_at) { 23.hours.ago }
+
+      it 'returns false' do
+        expect(account.possibly_stale?).to be false
+      end
+    end
+  end
+
   describe '#to_param' do
     it 'returns username' do
       account = Fabricate(:account, username: 'alice')