Merge branch 'develop' into chore/update-rails

This commit is contained in:
Sojan Jose
2025-03-18 01:29:19 -07:00
committed by GitHub
42 changed files with 576 additions and 310 deletions
@@ -58,6 +58,23 @@ RSpec.describe 'Public Articles API', type: :request do
expect(response_data[1][:views]).to eq(1)
expect(response_data.last[:id]).to eq(article.id)
end
it 'limits results based on per_page parameter' do
get "/hc/#{portal.slug}/#{category.locale}/articles.json", params: { per_page: 2 }
expect(response).to have_http_status(:success)
response_data = JSON.parse(response.body, symbolize_names: true)[:payload]
expect(response_data.length).to eq(2)
expect(JSON.parse(response.body, symbolize_names: true)[:meta][:articles_count]).to eq(5)
end
it 'uses default items per page if per_page is less than 1' do
get "/hc/#{portal.slug}/#{category.locale}/articles.json", params: { per_page: 0 }
expect(response).to have_http_status(:success)
response_data = JSON.parse(response.body, symbolize_names: true)[:payload]
expect(response_data.length).to eq(3)
end
end
describe 'GET /public/api/v1/portals/:slug/articles/:id' do
@@ -2,17 +2,27 @@ require 'rails_helper'
RSpec.describe 'Twilio::CallbacksController', type: :request do
include Rails.application.routes.url_helpers
let(:twilio_service) { instance_double(Twilio::IncomingMessageService) }
before do
allow(Twilio::IncomingMessageService).to receive(:new).and_return(twilio_service)
allow(twilio_service).to receive(:perform)
end
describe 'POST /twilio/callback' do
let(:params) do
{
'From' => '+1234567890',
'To' => '+0987654321',
'Body' => 'Test message',
'AccountSid' => 'AC123',
'SmsSid' => 'SM123'
}
end
describe 'GET /twilio/callback' do
it 'calls incoming message service' do
post twilio_callback_index_url, params: {}
expect(twilio_service).to have_received(:perform)
it 'enqueues the Twilio events job' do
expect do
post twilio_callback_index_url, params: params
end.to have_enqueued_job(Webhooks::TwilioEventsJob).with(params)
end
it 'returns no content status' do
post twilio_callback_index_url, params: params
expect(response).to have_http_status(:no_content)
end
end
end
@@ -2,17 +2,25 @@ require 'rails_helper'
RSpec.describe 'Twilio::DeliveryStatusController', type: :request do
include Rails.application.routes.url_helpers
let(:twilio_service) { instance_double(Twilio::DeliveryStatusService) }
before do
allow(Twilio::DeliveryStatusService).to receive(:new).and_return(twilio_service)
allow(twilio_service).to receive(:perform)
end
describe 'POST /twilio/delivery_status' do
let(:params) do
{
'MessageSid' => 'SM123',
'MessageStatus' => 'delivered',
'AccountSid' => 'AC123'
}
end
describe 'POST /twilio/delivery' do
it 'calls incoming message service' do
post twilio_delivery_status_index_url, params: {}
expect(twilio_service).to have_received(:perform)
it 'enqueues the Twilio delivery status job' do
expect do
post twilio_delivery_status_index_url, params: params
end.to have_enqueued_job(Webhooks::TwilioDeliveryStatusJob).with(params)
end
it 'returns no content status' do
post twilio_delivery_status_index_url, params: params
expect(response).to have_http_status(:no_content)
end
end
end