mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Sync client and server side behavior for category hashtag lookup
Category.query_from_hashtag_slug is the only source of truth.
This commit is contained in:
parent
56f42d89c5
commit
e88b17c044
@ -10,8 +10,7 @@ class CategoryHashtagsController < ApplicationController
|
||||
|
||||
slugs_and_urls = {}
|
||||
|
||||
Category.secured(guardian).where(id: ids).order(:id).each do |category|
|
||||
slugs_and_urls[category.slug] ||= category.url
|
||||
Category.secured(guardian).where(id: ids).each do |category|
|
||||
slugs_and_urls[category.slug_path.last(2).join(':')] ||= category.url
|
||||
end
|
||||
|
||||
|
@ -68,10 +68,10 @@ describe CategoryHashtagsController do
|
||||
|
||||
get "/category_hashtags/check.json", params: {
|
||||
category_slugs: [
|
||||
":",
|
||||
":", # should not work
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
"bar", # should not work
|
||||
"baz", # should not work
|
||||
"foo:bar",
|
||||
"bar:baz",
|
||||
"foo:bar:baz", # should not work
|
||||
@ -84,10 +84,8 @@ describe CategoryHashtagsController do
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["valid"]).to contain_exactly(
|
||||
{ "slug" => "foo", "url" => foo.url },
|
||||
{ "slug" => "bar", "url" => foobar.url },
|
||||
{ "slug" => "foo:bar", "url" => foobar.url },
|
||||
{ "slug" => "baz", "url" => foobarbaz.url },
|
||||
{ "slug" => "bar:baz", "url" => foobarbaz.url },
|
||||
{ "slug" => "bar:baz", "url" => foobarbaz.id < quxbarbaz.id ? foobarbaz.url : quxbarbaz.url },
|
||||
{ "slug" => "qux", "url" => qux.url },
|
||||
{ "slug" => "qux:bar", "url" => quxbar.url }
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user