AI: #279 検索のワイルドカード #488
@@ -290,19 +290,23 @@ RSpec.describe 'Posts API', type: :request do
|
|||||||
[:title, :url].each do |field|
|
[:title, :url].each do |field|
|
||||||
context "when #{field} contains wildcards" do
|
context "when #{field} contains wildcards" do
|
||||||
let!(:search_posts) do
|
let!(:search_posts) do
|
||||||
['needle%25end', 'needleX25end', 'needle_end', 'needleXend', 'needleABend'].map do |value|
|
['needle%25end', 'needleX25end', 'needle_end', 'needleXend', 'needleABend', 'needle%25_end'].map.with_index do |value, index|
|
||||||
Post.create!(uploaded_user: user, title: "prefix #{value} suffix",
|
Post.create!(uploaded_user: user,
|
||||||
url: "https://example.com/prefix-#{value}-suffix")
|
title: field == :title ? "prefix #{value} suffix" : 'url search post',
|
||||||
|
url: field == :url ? "https://example.com/prefix-#{value}-suffix" :
|
||||||
|
"https://example.com/title-search-#{index}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
'needle%25end' => [0],
|
'needle%25end' => [0],
|
||||||
'needle_end' => [2],
|
'needle_end' => [2],
|
||||||
'needle*end' => [0, 1, 2, 3, 4],
|
'needle*end' => [0, 1, 2, 3, 4, 5],
|
||||||
'needle?end' => [2, 3],
|
'needle?end' => [2, 3],
|
||||||
'needle%*end' => [0],
|
'needle%*end' => [0, 5],
|
||||||
'needle_?nd' => [2]
|
'needle_?nd' => [2],
|
||||||
|
'needle%25_end' => [5],
|
||||||
|
'needle%25_*end' => [5]
|
||||||
}.each do |query, expected_indices|
|
}.each do |query, expected_indices|
|
||||||
it "matches #{query.inspect} using only * and ? as wildcards" do
|
it "matches #{query.inspect} using only * and ? as wildcards" do
|
||||||
get '/posts', params: { field => query }
|
get '/posts', params: { field => query }
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする