闭社主体 forked from https://github.com/tootsuite/mastodon
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.

56 lines
1.4 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Api::V1::Timelines::PublicController do
  4. render_views
  5. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  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