about summary refs log tree commit diff
path: root/spec/models/concerns/account_interactions_spec.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-05-03 17:23:44 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-05-03 17:23:44 -0500
commitc816701550d7cdb593371dc47d0b9430c78308b0 (patch)
treecc4417d14de20e69fd5f9a58d66f84af4a623329 /spec/models/concerns/account_interactions_spec.rb
parent3a47842223ff93d8c057f804809f1b111dfd6f76 (diff)
parenta7e71bbd08e089938fbf20ddef5768c2f3ee0702 (diff)
Merge remote-tracking branch 'origin/master' into gs-master
  Conflicts:
 	.travis.yml
 	Gemfile.lock
 	README.md
 	app/controllers/settings/follower_domains_controller.rb
 	app/controllers/statuses_controller.rb
 	app/javascript/mastodon/locales/ja.json
 	app/lib/feed_manager.rb
 	app/models/media_attachment.rb
 	app/models/mute.rb
 	app/models/status.rb
 	app/services/mute_service.rb
 	app/views/home/index.html.haml
 	app/views/stream_entries/_simple_status.html.haml
 	config/locales/ca.yml
 	config/locales/en.yml
 	config/locales/es.yml
 	config/locales/fr.yml
 	config/locales/nl.yml
 	config/locales/pl.yml
 	config/locales/pt-BR.yml
 	config/themes.yml
Diffstat (limited to 'spec/models/concerns/account_interactions_spec.rb')
-rw-r--r--spec/models/concerns/account_interactions_spec.rb62
1 files changed, 26 insertions, 36 deletions
diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb
index 95bf9561d..9c9b87daf 100644
--- a/spec/models/concerns/account_interactions_spec.rb
+++ b/spec/models/concerns/account_interactions_spec.rb
@@ -115,13 +115,15 @@ describe AccountInteractions do
   end
 
   describe '#mute!' do
+    subject { account.mute!(target_account, notifications: arg_notifications) }
+
     context 'Mute does not exist yet' do
       context 'arg :notifications is nil' do
         let(:arg_notifications) { nil }
 
-        it 'creates Mute, and returns nil' do
+        it 'creates Mute, and returns Mute' do
           expect do
-            expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
+            expect(subject).to be_kind_of Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -129,9 +131,9 @@ describe AccountInteractions do
       context 'arg :notifications is false' do
         let(:arg_notifications) { false }
 
-        it 'creates Mute, and returns nil' do
+        it 'creates Mute, and returns Mute' do
           expect do
-            expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
+            expect(subject).to be_kind_of Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -139,9 +141,9 @@ describe AccountInteractions do
       context 'arg :notifications is true' do
         let(:arg_notifications) { true }
 
-        it 'creates Mute, and returns nil' do
+        it 'creates Mute, and returns Mute' do
           expect do
-            expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
+            expect(subject).to be_kind_of Mute
           end.to change { account.mute_relationships.count }.by 1
         end
       end
@@ -165,36 +167,30 @@ describe AccountInteractions do
         context 'arg :notifications is nil' do
           let(:arg_notifications) { nil }
 
-          it 'returns nil without updating mute.hide_notifications' do
+          it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be true
-            end
+              expect(subject).to be_kind_of Mute
+            end.not_to change { mute.reload.hide_notifications? }.from(true)
           end
         end
 
         context 'arg :notifications is false' do
           let(:arg_notifications) { false }
 
-          it 'returns true, and updates mute.hide_notifications false' do
+          it 'returns Mute, and updates mute.hide_notifications false' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be true
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be false
-            end
+              expect(subject).to be_kind_of Mute
+            end.to change { mute.reload.hide_notifications? }.from(true).to(false)
           end
         end
 
         context 'arg :notifications is true' do
           let(:arg_notifications) { true }
 
-          it 'returns nil without updating mute.hide_notifications' do
+          it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be true
-            end
+              expect(subject).to be_kind_of Mute
+            end.not_to change { mute.reload.hide_notifications? }.from(true)
           end
         end
       end
@@ -205,36 +201,30 @@ describe AccountInteractions do
         context 'arg :notifications is nil' do
           let(:arg_notifications) { nil }
 
-          it 'returns true, and updates mute.hide_notifications true' do
+          it 'returns Mute, and updates mute.hide_notifications true' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be true
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be true
-            end
+              expect(subject).to be_kind_of Mute
+            end.to change { mute.reload.hide_notifications? }.from(false).to(true)
           end
         end
 
         context 'arg :notifications is false' do
           let(:arg_notifications) { false }
 
-          it 'returns nil without updating mute.hide_notifications' do
+          it 'returns Mute without updating mute.hide_notifications' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be nil
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be false
-            end
+              expect(subject).to be_kind_of Mute
+            end.not_to change { mute.reload.hide_notifications? }.from(false)
           end
         end
 
         context 'arg :notifications is true' do
           let(:arg_notifications) { true }
 
-          it 'returns true, and updates mute.hide_notifications true' do
+          it 'returns Mute, and updates mute.hide_notifications true' do
             expect do
-              expect(account.mute!(target_account, notifications: arg_notifications)).to be true
-              mute = account.mute_relationships.find_by(target_account: target_account)
-              expect(mute.hide_notifications?).to be true
-            end
+              expect(subject).to be_kind_of Mute
+            end.to change { mute.reload.hide_notifications? }.from(false).to(true)
           end
         end
       end