このコミットが含まれているのは:
2026-10-12 12:45:00 +09:00
コミット e117e20346
9個のファイルの変更、142行の追加、36行の削除
+1 -1
ファイルの表示
@@ -431,7 +431,7 @@ RSpec.describe 'Tag group native API', type: :request do
it 'assigns the next group ID from the existing maximum' do
child_id
expected_id = (TagGroup.maximum(:id) || 0) + 1
expected_id = [TagGroup.maximum(:id).to_i, TagDescription.maximum(:id).to_i].max + 1
native_write(:create)
expect(response).to have_http_status(:created)
expect(json.fetch('id')).to eq(expected_id)
+15 -5
ファイルの表示
@@ -25,11 +25,22 @@ RSpec.describe 'Tag resource ID allocation', type: :request do
end
[:description, :group].each do |resource|
it "ignores the other resource's larger maximum when allocating #{ resource }" do
it "keeps #{ resource } independent of the Tag and ExternalTag ID space" do
create(:tag, id: 100)
create(:external_tag, id: 200)
seed_description(1)
seed_group(name: 'shared_space', id: 2)
create_resource(resource)
expect(json.fetch('id')).to eq(3)
end
it "uses the other resource's larger maximum when allocating #{ resource }" do
seed_description(resource == :description ? 1 : 20)
seed_group(name: 'other_space', id: resource == :group ? 1 : 20)
create_resource(resource)
expect(json.fetch('id')).to eq(2)
expect(json.fetch('id')).to eq(21)
end
it "starts #{ resource } at 1 even after previous allocated rows were removed" do
@@ -45,7 +56,7 @@ RSpec.describe 'Tag resource ID allocation', type: :request do
expect(json.fetch('id')).to eq(1)
end
it "allocates #{ resource } from its own maximum, preserving gaps and existing rows" do
it "allocates #{ resource } above both maxima, preserving legacy overlaps and gaps" do
[1, 2, 5].each { seed_description(_1) }
[1, 3, 8].each { seed_group(name: "group_#{ _1 }", id: _1) }
descriptions = TagDescription.order(:id).map(&:attributes)
@@ -53,8 +64,7 @@ RSpec.describe 'Tag resource ID allocation', type: :request do
create_resource(resource)
expected_id = resource == :description ? 6 : 9
expect(json.fetch('id')).to eq(expected_id)
expect(json.fetch('id')).to eq(9)
expect(TagDescription.where(id: [1, 2, 5]).order(:id).map(&:attributes)).to eq(descriptions)
expect(TagGroup.where(id: [1, 3, 8]).order(:id).map(&:attributes)).to eq(groups)
expect(TagDescription.exists?(id: 3)).to be(false)