suggestions_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe 'Suggestions 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' }
  7. let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
  8. describe 'GET /api/v2/suggestions' do
  9. let(:bob) { Fabricate(:account) }
  10. let(:jeff) { Fabricate(:account) }
  11. let(:params) { {} }
  12. before do
  13. Setting.bootstrap_timeline_accounts = [bob, jeff].map(&:acct).join(',')
  14. end
  15. it 'returns the expected suggestions' do
  16. get '/api/v2/suggestions', headers: headers
  17. expect(response).to have_http_status(200)
  18. expect(response.content_type)
  19. .to start_with('application/json')
  20. expect(response.parsed_body).to match_array(
  21. [bob, jeff].map do |account|
  22. hash_including({
  23. source: 'staff',
  24. sources: ['featured'],
  25. account: hash_including({ id: account.id.to_s }),
  26. })
  27. end
  28. )
  29. end
  30. end
  31. end