このコミットが含まれているのは:
@@ -1,10 +1,11 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Unmigrated Wiki compatibility', type: :request do
|
||||
include WikiRecords
|
||||
let!(:user) { create_member_user! }
|
||||
let!(:tag_name) { create(:tag_name, name: 'Help_contract') }
|
||||
let!(:page) do
|
||||
Wiki::Commit.create_content!(tag_name:, body: 'before', created_by_user: user)
|
||||
seed_wiki_page(tag_name:, body: 'before', created_by_user: user)
|
||||
end
|
||||
let!(:first_revision) { page.current_revision }
|
||||
let!(:last_revision) do
|
||||
@@ -33,83 +34,45 @@ RSpec.describe 'Unmigrated Wiki compatibility', type: :request do
|
||||
expect(page.current_revision).to have_attributes(message: 'legacy rename')
|
||||
end
|
||||
|
||||
it 'shows legacy current and historical content by ID' do
|
||||
get "/wiki/#{ page.id }"
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to include('body' => 'after', 'revision_id' => last_revision.id,
|
||||
'pred' => first_revision.id, 'succ' => nil)
|
||||
get "/wiki/#{ page.id }", params: { version: first_revision.id }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to include('body' => 'before', 'revision_id' => first_revision.id,
|
||||
'pred' => nil, 'succ' => last_revision.id)
|
||||
include TagGroupRecords
|
||||
|
||||
[:id, :title].each do |lookup|
|
||||
[nil, :historical].each do |edition|
|
||||
it "rejects legacy #{ lookup } #{ edition || 'current' } without legacy SELECTs" do
|
||||
path = lookup == :id ? "/wiki/#{ page.id }" : "/wiki/title/#{ tag_name.name }"
|
||||
params = edition ? { version: first_revision.id } : { }
|
||||
without_group_legacy_reads { get path, params: }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
it "does not recognise legacy #{ lookup } existence" do
|
||||
path = lookup == :id ? "/wiki/#{ page.id }" : "/wiki/title/#{ tag_name.name }"
|
||||
without_group_legacy_reads { get "#{ path }/exists" }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
it 'shows legacy current and historical content by title' do
|
||||
get "/wiki/title/#{ tag_name.name }"
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to include('body' => 'after', 'revision_id' => last_revision.id)
|
||||
get "/wiki/title/#{ tag_name.name }", params: { version: first_revision.id }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to include('body' => 'before', 'revision_id' => first_revision.id)
|
||||
end
|
||||
|
||||
it 'recognises legacy IDs' do
|
||||
get "/wiki/#{ page.id }/exists"
|
||||
expect(response).to have_http_status(:no_content)
|
||||
end
|
||||
|
||||
it 'recognises legacy titles' do
|
||||
get "/wiki/title/#{ tag_name.name }/exists"
|
||||
expect(response).to have_http_status(:no_content)
|
||||
end
|
||||
|
||||
it 'diffs legacy revisions with explicit and current target' do
|
||||
[last_revision.id, nil].each do |to|
|
||||
get "/wiki/#{ page.id }/diff", params: { from: first_revision.id, to: }
|
||||
['/wiki', '/wiki/search', '/wiki/changes'].each do |path|
|
||||
it "excludes unmigrated content from #{ path } without legacy SELECTs" do
|
||||
without_group_legacy_reads { get path }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to include(
|
||||
'wiki_page_id' => page.id, 'title' => tag_name.name,
|
||||
'older_revision_id' => first_revision.id, 'newer_revision_id' => last_revision.id,
|
||||
'diff' => [{ 'type' => 'removed', 'content' => 'before' },
|
||||
{ 'type' => 'added', 'content' => 'after' }])
|
||||
expect(json).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'revision resource scope' do
|
||||
let!(:other_page) do
|
||||
Wiki::Commit.create_content!(
|
||||
tag_name: create(:tag_name, name: 'Help_other_contract'),
|
||||
body: 'other page history', created_by_user: user)
|
||||
end
|
||||
let(:other_revision) { other_page.current_revision }
|
||||
|
||||
it 'returns 404 when show specifies another page revision' do
|
||||
get "/wiki/#{ page.id }", params: { version: other_revision.id }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'returns 404 when diff from belongs to another page' do
|
||||
get "/wiki/#{ page.id }/diff",
|
||||
params: { from: other_revision.id, to: last_revision.id }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'returns 404 when diff to belongs to another page' do
|
||||
get "/wiki/#{ page.id }/diff",
|
||||
params: { from: first_revision.id, to: other_revision.id }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
|
||||
it 'retains legacy history metadata and ordering' do
|
||||
get '/wiki/changes', params: { id: page.id }
|
||||
it 'returns empty scoped history without legacy SELECTs' do
|
||||
without_group_legacy_reads { get '/wiki/changes', params: { id: page.id } }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json.map { |row| row.fetch('revision_id') }).to eq(
|
||||
[last_revision.id, first_revision.id])
|
||||
expect(json.first).to include(
|
||||
'pred' => first_revision.id, 'succ' => nil, 'kind' => 'content',
|
||||
'message' => 'legacy edit', 'timestamp' => last_revision.created_at.iso8601(3),
|
||||
'wiki_page' => { 'id' => page.id, 'title' => tag_name.name, 'deprecated_at' => nil },
|
||||
'user' => { 'id' => user.id, 'name' => user.name })
|
||||
expect(json).to eq([])
|
||||
end
|
||||
|
||||
[false, true].each do |explicit|
|
||||
it "rejects legacy diff with #{ explicit ? 'explicit' : 'current' } target" do
|
||||
params = { from: first_revision.id }
|
||||
params[:to] = last_revision.id if explicit
|
||||
without_group_legacy_reads { get "/wiki/#{ page.id }/diff", params: }
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする