Merge remote-tracking branch 'origin/feat/support-pdf-upload-faq-gen' into test-pdf-support-captain

This commit is contained in:
Tanmay Deep Sharma
2025-07-08 14:18:03 +07:00
388 changed files with 3943 additions and 560 deletions
@@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe Captain::Tools::PdfExtractionService do
let(:service) { described_class.new(pdf_source) }
let(:sample_pdf_path) { Rails.root.join('spec/fixtures/files/sample.pdf') }
let(:sample_pdf_path) { Rails.root.join('spec/fixtures/files/valid_test.pdf') }
describe '#initialize' do
context 'with valid PDF path' do
@@ -69,12 +69,16 @@ RSpec.describe Captain::Tools::PdfExtractionService do
end
context 'with malformed PDF' do
let(:pdf_source) { Rails.root.join('spec/fixtures/files/sample.txt').to_s }
let(:pdf_source) { sample_pdf_path.to_s }
it 'handles malformed PDF gracefully' do
# Mock PDF::Reader to raise a MalformedPDFError
allow(PDF::Reader).to receive(:open).and_raise(PDF::Reader::MalformedPDFError, 'PDF does not contain EOF marker')
result = service.perform
expect(result[:success]).to be false
expect(result[:errors]).to be_an(Array)
expect(result[:errors]).to include('Invalid or corrupted PDF file')
end
end
+1 -1
View File
@@ -262,7 +262,7 @@ RSpec.describe Inbox do
describe '#sanitized_name' do
context 'when inbox name contains forbidden characters' do
it 'removes forbidden and spam-trigger characters' do
inbox = FactoryBot.build(:inbox, name: 'Test/Name\\With<Bad>@Characters"And\'Quotes!#$%')
inbox = FactoryBot.build(:inbox, name: 'Test/Name\\With<Bad>@Characters"And\';:Quotes!#$%')
expect(inbox.sanitized_name).to eq('Test/NameWithBadCharactersAnd\'Quotes')
end
end