このコミットが含まれているのは:
@@ -1,11 +1,17 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'TagName database invariants' do
|
||||
def insert_name!(**attributes)
|
||||
TagName.insert_all!([{ name: 'constraint_name', language_code: 'ja',
|
||||
script_code: 'Jpan', primary_flg: true,
|
||||
created_at: Time.current, updated_at: Time.current,
|
||||
**attributes }])
|
||||
def insert_name! **attributes
|
||||
defaults = {
|
||||
tag_id: create(:tag, primary_tag_name: nil).id,
|
||||
name: 'constraint_name',
|
||||
language_code: 'ja',
|
||||
script_code: 'Jpan',
|
||||
primary_flg: true,
|
||||
created_at: Time.current,
|
||||
updated_at: Time.current }
|
||||
|
||||
TagName.insert_all!([defaults.merge(attributes)])
|
||||
end
|
||||
|
||||
it 'defaults persisted names to human-confirmed provenance' do
|
||||
@@ -33,4 +39,9 @@ RSpec.describe 'TagName database invariants' do
|
||||
.to raise_error(ActiveRecord::RecordNotUnique)
|
||||
expect(TagName.where(tag:, language_code: 'ja', primary_flg: true).count).to eq(1)
|
||||
end
|
||||
|
||||
it 'rejects a name without a tag' do
|
||||
expect { insert_name!(tag_id: nil) }
|
||||
.to raise_error(ActiveRecord::NotNullViolation)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,4 +20,33 @@ RSpec.describe TagGroup, type: :model do
|
||||
.to include('id' => group.id, 'name' => 'history owner', 'members' => [])
|
||||
end
|
||||
|
||||
it 'destroys a group with nested placements and child membership, retaining history' do
|
||||
child = create_group(name: 'child group')
|
||||
|
||||
parent = create_group(
|
||||
name: 'parent group',
|
||||
members: [{ 'tag_group_id' => child.id }],
|
||||
placements: [{
|
||||
'section_name' => 'section',
|
||||
'description' => nil,
|
||||
'children' => [{
|
||||
'tag_group_id' => child.id,
|
||||
'children' => []
|
||||
}]
|
||||
}])
|
||||
|
||||
versions = parent.versions.order(:version_no).map(&:attributes)
|
||||
|
||||
expect { parent.destroy! }
|
||||
.to change(TagGroup, :count).by(-1)
|
||||
.and change(TagGroupVersion, :count).by(0)
|
||||
|
||||
expect(TagGroupVersion.where(tag_group_id: parent.id)
|
||||
.order(:version_no).map(&:attributes)).to eq(versions)
|
||||
|
||||
expect(child.reload).to be_persisted
|
||||
expect(TagGroupPlacement.where(tag_group_id: parent.id)).to be_empty
|
||||
expect(TagGroupTag.where(tag_group_id: parent.id)).to be_empty
|
||||
expect(TagGroupGroup.where(tag_group_id: parent.id)).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
@@ -232,10 +232,9 @@ RSpec.describe 'Materials API', type: :request do
|
||||
expect(current_description_version(page).body).to eq('legacy body')
|
||||
end
|
||||
|
||||
it 'uses tag_id rather than description ID without a Wiki page or TagName' do
|
||||
it 'uses tag_id rather than description Id. without a Wiki page' do
|
||||
description = TagDescription.create!(tag:, language_code: 'ja',
|
||||
body: 'independent body', version_no: 1)
|
||||
tag.tag_names.delete_all
|
||||
get_material_without_legacy_reads
|
||||
expect(json.fetch('wiki_page_body')).to eq('independent body')
|
||||
expect(json.fetch('tag').fetch('has_wiki')).to be(true)
|
||||
|
||||
@@ -46,12 +46,14 @@ RSpec.describe 'Tag resource ID allocation', type: :request do
|
||||
|
||||
it 'preserves resource and old revision identity on an update' do
|
||||
description = create_description('stable')
|
||||
original_resource_id = description.id
|
||||
original = current_description_version(description)
|
||||
snapshot = original.attributes
|
||||
put "/wiki/#{ description.id }", params: {
|
||||
title: 'stable', body: 'after', base_revision_id: original.id }, headers: headers
|
||||
put "/wiki/#{ description.id }",
|
||||
params: { title: 'stable', body: 'after', base_revision_id: original.id },
|
||||
headers: headers
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(json.fetch('id')).to eq(description.id)
|
||||
expect(description.reload.id).to eq(original_resource_id)
|
||||
expect(description.reload).to have_attributes(body: 'after', version_no: 2)
|
||||
expect(original.reload.attributes).to eq(snapshot)
|
||||
expect(current_description_version(description).id).to be > original.id
|
||||
|
||||
@@ -453,7 +453,6 @@ RSpec.describe 'Wiki API', type: :request do
|
||||
headers: auth_headers(user)
|
||||
}
|
||||
.to change(TagDescriptionVersion, :count).by(1)
|
||||
|
||||
.and change { linked_tag.reload.tag_versions.count }.by(2)
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
||||
@@ -52,12 +52,15 @@ RSpec.describe SharedResourceIdAllocator do
|
||||
end
|
||||
end
|
||||
|
||||
it "rejects explicit IDs below the reserved #{ space } position" do
|
||||
it "allows explicit overlapping Id.s in #{ space }" do
|
||||
first = resource(tables.first)
|
||||
first.save!
|
||||
first.class.where(id: first.id).delete_all
|
||||
expect { resource(tables.last, id: first.id).save! }
|
||||
.to raise_error(ActiveRecord::RecordNotUnique)
|
||||
|
||||
second = resource(tables.last, id: first.id)
|
||||
second.save!
|
||||
|
||||
expect(second.id).to eq(first.id)
|
||||
expect(first.reload.id).to eq(first.id)
|
||||
end
|
||||
|
||||
it "preserves historical #{ space } overlaps without repairing them" do
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする