2017-04-19 14:52:37 +03:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe AccountUnfollowController 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 18:58:49 +03:00
|
|
|
let(:service) { double }
|
2017-04-19 14:52:37 +03:00
|
|
|
|
2017-05-22 18:58:49 +03:00
|
|
|
subject { post :create, params: { account_username: alice.username } }
|
|
|
|
|
|
|
|
before do
|
2017-04-19 14:52:37 +03:00
|
|
|
allow(UnfollowService).to receive(:new).and_return(service)
|
|
|
|
allow(service).to receive(:call)
|
2017-05-22 18:58:49 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not create for user who is not signed in' do
|
|
|
|
subject
|
|
|
|
expect(UnfollowService).not_to receive(:new)
|
|
|
|
end
|
2017-04-19 14:52:37 +03:00
|
|
|
|
2017-05-22 18:58:49 +03:00
|
|
|
it 'redirects to account path' do
|
|
|
|
sign_in(user)
|
|
|
|
subject
|
2017-04-19 14:52:37 +03:00
|
|
|
|
|
|
|
expect(service).to have_received(:call).with(user.account, alice)
|
|
|
|
expect(response).to redirect_to(account_path(alice))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|