コミットを比較
2
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
d830ac0311 | ||
|
|
7585f51e01 |
@@ -5,6 +5,7 @@ class MaterialVersionsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class MaterialsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class NicoTagsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
post_tag_max_sql =
|
post_tag_max_sql =
|
||||||
PostExternalTag
|
PostExternalTag
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class PostVersionsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class PostsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class TagVersionsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class TagsController < ApplicationController
|
|||||||
|
|
||||||
page = 1 if page < 1
|
page = 1 if page < 1
|
||||||
limit = 1 if limit < 1
|
limit = 1 if limit < 1
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
offset = (page - 1) * limit
|
offset = (page - 1) * limit
|
||||||
|
|
||||||
@@ -218,16 +219,63 @@ class TagsController < ApplicationController
|
|||||||
locale = resolve_locale!
|
locale = resolve_locale!
|
||||||
|
|
||||||
q = params[:q].to_s.strip.sub(/\Anot:/i, '')
|
q = params[:q].to_s.strip.sub(/\Anot:/i, '')
|
||||||
literal = ActiveRecord::Base.sanitize_sql_like(q)
|
prefix = "#{ ActiveRecord::Base.sanitize_sql_like(q) }%"
|
||||||
nico = bool?(:nico, default: true)
|
|
||||||
present = bool?(:present, default: true)
|
|
||||||
|
|
||||||
rows = autocomplete_rows(locale:, pattern: "#{ literal }%", nico:, present:)
|
with_nico = bool?(:nico, default: true)
|
||||||
if rows.length < 20 && q.present?
|
present_only = bool?(:present, default: true)
|
||||||
suffix_rows = autocomplete_rows(locale:, pattern: "%#{ literal }", nico:, present:)
|
|
||||||
rows = (rows + suffix_rows).uniq { [_1['category'], _1['id']] }.first(20)
|
alias_rows =
|
||||||
|
TagName
|
||||||
|
.where(language_code: locale.language_code, primary_flg: false)
|
||||||
|
.where('name LIKE ?', prefix)
|
||||||
|
.pluck(:tag_id, :name)
|
||||||
|
|
||||||
|
matched_alias_by_tag_id = { }
|
||||||
|
tag_ids = []
|
||||||
|
alias_rows.each do |tag_id, alias_name|
|
||||||
|
tag_ids << tag_id
|
||||||
|
matched_alias_by_tag_id[tag_id] ||= alias_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
base =
|
||||||
|
Tag
|
||||||
|
.joins(:tag_names)
|
||||||
|
.preload(:tag_names, :materials, :deerjikists, :tag_descriptions,
|
||||||
|
parents: [:tag_names, :materials, :deerjikists, :tag_descriptions])
|
||||||
|
.where(tag_names: { language_code: locale.language_code, primary_flg: true },
|
||||||
|
deprecated_at: nil)
|
||||||
|
base = base.where('tags.post_count > 0') if present_only
|
||||||
|
|
||||||
|
canonical_hit = base.where('tag_names.name LIKE ?', prefix)
|
||||||
|
|
||||||
|
internal_tags = canonical_hit.or(base.where(id: tag_ids.uniq))
|
||||||
|
|
||||||
|
internal_rows =
|
||||||
|
internal_tags
|
||||||
|
.order(Arel.sql('tags.post_count DESC, tag_names.name'))
|
||||||
|
.limit(20)
|
||||||
|
.map { |tag|
|
||||||
|
TagRepr.base(tag, language_code: locale.language_code)
|
||||||
|
.merge(matched_alias: matched_alias_by_tag_id[tag.id])
|
||||||
|
}
|
||||||
|
|
||||||
|
return render json: internal_rows unless with_nico
|
||||||
|
|
||||||
|
external_base = ExternalTag.all
|
||||||
|
external_base = external_base.where('post_count > 0') if present_only
|
||||||
|
|
||||||
|
external_rows =
|
||||||
|
external_base
|
||||||
|
.where("CONCAT(platform, ':', name) LIKE ? OR name LIKE ?", prefix, prefix)
|
||||||
|
.order(post_count: :desc, name: :asc)
|
||||||
|
.limit(20)
|
||||||
|
.map { external_tag_json(_1) }
|
||||||
|
|
||||||
|
rows =
|
||||||
|
(internal_rows + external_rows)
|
||||||
|
.sort_by { |row| [-row['post_count'], row['name'] || row[:name]] }
|
||||||
|
.first(20)
|
||||||
|
|
||||||
render json: rows
|
render json: rows
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -498,59 +546,6 @@ class TagsController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def autocomplete_rows locale:, pattern:, nico:, present:
|
|
||||||
alias_rows =
|
|
||||||
TagName
|
|
||||||
.where(language_code: locale.language_code, primary_flg: false)
|
|
||||||
.where('name LIKE ?', pattern)
|
|
||||||
.pluck(:tag_id, :name)
|
|
||||||
|
|
||||||
matched_alias_by_tag_id = { }
|
|
||||||
tag_ids = []
|
|
||||||
alias_rows.each do |tag_id, alias_name|
|
|
||||||
tag_ids << tag_id
|
|
||||||
matched_alias_by_tag_id[tag_id] ||= alias_name
|
|
||||||
end
|
|
||||||
|
|
||||||
base =
|
|
||||||
Tag
|
|
||||||
.joins(:tag_names)
|
|
||||||
.preload(:tag_names, :materials, :deerjikists, :tag_descriptions,
|
|
||||||
parents: [:tag_names, :materials, :deerjikists, :tag_descriptions])
|
|
||||||
.where(tag_names: { language_code: locale.language_code, primary_flg: true },
|
|
||||||
deprecated_at: nil)
|
|
||||||
base = base.where('tags.post_count > 0') if present
|
|
||||||
|
|
||||||
canonical_hit = base.where('tag_names.name LIKE ?', pattern)
|
|
||||||
|
|
||||||
internal_tags = canonical_hit.or(base.where(id: tag_ids.uniq))
|
|
||||||
|
|
||||||
internal_rows =
|
|
||||||
internal_tags
|
|
||||||
.order(Arel.sql('tags.post_count DESC, tag_names.name'))
|
|
||||||
.limit(20)
|
|
||||||
.map { |tag|
|
|
||||||
TagRepr.base(tag, language_code: locale.language_code)
|
|
||||||
.merge(matched_alias: matched_alias_by_tag_id[tag.id])
|
|
||||||
}
|
|
||||||
|
|
||||||
return internal_rows unless nico
|
|
||||||
|
|
||||||
external_base = ExternalTag.all
|
|
||||||
external_base = external_base.where('post_count > 0') if present
|
|
||||||
|
|
||||||
external_rows =
|
|
||||||
external_base
|
|
||||||
.where("CONCAT(platform, ':', name) LIKE ? OR name LIKE ?", pattern, pattern)
|
|
||||||
.order(post_count: :desc, name: :asc)
|
|
||||||
.limit(20)
|
|
||||||
.map { external_tag_json(_1) }
|
|
||||||
|
|
||||||
(internal_rows + external_rows)
|
|
||||||
.sort_by { |row| [-row['post_count'], row['name'] || row[:name]] }
|
|
||||||
.first(20)
|
|
||||||
end
|
|
||||||
|
|
||||||
def material_filter_param default:
|
def material_filter_param default:
|
||||||
value = params[:material_filter].to_s.presence
|
value = params[:material_filter].to_s.presence
|
||||||
return default unless ['present', 'missing', 'any'].include?(value)
|
return default unless ['present', 'missing', 'any'].include?(value)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class TheatreCommentsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
limit = params[:limit].to_i
|
limit = params[:limit].to_i
|
||||||
limit = 20 if limit <= 0
|
limit = 20 if limit <= 0
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
no_gt = params[:no_gt].to_i
|
no_gt = params[:no_gt].to_i
|
||||||
no_gt = 0 if no_gt < 0
|
no_gt = 0 if no_gt < 0
|
||||||
@@ -9,6 +10,7 @@ class TheatreCommentsController < ApplicationController
|
|||||||
comments = TheatreComment
|
comments = TheatreComment
|
||||||
.where(theatre_id: params[:theatre_id])
|
.where(theatre_id: params[:theatre_id])
|
||||||
.where('no > ?', no_gt)
|
.where('no > ?', no_gt)
|
||||||
|
.includes(:user)
|
||||||
.order(no: :desc)
|
.order(no: :desc)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class TheatreProgrammesController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
limit = params[:limit].to_i
|
limit = params[:limit].to_i
|
||||||
limit = 100 if limit <= 0
|
limit = 100 if limit <= 0
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
position_gt = params[:position_gt].to_i
|
position_gt = params[:position_gt].to_i
|
||||||
position_gt = 0 if position_gt < 0
|
position_gt = 0 if position_gt < 0
|
||||||
@@ -10,7 +11,7 @@ class TheatreProgrammesController < ApplicationController
|
|||||||
.where(theatre_id: params[:theatre_id])
|
.where(theatre_id: params[:theatre_id])
|
||||||
.where('position > ?', position_gt)
|
.where('position > ?', position_gt)
|
||||||
.includes(:post)
|
.includes(:post)
|
||||||
.order(position: :desc).limit(100)
|
.order(position: :desc)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
|
||||||
render json: programmes.map { |programme|
|
render json: programmes.map { |programme|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class TheatreSkipEventsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
limit = params[:limit].to_i
|
limit = params[:limit].to_i
|
||||||
limit = 50 if limit <= 0
|
limit = 50 if limit <= 0
|
||||||
|
limit = 100 if limit > 100
|
||||||
|
|
||||||
events =
|
events =
|
||||||
TheatreSkipEvent
|
TheatreSkipEvent
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'List API limits', type: :request do
|
||||||
|
shared_examples 'a capped list' do |default_count, minimum_count, paginated|
|
||||||
|
def response_rows
|
||||||
|
body = json
|
||||||
|
body.is_a?(Array) ? body : body.fetch(collection_key)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'caps oversized limits at 100 and preserves the 100 boundary' do
|
||||||
|
get path, params: { locale: 'ja', limit: 100 }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows.size).to eq(100)
|
||||||
|
boundary_rows = response_rows
|
||||||
|
|
||||||
|
[101, 10_000].each do |limit|
|
||||||
|
get path, params: { locale: 'ja', limit: }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows).to eq(boundary_rows)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'preserves the default, nonpositive and small positive limits' do
|
||||||
|
get path, params: { locale: 'ja' }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows.size).to eq(default_count)
|
||||||
|
|
||||||
|
[0, -1].each do |limit|
|
||||||
|
get path, params: { locale: 'ja', limit: }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows.size).to eq(minimum_count)
|
||||||
|
end
|
||||||
|
|
||||||
|
get path, params: { locale: 'ja', limit: 2 }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows.size).to eq(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if paginated
|
||||||
|
it 'uses the capped limit for page offsets and preserves total count' do
|
||||||
|
get path, params: { locale: 'ja', limit: 100 }
|
||||||
|
first_page = response_rows
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(json.fetch('count')).to eq(101)
|
||||||
|
|
||||||
|
get path, params: { locale: 'ja', limit: 100, page: 2 }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows.size).to eq(1)
|
||||||
|
second_page = response_rows
|
||||||
|
expect(first_page & second_page).to be_empty
|
||||||
|
|
||||||
|
get path, params: { locale: 'ja', limit: 101, page: 2 }
|
||||||
|
expect(response).to have_http_status(:ok)
|
||||||
|
expect(response_rows).to eq(second_page)
|
||||||
|
expect(json.fetch('count')).to eq(101)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'posts' do
|
||||||
|
let(:path) { '/posts' }
|
||||||
|
let(:collection_key) { 'posts' }
|
||||||
|
before { create_list(:post, 101) }
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'tags' do
|
||||||
|
let(:path) { '/tags' }
|
||||||
|
let(:collection_key) { 'tags' }
|
||||||
|
before { create_list(:tag, 101) }
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'nico tags' do
|
||||||
|
let(:path) { '/tags/nico' }
|
||||||
|
let(:collection_key) { 'tags' }
|
||||||
|
before { create_list(:external_tag, 101) }
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'materials' do
|
||||||
|
let(:path) { '/materials' }
|
||||||
|
let(:collection_key) { 'materials' }
|
||||||
|
before do
|
||||||
|
101.times { |index| Material.create!(url: "https://example.com/material-#{ index }") }
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'post versions' do
|
||||||
|
let(:path) { '/posts/versions' }
|
||||||
|
let(:collection_key) { 'versions' }
|
||||||
|
let(:post) { create(:post) }
|
||||||
|
before do
|
||||||
|
101.times do |index|
|
||||||
|
PostVersion.create!(post:, version_no: index + 1, event_type: 'update',
|
||||||
|
url: post.url, tags: '', tags_json: [], parent_post_ids: '')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'tag versions' do
|
||||||
|
let(:path) { '/tags/versions' }
|
||||||
|
let(:collection_key) { 'versions' }
|
||||||
|
let(:tag) { create(:tag) }
|
||||||
|
before do
|
||||||
|
101.times do |index|
|
||||||
|
TagVersion.create!(tag:, version_no: index + 1, event_type: 'update',
|
||||||
|
name: 'limit tag', category: 'general', aliases: '',
|
||||||
|
parent_tag_ids: '', names: {
|
||||||
|
ja: { name: 'limit tag', script_code: 'Jpan',
|
||||||
|
auto_generated: false, aliases: [] } })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'material versions' do
|
||||||
|
let(:path) { '/materials/versions' }
|
||||||
|
let(:collection_key) { 'versions' }
|
||||||
|
let(:material) { Material.create!(url: 'https://example.com/material') }
|
||||||
|
before do
|
||||||
|
101.times do |index|
|
||||||
|
MaterialVersion.create!(material:, version_no: index + 1,
|
||||||
|
event_type: 'update', url: material.url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 1, true
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'theatre lists' do
|
||||||
|
let(:theatre) { create(:theatre) }
|
||||||
|
let(:post) { create(:post) }
|
||||||
|
|
||||||
|
context 'comments' do
|
||||||
|
let(:path) { "/theatres/#{ theatre.id }/comments" }
|
||||||
|
before { create_list(:theatre_comment, 101, theatre:, user: theatre.created_by_user) }
|
||||||
|
|
||||||
|
include_examples 'a capped list', 20, 20, false
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'programmes' do
|
||||||
|
let(:path) { "/theatres/#{ theatre.id }/programmes" }
|
||||||
|
before do
|
||||||
|
101.times do |index|
|
||||||
|
TheatreProgramme.create!(theatre:, post:, position: index + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 100, 100, false
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'skip events' do
|
||||||
|
let(:path) { "/theatres/#{ theatre.id }/skip_events" }
|
||||||
|
before do
|
||||||
|
101.times do |index|
|
||||||
|
TheatreSkipEvent.create!(theatre:, post:,
|
||||||
|
skipped_by_user: theatre.created_by_user,
|
||||||
|
created_at: Time.utc(2026, 1, 1) + index.seconds)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
include_examples 'a capped list', 50, 50, false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -482,7 +482,6 @@ RSpec.describe 'Tags API', type: :request do
|
|||||||
create(:tag, category: :general, primary_name: name, post_count: 1)
|
create(:tag, category: :general, primary_name: name, post_count: 1)
|
||||||
create(:external_tag, name:, post_count: 1)
|
create(:external_tag, name:, post_count: 1)
|
||||||
end
|
end
|
||||||
create(:external_tag, name: 'suffix_combined', post_count: 100)
|
|
||||||
|
|
||||||
get '/tags/autocomplete', params: { q: 'combined' }
|
get '/tags/autocomplete', params: { q: 'combined' }
|
||||||
|
|
||||||
@@ -491,39 +490,6 @@ RSpec.describe 'Tags API', type: :request do
|
|||||||
expect(json.map { |row| row.fetch('name') }).to eq(expected.first(20))
|
expect(json.map { |row| row.fetch('name') }).to eq(expected.first(20))
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'appends primary, alias, and external suffix matches without duplicate resources' do
|
|
||||||
prefix = create(:tag, primary_name: 'tail', post_count: 1)
|
|
||||||
create(:tag_name, :alias, name: 'tail_alias', tag: prefix)
|
|
||||||
create(:tag_name, :alias, name: 'alias_tail', tag: prefix)
|
|
||||||
create(:tag, primary_name: 'primary_tail', post_count: 4)
|
|
||||||
alias_target = create(:tag, primary_name: 'alias_target', post_count: 3)
|
|
||||||
create(:tag_name, :alias, name: 'suffix_tail', tag: alias_target)
|
|
||||||
external = create(:external_tag, id: prefix.id, name: 'external_tail', post_count: 5)
|
|
||||||
create(:tag, primary_name: 'middle_tail_only', post_count: 100)
|
|
||||||
create(:external_tag, name: 'middle_tail_only', post_count: 100)
|
|
||||||
|
|
||||||
get '/tags/autocomplete', params: { q: 'tail' }
|
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
|
||||||
expect(json.map { |row| row.fetch('name') }).to eq(
|
|
||||||
['tail', 'nico:external_tail', 'primary_tail', 'alias_target'])
|
|
||||||
expect(json.first.fetch('matched_alias')).to eq('tail_alias')
|
|
||||||
expect(json.last.fetch('matched_alias')).to eq('suffix_tail')
|
|
||||||
expect(json[1]).to include('id' => external.id, 'category' => 'nico')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'fills only the remaining places with suffix matches' do
|
|
||||||
names = 19.times.map { |number| "capacity_#{ number.to_s.rjust(2, '0') }" }
|
|
||||||
names.each { create(:tag, primary_name: _1, post_count: 1) }
|
|
||||||
create(:tag, primary_name: 'first_capacity', post_count: 3)
|
|
||||||
create(:external_tag, name: 'second_capacity', post_count: 2)
|
|
||||||
|
|
||||||
get '/tags/autocomplete', params: { q: 'capacity' }
|
|
||||||
|
|
||||||
expect(response).to have_http_status(:ok)
|
|
||||||
expect(json.map { |row| row.fetch('name') }).to eq(names + ['first_capacity'])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'excludes external tags but preserves internal alias matches when nico is false' do
|
it 'excludes external tags but preserves internal alias matches when nico is false' do
|
||||||
internal = create(:tag, category: :general, primary_name: 'switch_internal', post_count: 1)
|
internal = create(:tag, category: :general, primary_name: 'switch_internal', post_count: 1)
|
||||||
alias_target = create(:tag, category: :general, primary_name: 'alias_target', post_count: 1)
|
alias_target = create(:tag, category: :general, primary_name: 'alias_target', post_count: 1)
|
||||||
@@ -552,20 +518,12 @@ RSpec.describe 'Tags API', type: :request do
|
|||||||
create(:external_tag, name: literal, post_count: 1)
|
create(:external_tag, name: literal, post_count: 1)
|
||||||
create(:tag, category: :general, primary_name: 'literalXmatch', post_count: 2)
|
create(:tag, category: :general, primary_name: 'literalXmatch', post_count: 2)
|
||||||
create(:external_tag, name: 'literalXmatch', post_count: 2)
|
create(:external_tag, name: 'literalXmatch', post_count: 2)
|
||||||
suffix = "suffix_literal#{ wildcard }"
|
|
||||||
create(:tag, primary_name: suffix, post_count: 1)
|
|
||||||
suffix_alias = create(:tag, primary_name: 'suffix_alias_target', post_count: 1)
|
|
||||||
create(:tag_name, :alias, name: "alias_#{ suffix }", tag: suffix_alias)
|
|
||||||
create(:external_tag, name: suffix, post_count: 1)
|
|
||||||
create(:tag, primary_name: 'suffix_literalX', post_count: 2)
|
|
||||||
create(:external_tag, name: 'suffix_literalX', post_count: 2)
|
|
||||||
|
|
||||||
get '/tags/autocomplete', params: { q: "literal#{ wildcard }" }
|
get '/tags/autocomplete', params: { q: "literal#{ wildcard }" }
|
||||||
|
|
||||||
expect(json.map { |row| row.fetch('name') })
|
expect(json.map { |row| row.fetch('name') })
|
||||||
.to contain_exactly(
|
.to contain_exactly(
|
||||||
literal, primary_tag_name_for(alias_target, 'ja').name, "nico:#{ literal }",
|
literal, primary_tag_name_for(alias_target, 'ja').name, "nico:#{ literal }")
|
||||||
suffix, 'suffix_alias_target', "nico:#{ suffix }")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする