FIX: delete synonyms in topics if target tag is already added.

Currently, while adding a synonym tag if both target and synonym tags are already available in a topic then it's returning an error.
This commit is contained in:
Vinoth Kannan
2020-07-21 21:02:01 +05:30
parent 8515d8fae5
commit ef37460c93
2 changed files with 13 additions and 1 deletions

View File

@@ -517,6 +517,16 @@ describe DiscourseTagging do
expect(tag2.reload.target_tag).to eq(tag1)
end
it "can add an existing tag when both tags added to same topic" do
topic = Fabricate(:topic, tags: [tag1, tag2, tag3])
expect {
expect(DiscourseTagging.add_or_create_synonyms_by_name(tag1, [tag2.name])).to eq(true)
}.to_not change { Tag.count }
expect_same_tag_names(tag1.reload.synonyms, [tag2])
expect_same_tag_names(topic.reload.tags, [tag1, tag3])
expect(tag2.reload.target_tag).to eq(tag1)
end
it "can add existing tag with wrong case" do
expect {
expect(DiscourseTagging.add_or_create_synonyms_by_name(tag1, [tag2.name.upcase])).to eq(true)