The previous commit changed it so that `/pools?search[name_matches]` does a full-text search. So for example, `search[name_matches]=smiling` will now match pool names containing any of the words "smiling", "smile", "smiles", or "smiled". This commit adds a `/pools?search[name_contains]` param that does what `name_matches` did before, and switches to it in search forms. So for example, `search[name_contains]=smiling` will only match pool names containing the exact substring "smiling". This change is so that `<field>_matches` works consistently across the site, and so that it's possible to search pool names by either an exact substring match, or by a looser natural language match. This is a minor breaking API change. API users can replace `/pools?search[name_matches]` with `/pools?search[name_contains]` to get the same behavior as before. The same applies to /favorite_groups.
49 lines
2.0 KiB
Ruby
49 lines
2.0 KiB
Ruby
require 'test_helper'
|
|
|
|
class ArtistVersionsControllerTest < ActionDispatch::IntegrationTest
|
|
context "An artist versions controller" do
|
|
setup do
|
|
@user = create(:gold_user, id: 100)
|
|
@builder = create(:builder_user, name: "danbo")
|
|
as(@builder) { @artist = create(:artist, name: "masao", url_string: "https://masao.deviantart.com") }
|
|
as(@user) { @artist.update(name: "masao_(deleted)", is_deleted: true) }
|
|
as(@builder) { @artist.update(name: "masao", is_deleted: false, group_name: "the_best", url_string: "https://www.deviantart.com/masao") }
|
|
end
|
|
|
|
context "index action" do
|
|
setup do
|
|
@versions = @artist.versions
|
|
end
|
|
|
|
should "render" do
|
|
get artist_versions_path
|
|
assert_response :success
|
|
end
|
|
|
|
should respond_to_search({}).with { @versions.reverse }
|
|
should respond_to_search(name: "masao").with { [@versions[2], @versions[0]] }
|
|
should respond_to_search(group_name: "the_best").with { @versions[2] }
|
|
should respond_to_search(urls_include_any: "https://www.deviantart.com/masao").with { [@versions[2], @versions[1], @versions[0]] }
|
|
should respond_to_search(is_deleted: "true").with { @versions[1] }
|
|
|
|
context "using includes" do
|
|
should respond_to_search(updater_id: 100).with { @versions[1] }
|
|
should respond_to_search(updater_name: "danbo").with { [@versions[2], @versions[0]] }
|
|
should respond_to_search(updater: {level: User::Levels::BUILDER}).with { [@versions[2], @versions[0]] }
|
|
should respond_to_search(artist: {name: "masao"}).with { @versions.reverse }
|
|
should respond_to_search(artist: {name: "doesntexist"}).with { [] }
|
|
end
|
|
end
|
|
|
|
context "show action" do
|
|
should "work" do
|
|
get artist_version_path(@artist.versions.first)
|
|
assert_redirected_to artist_versions_path(search: { artist_id: @artist.id })
|
|
|
|
get artist_version_path(@artist.versions.first), as: :json
|
|
assert_response :success
|
|
end
|
|
end
|
|
end
|
|
end
|