Skip to content

Commit

Permalink
FIX: Tag synonyms should work (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grubba27 committed Jun 4, 2024
1 parent ecbe14c commit b793de8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module ::DiscoursePresetTopicComposer
tag_groups.each do |tag_group_name, tags|
tags.each do |tag|
tag = Tag.visible(guardian).find_by(name: tag)
tag = Tag.find_by_id(tag.target_tag_id) if tag.synonym?
next unless tag
topic.tags << tag
end
Expand Down
26 changes: 24 additions & 2 deletions spec/system/preset_topic_composer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
let(:composer) { PageObjects::Components::Composer.new }
fab!(:tag1) { Fabricate(:tag, name: "tag1") }
fab!(:tag2) { Fabricate(:tag, name: "tag2") }
fab!(:tag3) { Fabricate(:tag, name: "tag3") }
fab!(:tag_synonym_for_tag1) { Fabricate(:tag, name: "tag_synonym", target_tag: tag1) }
fab!(:cat) { Fabricate(:category) }
fab!(:tag_group) { Fabricate(:tag_group, tags: [tag1, tag2, tag3], name: "tag/group0") }
fab!(:tag_group) do
Fabricate(:tag_group, tags: [tag1, tag2, tag_synonym_for_tag1], name: "tag/group0")
end
fab!(:tag_group2) { Fabricate(:tag_group, tags: [tag1, tag2]) }

class SiteSettingHelper
Expand Down Expand Up @@ -113,6 +115,26 @@ def self.add_new_json(json)
expect(page).to have_text(tag1.name)
end

it "should create a topic with a preset and a tag synonym" do
visit "/"
preset_dropdown = PageObjects::Components::PresetTopicDropdown.new
preset_dropdown.select("New Question2")

preset_input = PageObjects::Components::PresetComposerInput.new
preset_input.select_first_with(tag_synonym_for_tag1.name)

title = "Abc 123 test title!"
body = "This is a test body that should work!"
composer.fill_title(title)
composer.type_content(body)

composer.submit

expect(page).to have_text(title, wait: 15)
expect(page).to have_text(body)
expect(page).to have_text(tag1.name)
end

it "should create a topic with a preset and multiple tags" do
visit "/"
preset_dropdown = PageObjects::Components::PresetTopicDropdown.new
Expand Down

0 comments on commit b793de8

Please sign in to comment.