このコミットが含まれているのは:
2026-09-24 12:48:29 +09:00
コミット a0f1d0c4c3
3個のファイルの変更33行の追加1行の削除
+6
ファイルの表示
@@ -71,6 +71,12 @@ class NicoTagsController < ApplicationController
}, count: }
end
def show
tag = ExternalTag.find(params[:id])
render json: external_tag_json(tag)
end
def update
return head :unauthorized unless current_user
return head :forbidden unless current_user.gte_member?
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
resources :nico_tags, path: 'tags/nico', only: [:index, :update]
resources :nico_tags, path: 'tags/nico', only: [:index, :show, :update]
scope 'tags/:parent_id/children', controller: :tag_children do
post ':child_id', action: :create
+26
ファイルの表示
@@ -106,6 +106,32 @@ RSpec.describe 'NicoTags', type: :request do
end
end
describe 'GET /tags/nico/:id' do
it 'returns the external tag even when an internal tag has the same id' do
internal = create(:tag)
external = create(
:external_tag,
id: internal.id,
name: 'external_detail')
get "/tags/nico/#{ external.id }"
expect(response).to have_http_status(:ok)
expect(json).to include(
'id' => external.id,
'name' => 'nico:external_detail',
'category' => 'nico')
end
it 'returns 404 when the external tag does not exist' do
internal = create(:tag)
get "/tags/nico/#{ internal.id }"
expect(response).to have_http_status(:not_found)
end
end
describe 'PATCH /tags/nico/:id' do
let(:member) { create(:user, :member) }
let(:admin) { create(:user, :admin) }