about summary refs log tree commit diff
path: root/spec/models/concerns/account_interactions_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/concerns/account_interactions_spec.rb')
-rw-r--r--spec/models/concerns/account_interactions_spec.rb201
1 files changed, 83 insertions, 118 deletions
diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb
index b5aecf6be..32e08d5f7 100644
--- a/spec/models/concerns/account_interactions_spec.rb
+++ b/spec/models/concerns/account_interactions_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'rails_helper'
 
 describe AccountInteractions do
@@ -14,20 +16,20 @@ describe AccountInteractions do
     context 'account with Follow' do
       it 'returns { target_account_id => { reblogs: true } }' do
         Fabricate(:follow, account: account, target_account: target_account)
-        is_expected.to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
+        expect(subject).to eq(target_account_id => { reblogs: true, notify: false, languages: nil })
       end
     end
 
     context 'account with Follow but with reblogs disabled' do
       it 'returns { target_account_id => { reblogs: false } }' do
         Fabricate(:follow, account: account, target_account: target_account, show_reblogs: false)
-        is_expected.to eq(target_account_id => { reblogs: false, notify: false, languages: nil })
+        expect(subject).to eq(target_account_id => { reblogs: false, notify: false, languages: nil })
       end
     end
 
     context 'account without Follow' do
       it 'returns {}' do
-        is_expected.to eq({})
+        expect(subject).to eq({})
       end
     end
   end
@@ -38,13 +40,13 @@ describe AccountInteractions do
     context 'account with Follow' do
       it 'returns { target_account_id => true }' do
         Fabricate(:follow, account: target_account, target_account: account)
-        is_expected.to eq(target_account_id => true)
+        expect(subject).to eq(target_account_id => true)
       end
     end
 
     context 'account without Follow' do
       it 'returns {}' do
-        is_expected.to eq({})
+        expect(subject).to eq({})
       end
     end
   end
@@ -55,13 +57,13 @@ describe AccountInteractions do
     context 'account with Block' do
       it 'returns { target_account_id => true }' do
         Fabricate(:block, account: account, target_account: target_account)
-        is_expected.to eq(target_account_id => true)
+        expect(subject).to eq(target_account_id => true)
       end
     end
 
     context 'account without Block' do
       it 'returns {}' do
-        is_expected.to eq({})
+        expect(subject).to eq({})
       end
     end
   end
@@ -78,7 +80,7 @@ describe AccountInteractions do
         let(:hide) { true }
 
         it 'returns { target_account_id => { notifications: true } }' do
-          is_expected.to eq(target_account_id => { notifications: true })
+          expect(subject).to eq(target_account_id => { notifications: true })
         end
       end
 
@@ -86,14 +88,14 @@ describe AccountInteractions do
         let(:hide) { false }
 
         it 'returns { target_account_id => { notifications: false } }' do
-          is_expected.to eq(target_account_id => { notifications: false })
+          expect(subject).to eq(target_account_id => { notifications: false })
         end
       end
     end
 
     context 'account without Mute' do
       it 'returns {}' do
-        is_expected.to eq({})
+        expect(subject).to eq({})
       end
     end
   end
@@ -101,7 +103,7 @@ describe AccountInteractions do
   describe '#follow!' do
     it 'creates and returns Follow' do
       expect do
-        expect(account.follow!(target_account)).to be_kind_of Follow
+        expect(account.follow!(target_account)).to be_a Follow
       end.to change { account.following.count }.by 1
     end
   end
@@ -109,7 +111,7 @@ describe AccountInteractions do
   describe '#block' do
     it 'creates and returns Block' do
       expect do
-        expect(account.block!(target_account)).to be_kind_of Block
+        expect(account.block!(target_account)).to be_a Block
       end.to change { account.block_relationships.count }.by 1
     end
   end
@@ -123,7 +125,7 @@ describe AccountInteractions do
 
         it 'creates Mute, and returns Mute' do
           expect do
-            expect(subject).to be_kind_of Mute
+            expect(subject).to be_a Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -133,7 +135,7 @@ describe AccountInteractions do
 
         it 'creates Mute, and returns Mute' do
           expect do
-            expect(subject).to be_kind_of Mute
+            expect(subject).to be_a Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -143,7 +145,7 @@ describe AccountInteractions do
 
         it 'creates Mute, and returns Mute' do
           expect do
-            expect(subject).to be_kind_of Mute
+            expect(subject).to be_a Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -156,8 +158,8 @@ describe AccountInteractions do
 
       let(:mute) do
         Fabricate(:mute,
-                  account:            account,
-                  target_account:     target_account,
+                  account: account,
+                  target_account: target_account,
                   hide_notifications: hide_notifications)
       end
 
@@ -169,8 +171,8 @@ describe AccountInteractions do
 
           it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(subject).to be_kind_of Mute
-            end.not_to change { mute.reload.hide_notifications? }.from(true)
+              expect(subject).to be_a Mute
+            end.to_not change { mute.reload.hide_notifications? }.from(true)
           end
         end
 
@@ -179,7 +181,7 @@ describe AccountInteractions do
 
           it 'returns Mute, and updates mute.hide_notifications false' do
             expect do
-              expect(subject).to be_kind_of Mute
+              expect(subject).to be_a Mute
             end.to change { mute.reload.hide_notifications? }.from(true).to(false)
           end
         end
@@ -189,8 +191,8 @@ describe AccountInteractions do
 
           it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(subject).to be_kind_of Mute
-            end.not_to change { mute.reload.hide_notifications? }.from(true)
+              expect(subject).to be_a Mute
+            end.to_not change { mute.reload.hide_notifications? }.from(true)
           end
         end
       end
@@ -203,7 +205,7 @@ describe AccountInteractions do
 
           it 'returns Mute, and updates mute.hide_notifications true' do
             expect do
-              expect(subject).to be_kind_of Mute
+              expect(subject).to be_a Mute
             end.to change { mute.reload.hide_notifications? }.from(false).to(true)
           end
         end
@@ -213,8 +215,8 @@ describe AccountInteractions do
 
           it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(subject).to be_kind_of Mute
-            end.not_to change { mute.reload.hide_notifications? }.from(false)
+              expect(subject).to be_a Mute
+            end.to_not change { mute.reload.hide_notifications? }.from(false)
           end
         end
 
@@ -223,7 +225,7 @@ describe AccountInteractions do
 
           it 'returns Mute, and updates mute.hide_notifications true' do
             expect do
-              expect(subject).to be_kind_of Mute
+              expect(subject).to be_a Mute
             end.to change { mute.reload.hide_notifications? }.from(false).to(true)
           end
         end
@@ -232,25 +234,25 @@ describe AccountInteractions do
   end
 
   describe '#mute_conversation!' do
-    let(:conversation) { Fabricate(:conversation) }
-
     subject { account.mute_conversation!(conversation) }
 
+    let(:conversation) { Fabricate(:conversation) }
+
     it 'creates and returns ConversationMute' do
       expect do
-        is_expected.to be_kind_of ConversationMute
+        expect(subject).to be_a ConversationMute
       end.to change { account.conversation_mutes.count }.by 1
     end
   end
 
   describe '#block_domain!' do
-    let(:domain) { 'example.com' }
-
     subject { account.block_domain!(domain) }
 
+    let(:domain) { 'example.com' }
+
     it 'creates and returns AccountDomainBlock' do
       expect do
-        is_expected.to be_kind_of AccountDomainBlock
+        expect(subject).to be_a AccountDomainBlock
       end.to change { account.domain_blocks.count }.by 1
     end
   end
@@ -261,14 +263,14 @@ describe AccountInteractions do
     context 'following target_account' do
       it 'returns destroyed Follow' do
         account.active_relationships.create(target_account: target_account)
-        is_expected.to be_kind_of Follow
+        expect(subject).to be_a Follow
         expect(subject).to be_destroyed
       end
     end
 
     context 'not following target_account' do
       it 'returns nil' do
-        is_expected.to be_nil
+        expect(subject).to be_nil
       end
     end
   end
@@ -279,14 +281,14 @@ describe AccountInteractions do
     context 'blocking target_account' do
       it 'returns destroyed Block' do
         account.block_relationships.create(target_account: target_account)
-        is_expected.to be_kind_of Block
+        expect(subject).to be_a Block
         expect(subject).to be_destroyed
       end
     end
 
     context 'not blocking target_account' do
       it 'returns nil' do
-        is_expected.to be_nil
+        expect(subject).to be_nil
       end
     end
   end
@@ -297,55 +299,55 @@ describe AccountInteractions do
     context 'muting target_account' do
       it 'returns destroyed Mute' do
         account.mute_relationships.create(target_account: target_account)
-        is_expected.to be_kind_of Mute
+        expect(subject).to be_a Mute
         expect(subject).to be_destroyed
       end
     end
 
     context 'not muting target_account' do
       it 'returns nil' do
-        is_expected.to be_nil
+        expect(subject).to be_nil
       end
     end
   end
 
   describe '#unmute_conversation!' do
-    let(:conversation) { Fabricate(:conversation) }
-
     subject { account.unmute_conversation!(conversation) }
 
+    let(:conversation) { Fabricate(:conversation) }
+
     context 'muting the conversation' do
       it 'returns destroyed ConversationMute' do
         account.conversation_mutes.create(conversation: conversation)
-        is_expected.to be_kind_of ConversationMute
+        expect(subject).to be_a ConversationMute
         expect(subject).to be_destroyed
       end
     end
 
     context 'not muting the conversation' do
       it 'returns nil' do
-        is_expected.to be nil
+        expect(subject).to be_nil
       end
     end
   end
 
   describe '#unblock_domain!' do
-    let(:domain) { 'example.com' }
-
     subject { account.unblock_domain!(domain) }
 
+    let(:domain) { 'example.com' }
+
     context 'blocking the domain' do
       it 'returns destroyed AccountDomainBlock' do
         account_domain_block = Fabricate(:account_domain_block, domain: domain)
         account.domain_blocks << account_domain_block
-        is_expected.to be_kind_of AccountDomainBlock
+        expect(subject).to be_a AccountDomainBlock
         expect(subject).to be_destroyed
       end
     end
 
     context 'unblocking the domain' do
       it 'returns nil' do
-        is_expected.to be_nil
+        expect(subject).to be_nil
       end
     end
   end
@@ -356,13 +358,13 @@ describe AccountInteractions do
     context 'following target_account' do
       it 'returns true' do
         account.active_relationships.create(target_account: target_account)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not following target_account' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
@@ -373,13 +375,13 @@ describe AccountInteractions do
     context 'followed by target_account' do
       it 'returns true' do
         account.passive_relationships.create(account: target_account)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not followed by target_account' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
@@ -390,33 +392,33 @@ describe AccountInteractions do
     context 'blocking target_account' do
       it 'returns true' do
         account.block_relationships.create(target_account: target_account)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not blocking target_account' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#domain_blocking?' do
-    let(:domain)               { 'example.com' }
-
     subject { account.domain_blocking?(domain) }
 
+    let(:domain) { 'example.com' }
+
     context 'blocking the domain' do
-      it' returns true' do
+      it 'returns true' do
         account_domain_block = Fabricate(:account_domain_block, domain: domain)
         account.domain_blocks << account_domain_block
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not blocking the domain' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
@@ -428,49 +430,49 @@ describe AccountInteractions do
       it 'returns true' do
         mute = Fabricate(:mute, account: account, target_account: target_account)
         account.mute_relationships << mute
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not muting target_account' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#muting_conversation?' do
-    let(:conversation) { Fabricate(:conversation) }
-
     subject { account.muting_conversation?(conversation) }
 
+    let(:conversation) { Fabricate(:conversation) }
+
     context 'muting the conversation' do
       it 'returns true' do
         account.conversation_mutes.create(conversation: conversation)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not muting the conversation' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#muting_notifications?' do
+    subject { account.muting_notifications?(target_account) }
+
     before do
       mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide)
       account.mute_relationships << mute
     end
 
-    subject { account.muting_notifications?(target_account) }
-
     context 'muting notifications of target_account' do
       let(:hide) { true }
 
       it 'returns true' do
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
@@ -478,7 +480,7 @@ describe AccountInteractions do
       let(:hide) { false }
 
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
@@ -489,27 +491,27 @@ describe AccountInteractions do
     context 'requested by target_account' do
       it 'returns true' do
         Fabricate(:follow_request, account: account, target_account: target_account)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not requested by target_account' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#favourited?' do
-    let(:status) { Fabricate(:status, account: account, favourites: favourites) }
-
     subject { account.favourited?(status) }
 
+    let(:status) { Fabricate(:status, account: account, favourites: favourites) }
+
     context 'favorited' do
       let(:favourites) { [Fabricate(:favourite, account: account)] }
 
       it 'returns true' do
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
@@ -517,21 +519,21 @@ describe AccountInteractions do
       let(:favourites) { [] }
 
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#reblogged?' do
-    let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
-
     subject { account.reblogged?(status) }
 
+    let(:status) { Fabricate(:status, account: account, reblogs: reblogs) }
+
     context 'reblogged' do
       let(:reblogs) { [Fabricate(:status, account: account)] }
 
       it 'returns true' do
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
@@ -539,26 +541,26 @@ describe AccountInteractions do
       let(:reblogs) { [] }
 
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
 
   describe '#pinned?' do
-    let(:status) { Fabricate(:status, account: account) }
-
     subject { account.pinned?(status) }
 
+    let(:status) { Fabricate(:status, account: account) }
+
     context 'pinned' do
       it 'returns true' do
         Fabricate(:status_pin, account: account, status: status)
-        is_expected.to be true
+        expect(subject).to be true
       end
     end
 
     context 'not pinned' do
       it 'returns false' do
-        is_expected.to be false
+        expect(subject).to be false
       end
     end
   end
@@ -688,41 +690,4 @@ describe AccountInteractions do
       end
     end
   end
-
-  describe 'ignoring reblogs from an account' do
-    before do
-      @me = Fabricate(:account, username: 'Me')
-      @you = Fabricate(:account, username: 'You')
-    end
-
-    context 'with the reblogs option unspecified' do
-      before do
-        @me.follow!(@you)
-      end
-
-      it 'defaults to showing reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(false)
-      end
-    end
-
-    context 'with the reblogs option set to false' do
-      before do
-        @me.follow!(@you, reblogs: false)
-      end
-
-      it 'does mute reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(true)
-      end
-    end
-
-    context 'with the reblogs option set to true' do
-      before do
-        @me.follow!(@you, reblogs: true)
-      end
-
-      it 'does not mute reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(false)
-      end
-    end
-  end
 end