mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add hashtag controller specs (#19983)
This is just cleaning up a TODO I had to add more specs to this controller -- there are more thorough tests on the actual HashtagService class and the type-specific hashtag classes.
This commit is contained in:
@@ -9,8 +9,8 @@ module CategoryHashtag
|
||||
# TODO (martin) Remove this when enable_experimental_hashtag_autocomplete
|
||||
# becomes the norm, it is reimplemented below for CategoryHashtagDataSourcee
|
||||
def query_from_hashtag_slug(category_slug)
|
||||
slug_path = category_slug.split(SEPARATOR)
|
||||
return nil if slug_path.empty? || slug_path.size > 2
|
||||
slug_path = split_slug_path(category_slug)
|
||||
return if slug_path.blank?
|
||||
|
||||
slug_path.map! { |slug| CGI.escape(slug) } if SiteSetting.slug_generation_method == "encoded"
|
||||
|
||||
@@ -34,7 +34,9 @@ module CategoryHashtag
|
||||
category_slugs
|
||||
.map(&:downcase)
|
||||
.map do |slug|
|
||||
slug_path = slug.split(":")
|
||||
slug_path = split_slug_path(slug)
|
||||
next if slug_path.blank?
|
||||
|
||||
if SiteSetting.slug_generation_method == "encoded"
|
||||
slug_path.map! { |slug| CGI.escape(slug) }
|
||||
end
|
||||
@@ -60,5 +62,11 @@ module CategoryHashtag
|
||||
end
|
||||
.compact
|
||||
end
|
||||
|
||||
def split_slug_path(slug)
|
||||
slug_path = slug.split(SEPARATOR)
|
||||
return if slug_path.empty? || slug_path.size > 2
|
||||
slug_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user