2017-04-19 11:52:37 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe AccountUnfollowController do
|
|
|
|
render_views
|
2017-04-28 13:12:37 +00:00
|
|
|
|
2017-04-19 11:52:37 +00:00
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
let(:alice) { Fabricate(:account, username: 'alice') }
|
|
|
|
|
|
|
|
describe 'POST #create' do
|
2017-05-22 15:58:49 +00:00
|
|
|
let(:service) { double }
|
2017-04-19 11:52:37 +00:00
|
|
|
|
2017-05-22 15:58:49 +00:00
|
|
|
subject { post :create, params: { account_username: alice.username } }
|
|
|
|
|
|
|
|
before do
|
2017-04-19 11:52:37 +00:00
|
|
|
allow(UnfollowService).to receive(:new).and_return(service)
|
|
|
|
allow(service).to receive(:call)
|
2017-05-22 15:58:49 +00:00
|
|
|
end
|
|
|
|
|
2020-11-07 23:28:39 +00:00
|
|
|
context 'when account is permanently suspended' do
|
|
|
|
before do
|
|
|
|
alice.suspend!
|
|
|
|
alice.deletion_request.destroy
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http gone' do
|
|
|
|
expect(response).to have_http_status(410)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when account is temporarily suspended' do
|
|
|
|
before do
|
|
|
|
alice.suspend!
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http forbidden' do
|
|
|
|
expect(response).to have_http_status(403)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not unfollow' do
|
|
|
|
expect(UnfollowService).not_to receive(:new)
|
|
|
|
end
|
2017-05-22 15:58:49 +00:00
|
|
|
end
|
2017-04-19 11:52:37 +00:00
|
|
|
|
2020-11-07 23:28:39 +00:00
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
subject
|
|
|
|
end
|
2017-04-19 11:52:37 +00:00
|
|
|
|
2020-11-07 23:28:39 +00:00
|
|
|
it 'redirects to account path' do
|
|
|
|
expect(service).to have_received(:call).with(user.account, alice)
|
|
|
|
expect(response).to redirect_to(account_path(alice))
|
|
|
|
end
|
2017-04-19 11:52:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|