1
0

account_follow_controller_spec.rb 783 B

1234567891011121314151617181920212223242526272829303132
  1. require 'rails_helper'
  2. describe AccountFollowController do
  3. render_views
  4. let(:user) { Fabricate(:user) }
  5. let(:alice) { Fabricate(:account, username: 'alice') }
  6. describe 'POST #create' do
  7. let(:service) { double }
  8. subject { post :create, params: { account_username: alice.username } }
  9. before do
  10. allow(FollowService).to receive(:new).and_return(service)
  11. allow(service).to receive(:call)
  12. end
  13. it 'does not create for user who is not signed in' do
  14. subject
  15. expect(FollowService).not_to receive(:new)
  16. end
  17. it 'redirects to account path' do
  18. sign_in(user)
  19. subject
  20. expect(service).to have_received(:call).with(user.account, 'alice')
  21. expect(response).to redirect_to(account_path(alice))
  22. end
  23. end
  24. end