このコミットが含まれているのは:
@@ -1,78 +1,25 @@
|
||||
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
|
||||
seed_wiki_page(tag_name:, body: 'before', created_by_user: user)
|
||||
end
|
||||
let!(:first_revision) { page.current_revision }
|
||||
let!(:last_revision) do
|
||||
Wiki::Commit.legacy_content!(page:, body: 'after', created_user: user,
|
||||
message: 'legacy edit', base_revision_id: first_revision.id)
|
||||
end
|
||||
|
||||
before { expect(TagDescription.exists?(id: page.id)).to be(false) }
|
||||
|
||||
it 'rejects standalone updates even after a Tag is linked to the legacy page' do
|
||||
create(:tag, primary_tag_name: tag_name)
|
||||
original = page.reload.attributes
|
||||
|
||||
expect do
|
||||
put "/wiki/#{ page.id }",
|
||||
params: { title: 'legacy_tag_renamed', body: 'changed legacy body',
|
||||
message: 'legacy rename', base_revision_id: last_revision.id },
|
||||
headers: { 'X-Transfer-Code' => user.inheritance_code }
|
||||
end.to change(WikiRevision, :count).by(0)
|
||||
.and change(WikiVersion, :count).by(0)
|
||||
.and change(TagDescription, :count).by(0)
|
||||
.and change(TagDescriptionVersion, :count).by(0)
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(page.reload.attributes).to eq(original)
|
||||
expect(page.current_revision).to have_attributes(message: 'legacy edit')
|
||||
end
|
||||
|
||||
RSpec.describe 'Removed standalone Wiki resources', type: :request do
|
||||
include TagGroupRecords
|
||||
let(:user) { create_member_user! }
|
||||
|
||||
[: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
|
||||
|
||||
['/wiki', '/wiki/search', '/wiki/changes'].each do |path|
|
||||
it "excludes unmigrated content from #{ path } without legacy SELECTs" do
|
||||
['Help:old', 'ヘルプ:旧ページ'].each do |title|
|
||||
it "does not resolve #{ title } as a Wiki resource" do
|
||||
path = "/wiki/title/#{ CGI.escapeURIComponent(title) }"
|
||||
without_group_legacy_reads { get path }
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
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).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)
|
||||
get "#{ path }/exists"
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it "rejects standalone creation of #{ title } without writes" do
|
||||
user
|
||||
before_state = group_state
|
||||
post '/wiki', params: { title:, body: 'body' },
|
||||
headers: { 'X-Transfer-Code' => user.inheritance_code }
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
expect(group_state).to eq(before_state)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする