FEATURE: Allow multiple required tag groups for a category (#16381)

Previously we only supported a single 'required tag group' for a category. This commit allows admins to specify multiple required tag groups, each with their own minimum tag count.

A new category_required_tag_groups database table replaces the existing columns on the categories table. Data is automatically migrated.
This commit is contained in:
David Taylor
2022-04-06 14:08:06 +01:00
committed by GitHub
parent 8f03baaf8e
commit 68c74e9b93
32 changed files with 387 additions and 156 deletions

View File

@ -577,7 +577,7 @@ describe NewPostManager do
let(:tag) { Fabricate(:tag) }
before do
TagGroupMembership.create(tag: tag, tag_group: tag_group)
category.update(min_tags_from_required_group: 1, required_tag_group_id: tag_group.id)
category.update(category_required_tag_groups: [CategoryRequiredTagGroup.new(tag_group: tag_group, min_count: 1)])
end
it "errors when there are no tags from the group provided" do
@ -593,8 +593,8 @@ describe NewPostManager do
expect(result.errors.full_messages).to include(
I18n.t(
"tags.required_tags_from_group",
count: category.min_tags_from_required_group,
tag_group_name: category.required_tag_group.name,
count: category.category_required_tag_groups.first.min_count,
tag_group_name: category.category_required_tag_groups.first.tag_group.name,
tags: tag.name
)
)