conversations_controller_spec.rb 1014 B

12345678910111213141516171819202122232425262728293031323334353637
  1. require 'rails_helper'
  2. RSpec.describe Api::V1::ConversationsController, type: :controller 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: scopes) }
  6. let(:other) { Fabricate(:user, account: Fabricate(:account, username: 'bob')) }
  7. before do
  8. allow(controller).to receive(:doorkeeper_token) { token }
  9. end
  10. describe 'GET #index' do
  11. let(:scopes) { 'read:statuses' }
  12. before do
  13. PostStatusService.new.call(other.account, text: 'Hey @alice', visibility: 'direct')
  14. end
  15. it 'returns http success' do
  16. get :index
  17. expect(response).to have_http_status(200)
  18. end
  19. it 'returns pagination headers' do
  20. get :index, params: { limit: 1 }
  21. expect(response.headers['Link'].links.size).to eq(2)
  22. end
  23. it 'returns conversations' do
  24. get :index
  25. json = body_as_json
  26. expect(json.size).to eq 1
  27. end
  28. end
  29. end