about summary refs log tree commit diff
path: root/spec/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-18 03:03:12 +0200
committerGitHub <noreply@github.com>2018-08-18 03:03:12 +0200
commit78fa926ed560e6a9738144bec7e152fa42104139 (patch)
tree77470dc0c731cf32e298a32d618d65f5dc5b3820 /spec/controllers
parentbf1bde5d6a8306284a0cce89eb8f492b8c9b7a67 (diff)
Add remote interaction dialog for toots (#8202)
* Add remote interaction dialog for toots

* Change AuthorizeFollow into AuthorizeInteraction, support statuses

* Update brakeman.ignore

* Adjust how interaction buttons are display on public pages

* Fix tests
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/authorize_interactions_controller_spec.rb (renamed from spec/controllers/authorize_follows_controller_spec.rb)31
-rw-r--r--spec/controllers/intents_controller_spec.rb2
2 files changed, 17 insertions, 16 deletions
diff --git a/spec/controllers/authorize_follows_controller_spec.rb b/spec/controllers/authorize_interactions_controller_spec.rb
index 52971c724..81fd9ceb7 100644
--- a/spec/controllers/authorize_follows_controller_spec.rb
+++ b/spec/controllers/authorize_interactions_controller_spec.rb
@@ -2,7 +2,7 @@
 
 require 'rails_helper'
 
-describe AuthorizeFollowsController do
+describe AuthorizeInteractionsController do
   render_views
 
   describe 'GET #show' do
@@ -39,19 +39,19 @@ describe AuthorizeFollowsController do
         expect(service).to have_received(:call).with('missing@hostname')
       end
 
-      it 'sets account from url' do
+      it 'sets resource from url' do
         account = Account.new
         service = double
-        allow(FetchRemoteAccountService).to receive(:new).and_return(service)
+        allow(ResolveURLService).to receive(:new).and_return(service)
         allow(service).to receive(:call).with('http://example.com').and_return(account)
 
         get :show, params: { acct: 'http://example.com' }
 
         expect(response).to have_http_status(200)
-        expect(assigns(:account)).to eq account
+        expect(assigns(:resource)).to eq account
       end
 
-      it 'sets account from acct uri' do
+      it 'sets resource from acct uri' do
         account = Account.new
         service = double
         allow(ResolveAccountService).to receive(:new).and_return(service)
@@ -60,7 +60,7 @@ describe AuthorizeFollowsController do
         get :show, params: { acct: 'acct:found@hostname' }
 
         expect(response).to have_http_status(200)
-        expect(assigns(:account)).to eq account
+        expect(assigns(:resource)).to eq account
       end
     end
   end
@@ -75,8 +75,8 @@ describe AuthorizeFollowsController do
     end
 
     describe 'when signed in' do
-      let(:user) { Fabricate(:user) }
-      let(:account) { Fabricate(:account, user: user) }
+      let!(:user) { Fabricate(:user) }
+      let!(:account) { user.account }
 
       before do
         sign_in(user)
@@ -84,25 +84,26 @@ describe AuthorizeFollowsController do
 
       it 'shows error when account not found' do
         service = double
-        allow(FollowService).to receive(:new).and_return(service)
-        allow(service).to receive(:call).with(account, 'user@hostname').and_return(nil)
+
+        allow(ResolveAccountService).to receive(:new).and_return(service)
+        allow(service).to receive(:call).with('user@hostname').and_return(nil)
 
         post :create, params: { acct: 'acct:user@hostname' }
 
-        expect(service).to have_received(:call).with(account, 'user@hostname')
         expect(response).to render_template(:error)
       end
 
       it 'follows account when found' do
         target_account = Fabricate(:account)
-        result_account = double(target_account: target_account)
         service = double
-        allow(FollowService).to receive(:new).and_return(service)
-        allow(service).to receive(:call).with(account, 'user@hostname').and_return(result_account)
+
+        allow(ResolveAccountService).to receive(:new).and_return(service)
+        allow(service).to receive(:call).with('user@hostname').and_return(target_account)
 
         post :create, params: { acct: 'acct:user@hostname' }
 
-        expect(service).to have_received(:call).with(account, 'user@hostname')
+        expect(service).to have_received(:call).with('user@hostname')
+        expect(account.following?(target_account)).to be true
         expect(response).to render_template(:success)
       end
     end
diff --git a/spec/controllers/intents_controller_spec.rb b/spec/controllers/intents_controller_spec.rb
index 3dde7f835..ddfd5ea36 100644
--- a/spec/controllers/intents_controller_spec.rb
+++ b/spec/controllers/intents_controller_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe IntentsController, type: :controller do
       context 'when host is follow' do
         let(:uri) { 'web+mastodon://follow?uri=test' }
 
-        it { is_expected.to redirect_to authorize_follow_path(acct: 'test') }
+        it { is_expected.to redirect_to authorize_interaction_path(uri: 'test') }
       end
 
       context 'when host is share' do