about summary refs log tree commit diff
path: root/spec/models/follow_request_spec.rb
diff options
context:
space:
mode:
authorysksn <bluewhale1982@gmail.com>2017-11-09 22:36:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-11-09 14:36:52 +0100
commit54b42901df938257ae660168958fffe58b1a0287 (patch)
treea5842b3b5cc335c22c1d4a1612d856838fe2b70f /spec/models/follow_request_spec.rb
parentd200e041fe50b5c9253991a8884791c75255d457 (diff)
Add and Remove tests for FollowRequest (#5622)
* Add a test for FollowRequest#authorize!

* Remove tests

There is no need to test
ActiveModel::Validations::ClassMethods#validates.

* Make an alias of destroy! as reject!

Instead of defining the method,
make an alias of destroy! as reject! because of reducing test.
Diffstat (limited to 'spec/models/follow_request_spec.rb')
-rw-r--r--spec/models/follow_request_spec.rb27
1 files changed, 9 insertions, 18 deletions
diff --git a/spec/models/follow_request_spec.rb b/spec/models/follow_request_spec.rb
index cc6f8ee62..1436501e9 100644
--- a/spec/models/follow_request_spec.rb
+++ b/spec/models/follow_request_spec.rb
@@ -1,25 +1,16 @@
 require 'rails_helper'
 
 RSpec.describe FollowRequest, type: :model do
-  describe '#authorize!'
-  describe '#reject!'
+  describe '#authorize!' do
+    let(:follow_request) { Fabricate(:follow_request, account: account, target_account: target_account) }
+    let(:account)        { Fabricate(:account) }
+    let(:target_account) { Fabricate(:account) }
 
-  describe 'validations' do
-    it 'has a valid fabricator' do
-      follow_request = Fabricate.build(:follow_request)
-      expect(follow_request).to be_valid
-    end
-
-    it 'is invalid without an account' do
-      follow_request = Fabricate.build(:follow_request, account: nil)
-      follow_request.valid?
-      expect(follow_request).to model_have_error_on_field(:account)
-    end
-
-    it 'is invalid without a target account' do
-      follow_request = Fabricate.build(:follow_request, target_account: nil)
-      follow_request.valid?
-      expect(follow_request).to model_have_error_on_field(:target_account)      
+    it 'calls Account#follow!, MergeWorker.perform_async, and #destroy!' do
+      expect(account).to        receive(:follow!).with(target_account)
+      expect(MergeWorker).to    receive(:perform_async).with(target_account.id, account.id)
+      expect(follow_request).to receive(:destroy!)
+      follow_request.authorize!
     end
   end
 end