DEV: Remove enable_experimental_hashtag_autocomplete logic (#22820)

This commit removes any logic in the app and in specs around
enable_experimental_hashtag_autocomplete and deletes some
old category hashtag code that is no longer necessary.

It also adds a `slug_ref` category instance method, which
will generate a reference like `parent:child` for a category,
with an optional depth, which hashtags use. Also refactors
PostRevisor which was using CategoryHashtagDataSource directly
which is a no-no.

Deletes the old hashtag markdown rule as well.
This commit is contained in:
Martin Brennan
2023-08-08 11:18:55 +10:00
committed by GitHub
parent 0c88bf341a
commit 09223e5ae7
43 changed files with 310 additions and 1001 deletions

View File

@ -377,9 +377,6 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
context "when reply contains the skip trigger" do
it "should create the right reply" do
# TODO (martin) Remove when enable_experimental_hashtag_autocomplete is default for all sites
SiteSetting.enable_experimental_hashtag_autocomplete = false
parent_category = Fabricate(:category, name: "a")
_category = Fabricate(:category, parent_category: parent_category, name: "b")
@ -417,9 +414,6 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
context "when user recovers a post in the right topic" do
it "should create the right reply" do
# TODO (martin) Remove when enable_experimental_hashtag_autocomplete is default for all sites
SiteSetting.enable_experimental_hashtag_autocomplete = false
parent_category = Fabricate(:category, name: "a")
_category = Fabricate(:category, parent_category: parent_category, name: "b")
post
@ -448,9 +442,6 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
topic_id: topic.id,
track: described_class.to_s,
)
# TODO (martin) Remove when enable_experimental_hashtag_autocomplete is default for all sites
SiteSetting.enable_experimental_hashtag_autocomplete = false
end
context "when post is not in the right topic" do
@ -509,37 +500,15 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
narrative.input(:reply, user, post: post)
expected_raw = <<~RAW
#{I18n.t("discourse_narrative_bot.advanced_user_narrative.category_hashtag.reply", base_uri: "")}
#{I18n.t("discourse_narrative_bot.advanced_user_narrative.change_topic_notification_level.instructions", base_uri: "")}
RAW
expect(Post.last.raw).to eq(expected_raw.chomp)
expect(narrative.get_data(user)[:state].to_sym).to eq(
:tutorial_change_topic_notification_level,
)
end
context "when enable_experimental_hashtag_autocomplete is true" do
before { SiteSetting.enable_experimental_hashtag_autocomplete = true }
it "should create the right reply" do
category = Fabricate(:category)
post.update!(raw: "Check out this ##{category.slug}")
narrative.input(:reply, user, post: post)
expected_raw = <<~RAW
#{I18n.t("discourse_narrative_bot.advanced_user_narrative.category_hashtag.reply", base_uri: "")}
#{I18n.t("discourse_narrative_bot.advanced_user_narrative.change_topic_notification_level.instructions", base_uri: "")}
RAW
expect(Post.last.raw).to eq(expected_raw.chomp)
expect(narrative.get_data(user)[:state].to_sym).to eq(
:tutorial_change_topic_notification_level,
)
end
expect(Post.last.raw).to eq(expected_raw.chomp)
expect(narrative.get_data(user)[:state].to_sym).to eq(
:tutorial_change_topic_notification_level,
)
end
end