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.
57 lines
1.4 KiB
57 lines
1.4 KiB
8 years ago
|
# frozen_string_literal: true
|
||
|
|
||
8 years ago
|
require 'rails_helper'
|
||
|
|
||
8 years ago
|
describe Api::V1::Timelines::PublicController do
|
||
8 years ago
|
render_views
|
||
|
|
||
|
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||
|
|
||
|
before do
|
||
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||
|
end
|
||
|
|
||
|
context 'with a user context' do
|
||
|
let(:token) { double acceptable?: true, resource_owner_id: user.id }
|
||
|
|
||
8 years ago
|
describe 'GET #show' do
|
||
|
before do
|
||
|
PostStatusService.new.call(user.account, 'New status from user for federated public timeline.')
|
||
8 years ago
|
end
|
||
|
|
||
|
it 'returns http success' do
|
||
8 years ago
|
get :show
|
||
|
|
||
8 years ago
|
expect(response).to have_http_status(:success)
|
||
8 years ago
|
expect(response.headers['Link'].links.size).to eq(2)
|
||
8 years ago
|
end
|
||
|
end
|
||
|
|
||
8 years ago
|
describe 'GET #show with local only' do
|
||
8 years ago
|
before do
|
||
8 years ago
|
PostStatusService.new.call(user.account, 'New status from user for local public timeline.')
|
||
8 years ago
|
end
|
||
|
|
||
|
it 'returns http success' do
|
||
8 years ago
|
get :show, params: { local: true }
|
||
|
|
||
8 years ago
|
expect(response).to have_http_status(:success)
|
||
8 years ago
|
expect(response.headers['Link'].links.size).to eq(2)
|
||
8 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'without a user context' do
|
||
|
let(:token) { double acceptable?: true, resource_owner_id: nil }
|
||
|
|
||
8 years ago
|
describe 'GET #show' do
|
||
8 years ago
|
it 'returns http success' do
|
||
8 years ago
|
get :show
|
||
8 years ago
|
|
||
|
expect(response).to have_http_status(:success)
|
||
8 years ago
|
expect(response.headers['Link']).to be_nil
|
||
8 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|