Merge remote-tracking branch 'parent/stable-4.2' into upstream-4.2.2-lts
This commit is contained in:
commit
9310c1c81b
39 changed files with 460 additions and 98 deletions
50
spec/requests/api/v1/accounts/featured_tags_spec.rb
Normal file
50
spec/requests/api/v1/accounts/featured_tags_spec.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'account featured tags API' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
||||
let(:scopes) { 'read:accounts' }
|
||||
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
describe 'GET /api/v1/accounts/:id/featured_tags' do
|
||||
subject do
|
||||
get "/api/v1/accounts/#{account.id}/featured_tags", headers: headers
|
||||
end
|
||||
|
||||
before do
|
||||
account.featured_tags.create!(name: 'foo')
|
||||
account.featured_tags.create!(name: 'bar')
|
||||
end
|
||||
|
||||
it 'returns the expected tags', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||
}), a_hash_including({
|
||||
name: 'foo',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/foo",
|
||||
}))
|
||||
end
|
||||
|
||||
context 'when the account is remote' do
|
||||
it 'returns the expected tags', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||
}), a_hash_including({
|
||||
name: 'foo',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/foo",
|
||||
}))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -124,7 +124,7 @@ describe 'Caching behavior' do
|
|||
expect(response.cookies).to be_empty
|
||||
end
|
||||
|
||||
it 'sets public cache control' do
|
||||
it 'sets public cache control', :aggregate_failures do
|
||||
# expect(response.cache_control[:max_age]&.to_i).to be_positive
|
||||
expect(response.cache_control[:public]).to be_truthy
|
||||
expect(response.cache_control[:private]).to be_falsy
|
||||
|
@ -141,11 +141,8 @@ describe 'Caching behavior' do
|
|||
end
|
||||
|
||||
shared_examples 'non-cacheable error' do
|
||||
it 'does not return HTTP success' do
|
||||
it 'does not return HTTP success and does not have cache headers', :aggregate_failures do
|
||||
expect(response).to_not have_http_status(200)
|
||||
end
|
||||
|
||||
it 'does not have cache headers' do
|
||||
expect(response.cache_control[:public]).to be_falsy
|
||||
end
|
||||
end
|
||||
|
@ -182,6 +179,15 @@ describe 'Caching behavior' do
|
|||
end
|
||||
|
||||
context 'when anonymously accessed' do
|
||||
describe '/users/alice' do
|
||||
it 'redirects with proper cache header', :aggregate_failures do
|
||||
get '/users/alice'
|
||||
|
||||
expect(response).to redirect_to('/@alice')
|
||||
expect(response.headers['Vary']&.split(',')&.map { |x| x.strip.downcase }).to include('accept')
|
||||
end
|
||||
end
|
||||
|
||||
TestEndpoints::ALWAYS_CACHED.each do |endpoint|
|
||||
describe endpoint do
|
||||
before { get endpoint }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue