You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB

  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. context 'when account is permanently suspended' do
  14. before do
  15. alice.suspend!
  16. alice.deletion_request.destroy
  17. subject
  18. end
  19. it 'returns http gone' do
  20. expect(response).to have_http_status(410)
  21. end
  22. end
  23. context 'when account is temporarily suspended' do
  24. before do
  25. alice.suspend!
  26. subject
  27. end
  28. it 'returns http forbidden' do
  29. expect(response).to have_http_status(403)
  30. end
  31. end
  32. context 'when signed out' do
  33. before do
  34. subject
  35. end
  36. it 'does not follow' do
  37. expect(FollowService).not_to receive(:new)
  38. end
  39. end
  40. context 'when signed in' do
  41. before do
  42. sign_in(user)
  43. subject
  44. end
  45. it 'redirects to account path' do
  46. expect(service).to have_received(:call).with(user.account, alice, with_rate_limit: true)
  47. expect(response).to redirect_to(account_path(alice))
  48. end
  49. end
  50. end
  51. end