FIX: remove parent tag from tag group

Having a tag be a member of a tag group and the group's parent tag at
the same time causes some unexpected behavior. When a tag is assigned
as the parent, remove it from the group.
This commit is contained in:
Neil Lalonde
2020-03-13 12:25:46 -04:00
parent ad2ec5b65e
commit 7c27f9bba9
2 changed files with 21 additions and 0 deletions

View File

@@ -101,6 +101,22 @@ describe TagGroup do
expect_same_tag_names(tag_group.reload.tags, [tag, 'new-tag'])
end
it "removes parent tag as group member" do
parent = Fabricate(:tag)
tag_group.tags = [tag, parent]
tag_group.update!(parent_tag: parent)
tag_group.reload
expect_same_tag_names(tag_group.tags, [tag])
expect_same_tag_names([tag_group.parent_tag], [parent])
end
it "removes parent tag as group member when creating the group" do
parent = Fabricate(:tag)
tg = Fabricate(:tag_group, tags: [tag, parent], parent_tag: parent)
expect_same_tag_names(tg.tags, [tag])
expect_same_tag_names([tg.parent_tag], [parent])
end
context 'with synonyms' do
fab!(:synonym) { Fabricate(:tag, name: 'synonym', target_tag: tag) }