Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE | Ask Va Api: Add test_create endpoint #16391

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Dismissed Show dismissed Hide dismissed

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
Loading