diff options
author | ysksn <bluewhale1982@gmail.com> | 2017-11-06 13:54:41 +0900 |
---|---|---|
committer | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-11-06 13:54:41 +0900 |
commit | d307ee79e9b2f783fbdc6fd2e174ec91c47e8e5e (patch) | |
tree | 614494fe93f0f75dd5e290e83b8f1e6b1a2cead8 | |
parent | cf01326cc130bc6255aab5ce1e961ff8810758ae (diff) |
Implement tests for Account#refresh! (#5601)
-rw-r--r-- | spec/models/account_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 5165082d1..9c1492c90 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -174,6 +174,33 @@ RSpec.describe Account, type: :model do end end + describe '#refresh!' do + let(:account) { Fabricate(:account, domain: domain) } + let(:acct) { account.acct } + + context 'domain is nil' do + let(:domain) { nil } + + it 'returns nil' do + expect(account.refresh!).to be_nil + end + + it 'calls not ResolveRemoteAccountService#call' do + expect_any_instance_of(ResolveRemoteAccountService).not_to receive(:call).with(acct) + account.refresh! + end + end + + context 'domain is present' do + let(:domain) { 'example.com' } + + it 'calls ResolveRemoteAccountService#call' do + expect_any_instance_of(ResolveRemoteAccountService).to receive(:call).with(acct).once + account.refresh! + end + end + end + describe '#to_param' do it 'returns username' do account = Fabricate(:account, username: 'alice') |