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.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 'keeps a Tag-linked legacy page in the legacy domain when its title changes' do create(:tag, primary_tag_name: tag_name) 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(1) .and change(WikiVersion, :count).by(1) .and change(TagDescription, :count).by(0) .and change(TagDescriptionVersion, :count).by(0) expect(response).to have_http_status(:ok) expect(page.reload).to have_attributes(body: 'changed legacy body') expect(page.title).to eq('legacy_tag_renamed') expect(page.current_revision).to have_attributes(message: 'legacy rename') end 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 ['/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 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) end end end