2017-05-23 16:11:39 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-08 22:22:44 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-05-23 16:11:39 +00:00
|
|
|
describe Api::V1::Timelines::PublicController do
|
2016-11-08 22:22:44 +00:00
|
|
|
render_views
|
|
|
|
|
2022-01-27 23:46:42 +00:00
|
|
|
let(:user) { Fabricate(:user) }
|
2016-11-08 22:22:44 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
allow(controller).to receive(:doorkeeper_token) { token }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a user context' do
|
2017-07-27 13:16:07 +00:00
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) }
|
2016-11-08 22:22:44 +00:00
|
|
|
|
2017-05-23 16:11:39 +00:00
|
|
|
describe 'GET #show' do
|
|
|
|
before do
|
2019-01-05 11:43:28 +00:00
|
|
|
PostStatusService.new.call(user.account, text: 'New status from user for federated public timeline.')
|
2016-11-08 22:22:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
2017-05-23 16:11:39 +00:00
|
|
|
get :show
|
|
|
|
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2017-05-23 16:11:39 +00:00
|
|
|
expect(response.headers['Link'].links.size).to eq(2)
|
2016-11-08 22:22:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-23 16:11:39 +00:00
|
|
|
describe 'GET #show with local only' do
|
2016-11-08 22:22:44 +00:00
|
|
|
before do
|
2019-01-05 11:43:28 +00:00
|
|
|
PostStatusService.new.call(user.account, text: 'New status from user for local public timeline.')
|
2016-11-08 22:22:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
2017-05-23 16:11:39 +00:00
|
|
|
get :show, params: { local: true }
|
|
|
|
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2017-05-23 16:11:39 +00:00
|
|
|
expect(response.headers['Link'].links.size).to eq(2)
|
2016-11-08 22:22:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without a user context' do
|
2017-07-27 13:16:07 +00:00
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) }
|
2016-11-08 22:22:44 +00:00
|
|
|
|
2019-09-13 18:18:25 +00:00
|
|
|
before do
|
|
|
|
Setting.timeline_preview = true
|
|
|
|
end
|
|
|
|
|
2017-05-23 16:11:39 +00:00
|
|
|
describe 'GET #show' do
|
2016-11-08 22:22:44 +00:00
|
|
|
it 'returns http success' do
|
2017-05-23 16:11:39 +00:00
|
|
|
get :show
|
2016-11-08 22:22:44 +00:00
|
|
|
|
2018-04-21 19:35:07 +00:00
|
|
|
expect(response).to have_http_status(200)
|
2017-05-23 16:11:39 +00:00
|
|
|
expect(response.headers['Link']).to be_nil
|
2016-11-08 22:22:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|