The code powering m.abunchtell.com https://m.abunchtell.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

41 řádky
1.2 KiB

  1. require 'rails_helper'
  2. describe Api::V1::Accounts::FollowingAccountsController do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:accounts') }
  6. let(:account) { Fabricate(:account) }
  7. let(:alice) { Fabricate(:account) }
  8. let(:bob) { Fabricate(:account) }
  9. before do
  10. account.follow!(alice)
  11. account.follow!(bob)
  12. allow(controller).to receive(:doorkeeper_token) { token }
  13. end
  14. describe 'GET #index' do
  15. it 'returns http success' do
  16. get :index, params: { account_id: account.id, limit: 2 }
  17. expect(response).to have_http_status(200)
  18. end
  19. it 'returns accounts followed by the given account' do
  20. get :index, params: { account_id: account.id, limit: 2 }
  21. expect(body_as_json.size).to eq 2
  22. expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s])
  23. end
  24. it 'does not return blocked users' do
  25. user.account.block!(bob)
  26. get :index, params: { account_id: account.id, limit: 2 }
  27. expect(body_as_json.size).to eq 1
  28. expect(body_as_json[0][:id]).to eq alice.id.to_s
  29. end
  30. end
  31. end