41 行
1.8 KiB
Ruby
41 行
1.8 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe 'History boundaries shared with Counts', type: :request do
|
|
let!(:tag) { create(:tag, primary_name: 'description tag') }
|
|
let!(:description) do
|
|
TagDescription.create!(tag:, language_code: 'ja', version_no: 2, body: 'private body')
|
|
end
|
|
|
|
before do
|
|
['create', 'discard'].each_with_index do |event, index|
|
|
TagDescriptionVersion.create!(tag_id: tag.id, language_code: 'ja',
|
|
version_no: index + 1, event_type: event, body: 'private body',
|
|
created_at: Time.utc(2024))
|
|
end
|
|
end
|
|
|
|
it 'denies the same discarded description through Counts, the facade and the ordinary API' do
|
|
get '/counts/query', params: { resource: 'tag_descriptions', definition: 'history',
|
|
mode: 'details', locale: 'ja', execution_at: '2025-01-01T00:00:00Z' }
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.parsed_body).to include('count' => 0, 'output_count' => 2,
|
|
'excluded_count' => 2, 'versions' => [])
|
|
["/wiki/#{ description.id }", "/tags/#{ tag.id }/description"].each do |path|
|
|
get path, params: { locale: 'ja' }
|
|
expect(response).to have_http_status(:not_found)
|
|
expect(response.body).not_to include('private body')
|
|
end
|
|
get '/sitemap_entries/descriptions', params: { locale: 'ja' }
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.parsed_body['ids']).not_to include(description.id)
|
|
end
|
|
|
|
it 'permits the server-authenticated administrator to read the discarded description' do
|
|
sign_in_as(create(:user, :admin))
|
|
get "/tags/#{ tag.id }/description", params: { locale: 'ja' }
|
|
expect(response).to have_http_status(:ok)
|
|
expect(response.parsed_body['body']).to eq('private body')
|
|
expect(response.headers['Cache-Control']).to include('no-store')
|
|
end
|
|
end
|