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

@@ -313,53 +313,6 @@ RSpec.describe HashtagAutocompleteService do
end
end
describe "#lookup_old" do
fab!(:tag2) { Fabricate(:tag, name: "fiction-books") }
it "returns categories and tags in a hash format with the slug and url" do
result = service.lookup_old(%w[the-book-club great-books fiction-books])
expect(result[:categories]).to eq({ "the-book-club" => "/c/the-book-club/#{category1.id}" })
expect(result[:tags]).to eq(
{
"fiction-books" => "http://test.localhost/tag/fiction-books",
"great-books" => "http://test.localhost/tag/great-books",
},
)
end
it "does not include categories the user cannot access" do
category1.update!(read_restricted: true)
result = service.lookup_old(%w[the-book-club great-books fiction-books])
expect(result[:categories]).to eq({})
end
it "does not include tags the user cannot access" do
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: ["great-books"])
result = service.lookup_old(%w[the-book-club great-books fiction-books])
expect(result[:tags]).to eq({ "fiction-books" => "http://test.localhost/tag/fiction-books" })
end
it "handles tags which have the ::tag suffix" do
result = service.lookup_old(%w[the-book-club great-books::tag fiction-books])
expect(result[:tags]).to eq(
{
"fiction-books" => "http://test.localhost/tag/fiction-books",
"great-books" => "http://test.localhost/tag/great-books",
},
)
end
context "when not tagging_enabled" do
before { SiteSetting.tagging_enabled = false }
it "does not return tags" do
result = service.lookup_old(%w[the-book-club great-books fiction-books])
expect(result[:categories]).to eq({ "the-book-club" => "/c/the-book-club/#{category1.id}" })
expect(result[:tags]).to eq({})
end
end
end
describe "#lookup" do
fab!(:tag2) { Fabricate(:tag, name: "fiction-books") }

View File

@@ -1332,8 +1332,7 @@ RSpec.describe PostAlerter do
expect(JSON.parse(body)).to eq(payload)
end
it "does not have invalid HTML in the excerpt when enable_experimental_hashtag_autocomplete is enabled" do
SiteSetting.enable_experimental_hashtag_autocomplete = true
it "does not have invalid HTML in the excerpt" do
Fabricate(:category, slug: "random")
Jobs.run_immediately!
body = nil