fix(captain): keep faq policy patch scoped

This commit is contained in:
Codex CLI 2026-05-04 13:21:38 +00:00
parent 689cc114f8
commit 1cbc9f1123
3 changed files with 20 additions and 4 deletions

View File

@ -21,7 +21,6 @@ class Api::V1::Accounts::Captain::AssistantResponsesController < Api::V1::Accoun
@response = Current.account.captain_assistant_responses.new(response_params)
@response.documentable = Current.user
@response.save!
Captain::Llm::UpdateEmbeddingJob.perform_now(@response, "#{@response.question}: #{@response.answer}")
end
def update
@ -29,7 +28,7 @@ class Api::V1::Accounts::Captain::AssistantResponsesController < Api::V1::Accoun
end
def destroy
@response.destroy
@response.destroy!
head :no_content
end

View File

@ -19,7 +19,7 @@ class Api::V1::Accounts::Captain::BulkActionsController < Api::V1::Accounts::Bas
end
def type_matches?
return if MODEL_TYPE.include?(params[:type])
return false if MODEL_TYPE.include?(params[:type])
render json: { success: false }, status: :unprocessable_entity
end
@ -37,7 +37,7 @@ class Api::V1::Accounts::Captain::BulkActionsController < Api::V1::Accounts::Bas
case params[:fields][:status]
when 'approve'
responses.pending.update(status: 'approved')
responses.pending.update!(status: 'approved')
responses
when 'delete'
responses.destroy_all

View File

@ -238,6 +238,23 @@ RSpec.describe 'Api::V1::Accounts::Captain::AssistantResponses', type: :request
expect(response).to have_http_status(:unprocessable_entity)
end
it 'returns unprocessable entity when question exceeds 255 characters' do
long_question = 'a' * 256
post "/api/v1/accounts/#{account.id}/captain/assistant_responses",
params: {
assistant_response: {
question: long_question,
answer: 'Test answer',
assistant_id: assistant.id
}
},
headers: admin.create_new_auth_token,
as: :json
expect(response).to have_http_status(:unprocessable_entity)
end
end
end