2017-04-19 14:52:37 +03:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe AccountFollowController do
|
|
|
|
render_views
|
2017-04-28 16:12:37 +03:00
|
|
|
|
2017-04-19 14:52:37 +03:00
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
|
|
|
|
|
|
|
describe 'POST #create' do
|
2017-05-22 17:29:48 +03:00
|
|
|
let(:service) { double }
|
2017-04-19 14:52:37 +03:00
|
|
|
|
2017-05-22 17:29:48 +03:00
|
|
|
subject { post :create, params: { account_username: alice.username } }
|
|
|
|
|
|
|
|
before do
|
2017-04-19 14:52:37 +03:00
|
|
|
allow(FollowService).to receive(:new).and_return(service)
|
|
|
|
allow(service).to receive(:call)
|
2017-05-22 17:29:48 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create for user who is not signed in' do
|
|
|
|
subject
|
|
|
|
expect(FollowService).not_to receive(:new)
|
|
|
|
end
|
2017-04-19 14:52:37 +03:00
|
|
|
|
2017-05-22 17:29:48 +03:00
|
|
|
it 'redirects to account path' do
|
|
|
|
sign_in(user)
|
|
|
|
subject
|
2017-04-19 14:52:37 +03:00
|
|
|
|
2020-03-08 16:17:39 +02:00
|
|
|
expect(service).to have_received(:call).with(user.account, alice, with_rate_limit: true)
|
2017-04-19 14:52:37 +03:00
|
|
|
expect(response).to redirect_to(account_path(alice))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|