]> cat aescling's git repositories - mastodon.git/commitdiff
Implement tests for Account#refresh! (#5601)
authorysksn <bluewhale1982@gmail.com>
Mon, 6 Nov 2017 04:54:41 +0000 (13:54 +0900)
committerYamagishi Kazutoshi <ykzts@desire.sh>
Mon, 6 Nov 2017 04:54:41 +0000 (13:54 +0900)
spec/models/account_spec.rb

index 5165082d1484d5d90551e5b69d20220ea88d24b0..9c1492c90e9b2fc86ecb806dd09542e1850ea139 100644 (file)
@@ -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')