FIX: errors when using tags with colons in their name

This commit is contained in:
Neil Lalonde
2019-11-18 13:20:37 -05:00
parent 0350247130
commit 228c4814be
4 changed files with 53 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ describe "category tag restrictions" do
fab!(:tag2) { Fabricate(:tag, name: 'tag2') }
fab!(:tag3) { Fabricate(:tag, name: 'tag3') }
fab!(:tag4) { Fabricate(:tag, name: 'tag4') }
let(:tag_with_colon) { Fabricate(:tag, name: 'with:colon') }
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
@@ -58,6 +59,11 @@ describe "category tag restrictions" do
expect_same_tag_names(filter_allowed_tags(for_input: true, category: other_category, selected_tags: [tag3.name], term: 'tag'), [tag4])
end
it "search can handle colons in tag names" do
tag_with_colon
expect_same_tag_names(filter_allowed_tags(for_input: true, term: 'with:c'), [tag_with_colon])
end
it "can't create new tags in a restricted category" do
post = create_post(category: category_with_tags, tags: [tag1.name, "newtag"])
expect_same_tag_names(post.topic.tags, [tag1])
@@ -157,6 +163,11 @@ describe "category tag restrictions" do
expect(post.topic.tags.map(&:name)).to eq([tag1.name])
end
it "handles colons" do
tag_with_colon
expect_same_tag_names(filter_allowed_tags(for_input: true, term: 'with:c'), [tag_with_colon])
end
context 'required tags from tag group' do
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag3]) }
before { category.update!(required_tag_group: tag_group, min_tags_from_required_group: 1) }
@@ -326,7 +337,7 @@ describe "category tag restrictions" do
car_category.allowed_tag_groups = [makes.name, honda_group.name, ford_group.name]
end
it "handles all those rules", :focus do
it "handles all those rules" do
# car tags can't be used outside of car category:
expect_same_tag_names(filter_allowed_tags(for_input: true), [tag1, tag2, tag3, tag4])
expect_same_tag_names(filter_allowed_tags(for_input: true, category: other_category), [tag1, tag2, tag3, tag4])