diff options
author | ysksn <bluewhale1982@gmail.com> | 2017-11-05 17:20:05 +0900 |
---|---|---|
committer | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-11-05 17:20:05 +0900 |
commit | 15c0f6ae56e31ced750fa0ae06bf39d72355a477 (patch) | |
tree | 4bf79e17cec3895ad0e3984d79286276376de697 /spec | |
parent | da3adc0a73abeb7655d7836f1d7a5cbf64f7762f (diff) |
Implement tests for Account#possibly_stale? (#5591)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/account_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index aef0c3082..2144bffee 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -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') |