闭社主体 forked from https://github.com/tootsuite/mastodon
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.8 KiB

  1. require 'rails_helper'
  2. describe FollowingAccountsController do
  3. render_views
  4. let(:alice) { Fabricate(:account, username: 'alice') }
  5. let(:followee0) { Fabricate(:account) }
  6. let(:followee1) { Fabricate(:account) }
  7. describe 'GET #index' do
  8. let!(:follow0) { alice.follow!(followee0) }
  9. let!(:follow1) { alice.follow!(followee1) }
  10. context 'when format is html' do
  11. subject(:response) { get :index, params: { account_username: alice.username, format: :html } }
  12. it 'assigns follows' do
  13. expect(response).to have_http_status(200)
  14. assigned = assigns(:follows).to_a
  15. expect(assigned.size).to eq 2
  16. expect(assigned[0]).to eq follow1
  17. expect(assigned[1]).to eq follow0
  18. end
  19. it 'does not assign blocked users' do
  20. user = Fabricate(:user)
  21. user.account.block!(followee0)
  22. sign_in(user)
  23. expect(response).to have_http_status(200)
  24. assigned = assigns(:follows).to_a
  25. expect(assigned.size).to eq 1
  26. expect(assigned[0]).to eq follow1
  27. end
  28. end
  29. context 'when format is json' do
  30. subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
  31. subject(:body) { JSON.parse(response.body) }
  32. context 'with page' do
  33. let(:page) { 1 }
  34. it 'returns followers' do
  35. expect(response).to have_http_status(200)
  36. expect(body['totalItems']).to eq 2
  37. expect(body['partOf']).to be_present
  38. end
  39. end
  40. context 'without page' do
  41. let(:page) { nil }
  42. it 'returns followers' do
  43. expect(response).to have_http_status(200)
  44. expect(body['totalItems']).to eq 2
  45. expect(body['partOf']).to be_blank
  46. end
  47. end
  48. end
  49. end
  50. end