Fix #4601: Hide deleted pools by default in pool search.

* On /pools, hide deleted pools by default in HTML responses. Don't
  filter out deleted pools in API responses.

* API change: on /forum_topics, only hide deleted forum topics by
  default for HTML responses, not for API responses. Explicitly do
  https://danbooru.donmai.us/forum_topics.json?search[is_deleted]=false
  to filter out deleted topics.

* API change: on /tags, only hide empty tags by default for HTML
  responses, not for API responses. Explicitly do
  https://danbooru.donmai.us/tags.json?search[is_empty]=false to filter
  out empty tags.

* API change: on /pools, default to 20 posts per page for API responses,
  not 40.

* API change: add `search[is_empty]` param to /tags.json endpoint.
  `search[hide_empty]=true` is deprecated in favor of `search[is_empty]=false`.

* On /pools, add option to show/hide deleted pools in search form.

* Fix the /forum_topics page putting `search[order]=sticky&limit=40` in
  the URL when browsing past page 1.
This commit is contained in:
evazion
2021-09-29 05:28:21 -05:00
parent 4a525c7473
commit 2eb89a8354
8 changed files with 49 additions and 23 deletions

View File

@@ -36,10 +36,12 @@ class TagsControllerTest < ActionDispatch::IntegrationTest
context "searching" do
setup do
as(@user) do
@miku = create(:character_tag, name: "hatsune_miku")
@miku = create(:character_tag, name: "miku")
@hatsune_miku = create(:character_tag, name: "hatsune_miku")
@wokada = create(:artist_tag, name: "wokada")
@vocaloid = create(:copyright_tag, name: "vocaloid")
@weapon = create(:tag, name: "weapon")
@axe = create(:tag, name: "axe")
@empty = create(:tag, name: "empty", post_count: 0)
create(:tag_alias, antecedent_name: "miku", consequent_name: "hatsune_miku")
@@ -54,22 +56,24 @@ class TagsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
should respond_to_search({}).with { [@weapon, @vocaloid, @wokada, @miku, @tag] }
should respond_to_search(name_matches: "hatsune_miku").with { @miku }
should respond_to_search(name_normalize: "HATSUNE_MIKU ").with { @miku }
should respond_to_search(name_or_alias_matches: "miku").with { @miku }
should respond_to_search(fuzzy_name_matches: "hatsune_mika", order: "similarity").with { @miku }
should respond_to_search({}).with { [@empty, @axe, @weapon, @vocaloid, @wokada, @hatsune_miku, @miku, @tag] }
should respond_to_search(name_matches: "hatsune_miku").with { @hatsune_miku }
should respond_to_search(name_normalize: "HATSUNE_MIKU ").with { @hatsune_miku }
should respond_to_search(name_or_alias_matches: "miku").with { [@hatsune_miku, @miku] }
should respond_to_search(fuzzy_name_matches: "hatsune_mika", order: "similarity").with { @hatsune_miku }
should respond_to_search(name: "empty", hide_empty: "true").with { [] }
should respond_to_search(name: "empty", hide_empty: "false").with { [@empty] }
should respond_to_search(name: "empty", is_empty: "true").with { [@empty] }
should respond_to_search(name: "empty", is_empty: "false").with { [] }
context "using includes" do
should respond_to_search(name: "wokada", has_artist: "true").with { @wokada }
should respond_to_search(name: "hatsune_miku", has_artist: "false").with { @miku }
should respond_to_search(name: "hatsune_miku", has_wiki_page: "true").with { @miku }
should respond_to_search(name: "hatsune_miku", has_artist: "false").with { @hatsune_miku }
should respond_to_search(name: "hatsune_miku", has_wiki_page: "true").with { @hatsune_miku }
should respond_to_search(name: "vocaloid", has_wiki_page: "false").with { @vocaloid }
should respond_to_search(consequent_aliases: {antecedent_name: "miku"}).with { @miku }
should respond_to_search(consequent_aliases: {antecedent_name: "miku"}).with { @hatsune_miku }
should respond_to_search(consequent_implications: {antecedent_name: "axe"}).with { @weapon }
should respond_to_search(wiki_page: {body_matches: "*vocaloid*"}).with { @miku }
should respond_to_search(wiki_page: {body_matches: "*vocaloid*"}).with { @hatsune_miku }
should respond_to_search(artist: {is_banned: "false"}).with { @wokada }
should respond_to_search(has_dtext_links: "true").with { @vocaloid }
end