public_controller_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Api::V1::Timelines::PublicController do
  4. render_views
  5. let(:user) { Fabricate(:user) }
  6. before do
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. context 'with a user context' do
  10. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
  11. describe 'GET #show' do
  12. before do
  13. PostStatusService.new.call(user.account, text: 'New status from user for federated public timeline.')
  14. end
  15. it 'returns http success' do
  16. get :show
  17. expect(response).to have_http_status(200)
  18. expect(response.headers['Link'].links.size).to eq(2)
  19. end
  20. end
  21. describe 'GET #show with local only' do
  22. before do
  23. PostStatusService.new.call(user.account, text: 'New status from user for local public timeline.')
  24. end
  25. it 'returns http success' do
  26. get :show, params: { local: true }
  27. expect(response).to have_http_status(200)
  28. expect(response.headers['Link'].links.size).to eq(2)
  29. end
  30. end
  31. end
  32. context 'without a user context' do
  33. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }
  34. describe 'GET #show' do
  35. it 'returns http success' do
  36. get :show
  37. expect(response).to have_http_status(200)
  38. expect(response.headers['Link']).to be_nil
  39. end
  40. end
  41. end
  42. end