familiar_followers_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Accounts Familiar Followers API' do
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
  6. let(:scopes) { 'read:follows' }
  7. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  8. let(:account) { Fabricate(:account) }
  9. describe 'GET /api/v1/accounts/familiar_followers' do
  10. it 'returns http success' do
  11. get '/api/v1/accounts/familiar_followers', params: { account_id: account.id, limit: 2 }, headers: headers
  12. expect(response).to have_http_status(200)
  13. expect(response.content_type)
  14. .to start_with('application/json')
  15. end
  16. context 'when there are duplicate account IDs in the params' do
  17. let(:account_a) { Fabricate(:account) }
  18. let(:account_b) { Fabricate(:account) }
  19. it 'removes duplicate account IDs from params' do
  20. account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s }
  21. get '/api/v1/accounts/familiar_followers', params: { id: account_ids }, headers: headers
  22. expect(response.parsed_body.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s)
  23. end
  24. end
  25. end
  26. end