A platform for community discussion. Free, open, simple.
FIX: when creating a topic in a category that only allows tags from a tag group, don't allow creation of new tags
Neil Lalonde6ca71e1319cc
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex 7f0cc0a68a7..758b8dcd75a 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -40,7 +40,7 @@ module DiscourseTaggingselected_tags: tag_names).to_a- if tags.size < tag_names.size && (category.nil? || category.tags.count == 0)+ if tags.size < tag_names.size && (category.nil? || (category.tags.count == 0 && category.tag_groups.count == 0))tag_names.each do |name|unless Tag.where(name: name).exists?tags << Tag.create(name: name)diff --git a/spec/integration/category_tag_spec.rb b/spec/integration/category_tag_spec.rbindex 2e0abf30b0c..86ff857cb34 100644--- a/spec/integration/category_tag_spec.rb+++ b/spec/integration/category_tag_spec.rb@@ -100,6 +100,13 @@ describe "category tag restrictions" doexpect(filter_allowed_tags(for_input: true)).to contain_exactly(tag3)expect(filter_allowed_tags(for_input: true, category: other_category)).to contain_exactly(tag3)end++ it "enforces restrictions when creating a topic" do+ category.allowed_tag_groups = [tag_group1.name]+ category.reload+ post = create_post(category: category, tags: [tag1.name, "newtag"])+ expect(post.topic.tags.map(&:name)).to eq([tag1.name])+ endendcontext "tag groups with parent tag" do