このコミットが含まれているのは:
@@ -1,5 +1,21 @@
|
||||
FactoryBot.define do
|
||||
factory :tag_name do
|
||||
name { "tag-#{SecureRandom.hex(4)}" }
|
||||
language_code { 'ja' }
|
||||
script_code { 'Jpan' }
|
||||
primary_flg { true }
|
||||
sequence(:name) { |number| "tag-#{ SecureRandom.hex(4) }-#{ number }" }
|
||||
|
||||
trait :alias do
|
||||
primary_flg { false }
|
||||
|
||||
after(:create) do |tag_name|
|
||||
owner = tag_name.canonical&.tag
|
||||
raise ArgumentError, 'alias requires a canonical tag' unless owner
|
||||
|
||||
# The alias validation still rejects tag_id; its contract is tested separately.
|
||||
tag_name.update_columns(tag_id: owner.id)
|
||||
tag_name.association(:tag).reset
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,10 +6,15 @@ FactoryBot.define do
|
||||
|
||||
category { :general }
|
||||
post_count { 0 }
|
||||
|
||||
association :tag_name
|
||||
|
||||
after(:build) do |tag, evaluator|
|
||||
tag.name = evaluator.name if evaluator.name.present?
|
||||
end
|
||||
|
||||
after(:create) do |tag|
|
||||
tag.tag_name.update!(tag:) if tag.tag_name.tag_id != tag.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする