闭社主体 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.

52 lines
1.4 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. end
  20. context 'when format is json' do
  21. subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
  22. subject(:body) { JSON.parse(response.body) }
  23. context 'with page' do
  24. let(:page) { 1 }
  25. it 'returns followers' do
  26. expect(response).to have_http_status(200)
  27. expect(body['totalItems']).to eq 2
  28. expect(body['partOf']).to be_present
  29. end
  30. end
  31. context 'without page' do
  32. let(:page) { nil }
  33. it 'returns followers' do
  34. expect(response).to have_http_status(200)
  35. expect(body['totalItems']).to eq 2
  36. expect(body['partOf']).to be_blank
  37. end
  38. end
  39. end
  40. end
  41. end