From 7cf2978f5f82ae0396ad2caddb155e9bc16b433f Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 12 Oct 2026 21:53:02 +0900 Subject: [PATCH] #424 --- backend/spec/models/shared_tag_ids_spec.rb | 6 +++++- backend/spec/requests/tag_descriptions_spec.rb | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/backend/spec/models/shared_tag_ids_spec.rb b/backend/spec/models/shared_tag_ids_spec.rb index 039de17..96ef653 100644 --- a/backend/spec/models/shared_tag_ids_spec.rb +++ b/backend/spec/models/shared_tag_ids_spec.rb @@ -27,8 +27,12 @@ RSpec.describe 'Shared Tag and ExternalTag IDs', type: :model do end it "uses the current maximum after deleting earlier #{ resource } records" do - create(:tag, id: 100).destroy! + tag = create(:tag, id: 100) + TagName.where(tag_id: tag.id).update_all(tag_id: nil) + tag.destroy! create(:external_tag, id: 200).destroy! + expect(Tag.unscoped.count).to eq(0) + expect(ExternalTag.unscoped.count).to eq(0) expect(create_resource(resource).id).to eq(1) end diff --git a/backend/spec/requests/tag_descriptions_spec.rb b/backend/spec/requests/tag_descriptions_spec.rb index a0746e5..7901144 100644 --- a/backend/spec/requests/tag_descriptions_spec.rb +++ b/backend/spec/requests/tag_descriptions_spec.rb @@ -206,7 +206,13 @@ RSpec.describe 'Tag description native API', type: :request do context 'without an existing description' do before { tag } - it 'creates both current resources and histories with matching compatibility IDs' do + it 'creates a description with synchronised Wiki content and histories' do + unrelated = Wiki::Commit.create_legacy_content!( + tag_name: create(:tag_name, name: 'Help:unrelated_native_description'), + body: 'unrelated body', created_by_user: author) + unrelated_state = [unrelated.attributes, + unrelated.wiki_revisions.map(&:attributes), + unrelated.wiki_versions.map(&:attributes)] expect { native_write(body: 'created natively') } .to change(TagDescription, :count).by(1) .and change(TagDescriptionVersion, :count).by(1) @@ -215,7 +221,7 @@ RSpec.describe 'Tag description native API', type: :request do .and change(WikiVersion, :count).by(1) expect(response).to have_http_status(:created) description = TagDescription.find_by!(tag_id: tag.id, language_code: 'ja') - page = WikiPage.find(description.id) + page = WikiPage.find_by!(tag_name: tag.tag_name('ja')) revision = page.current_revision version = TagDescriptionVersion.find(revision.id) expect(description).to have_attributes( @@ -227,6 +233,9 @@ RSpec.describe 'Tag description native API', type: :request do expect(page).to have_attributes(tag_name_id: tag_name.id, body: description.body) expect(revision.body).to eq(version.body) expect(page.wiki_versions.last.body).to eq(version.body) + unrelated.reload + expect([unrelated.attributes, unrelated.wiki_revisions.map(&:attributes), + unrelated.wiki_versions.map(&:attributes)]).to eq(unrelated_state) expect_current(description) get "/wiki/#{ description.id }"