FEATURE: categories can require topics have a tag from a tag group

In a category's settings, the Tags tab has two new fields to
specify the number of tags that must be added to a topic
from a tag group. When creating a new topic, an error will be
shown to the user if the requirement isn't met.
This commit is contained in:
Neil Lalonde
2019-10-30 14:49:00 -04:00
parent 091d058ff2
commit d777844ed6
15 changed files with 226 additions and 21 deletions

View File

@@ -349,6 +349,7 @@ describe CategoriesController do
it "updates attributes correctly" do
readonly = CategoryGroup.permission_types[:readonly]
create_post = CategoryGroup.permission_types[:create_post]
tag_group = Fabricate(:tag_group)
put "/categories/#{category.id}.json", params: {
name: "hello",
@@ -364,7 +365,9 @@ describe CategoriesController do
"dancing" => "frogs"
},
minimum_required_tags: "",
allow_global_tags: 'true'
allow_global_tags: 'true',
required_tag_group_name: tag_group.name,
min_tags_from_required_group: 2
}
expect(response.status).to eq(200)
@@ -379,6 +382,8 @@ describe CategoriesController do
expect(category.custom_fields).to eq("dancing" => "frogs")
expect(category.minimum_required_tags).to eq(0)
expect(category.allow_global_tags).to eq(true)
expect(category.required_tag_group_id).to eq(tag_group.id)
expect(category.min_tags_from_required_group).to eq(2)
end
it 'logs the changes correctly' do