このコミットが含まれているのは:
2026-10-15 22:07:07 +09:00
コミット 47c40afcc1
10個のファイルの変更、102行の追加、51行の削除
+16 -5
ファイルの表示
@@ -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