suggestions_controller_spec.rb 910 B

1234567891011121314151617181920212223242526272829303132333435
  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