Skip to content

Commit

Permalink
[Automated] Merged master into target preview_envs_k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 17, 2024
2 parents 8c20d70 + 4d200de commit 866dfdc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class InquiriesController < ApplicationController
around_action :handle_exceptions
before_action :get_inquiries_by_icn, only: [:index]
before_action :get_inquiry_by_id, only: [:show]
skip_before_action :authenticate, only: %i[unauth_create upload_attachment]
skip_before_action :verify_authenticity_token, only: %i[unauth_create upload_attachment]
skip_before_action :authenticate, only: %i[unauth_create upload_attachment test_create]
skip_before_action :verify_authenticity_token, only: %i[unauth_create upload_attachment test_create]

def index
render json: @user_inquiries.payload, status: @user_inquiries.status
Expand All @@ -17,6 +17,14 @@ def show
render json: @inquiry.payload, status: @inquiry.status
end

def test_create
service = Crm::Service.new(icn: nil)
payload = { reply: params[:reply] }
response = service.call(endpoint: params[:endpoint], method: :post, payload:)

render json: response.to_json, status: :ok
end

def create
render json: { message: 'success' }, status: :created
end
Expand Down
1 change: 1 addition & 0 deletions modules/ask_va_api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
post '/inquiries', to: 'inquiries#unauth_create'
post '/upload_attachment', to: 'inquiries#upload_attachment'
post '/inquiries/:id/reply/new', to: 'inquiries#create_reply'
post '/test_create', to: 'inquiries#test_create'

# static_data
get '/categories', to: 'static_data#categories'
Expand Down
13 changes: 13 additions & 0 deletions modules/ask_va_api/spec/requests/v0/inquiries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@
end
end

describe 'POST #test_create' do
before do
allow_any_instance_of(Crm::Service).to receive(:call).and_return({ message: 'success' })
post '/ask_va_api/v0/test_create',
params: { 'reply' => 'test', 'endpoint' => 'inquiries/id/reply/new' },
as: :json
end

it 'response with 200' do
expect(response).to have_http_status(:ok)
end
end

describe 'GET #show' do
let(:expected_response) do
{ 'data' =>
Expand Down

0 comments on commit 866dfdc

Please sign in to comment.