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.

35 lines
910 B

  1. require 'rails_helper'
  2. RSpec.describe Api::V1::SuggestionsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read write') }
  6. before do
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. describe 'GET #index' do
  10. let(:bob) { Fabricate(:account) }
  11. let(:jeff) { Fabricate(:account) }
  12. before do
  13. PotentialFriendshipTracker.record(user.account_id, bob.id, :reblog)
  14. PotentialFriendshipTracker.record(user.account_id, jeff.id, :favourite)
  15. get :index
  16. end
  17. it 'returns http success' do
  18. expect(response).to have_http_status(200)
  19. end
  20. it 'returns accounts' do
  21. json = body_as_json
  22. expect(json.size).to be >= 1
  23. expect(json.map { |i| i[:id] }).to include *[bob, jeff].map { |i| i.id.to_s }
  24. end
  25. end
  26. end