fix(captain): keep faq policy patch scoped
This commit is contained in:
parent
689cc114f8
commit
1cbc9f1123
@ -21,7 +21,6 @@ class Api::V1::Accounts::Captain::AssistantResponsesController < Api::V1::Accoun
|
|||||||
@response = Current.account.captain_assistant_responses.new(response_params)
|
@response = Current.account.captain_assistant_responses.new(response_params)
|
||||||
@response.documentable = Current.user
|
@response.documentable = Current.user
|
||||||
@response.save!
|
@response.save!
|
||||||
Captain::Llm::UpdateEmbeddingJob.perform_now(@response, "#{@response.question}: #{@response.answer}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@ -29,7 +28,7 @@ class Api::V1::Accounts::Captain::AssistantResponsesController < Api::V1::Accoun
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@response.destroy
|
@response.destroy!
|
||||||
head :no_content
|
head :no_content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class Api::V1::Accounts::Captain::BulkActionsController < Api::V1::Accounts::Bas
|
|||||||
end
|
end
|
||||||
|
|
||||||
def type_matches?
|
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
|
render json: { success: false }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
@ -37,7 +37,7 @@ class Api::V1::Accounts::Captain::BulkActionsController < Api::V1::Accounts::Bas
|
|||||||
|
|
||||||
case params[:fields][:status]
|
case params[:fields][:status]
|
||||||
when 'approve'
|
when 'approve'
|
||||||
responses.pending.update(status: 'approved')
|
responses.pending.update!(status: 'approved')
|
||||||
responses
|
responses
|
||||||
when 'delete'
|
when 'delete'
|
||||||
responses.destroy_all
|
responses.destroy_all
|
||||||
|
|||||||
@ -238,6 +238,23 @@ RSpec.describe 'Api::V1::Accounts::Captain::AssistantResponses', type: :request
|
|||||||
|
|
||||||
expect(response).to have_http_status(:unprocessable_entity)
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user