Skip to content

Add comprehensive tests for PdfGeneratorService::HeaderGenerator#prepare_logo#227

Merged
stefan-burke merged 1 commit intomainfrom
terragon/test-prepare-logo-pdf-generator
Aug 22, 2025
Merged

Add comprehensive tests for PdfGeneratorService::HeaderGenerator#prepare_logo#227
stefan-burke merged 1 commit intomainfrom
terragon/test-prepare-logo-pdf-generator

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • Adds a new RSpec test suite for the PdfGeneratorService::HeaderGenerator class
  • Covers the private .prepare_logo method extensively
  • Tests behavior when PDF_LOGO environment variable is set, unset, or empty
  • Validates handling of user logo attachments, including missing or broken attachments
  • Ensures correct logo width calculation based on configured constants

Changes

Test Coverage

  • Created spec/services/pdf_generator_service/header_generator_spec.rb with 155 lines of tests
  • Mocked file reading and environment variables to simulate different logo sources
  • Verified that environment variable logo takes precedence over user logo
  • Tested error handling for missing logo files and broken ActiveStorage attachments
  • Confirmed that empty or nil user returns empty logo data
  • Checked that logo width calculation matches expected formula

Test plan

  • Run the new RSpec tests to ensure all cases pass
  • Validate error raising for missing files and broken attachments
  • Confirm logo data is correctly returned from environment variable or user attachment
  • Verify logo width calculation consistency

This PR improves the reliability and robustness of the PDF header logo generation by ensuring all edge cases are tested and handled properly.

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/4bce113e-130d-4528-ae5e-ee1fe7832b73

…go method

Add comprehensive tests for the PdfGeneratorService::HeaderGenerator's private method prepare_logo. These tests cover scenarios including when the PDF_LOGO environment variable is set or unset, user logo attachment presence, error handling for missing files, and logo dimension calculations based on configuration.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke marked this pull request as ready for review August 22, 2025 11:03
@stefan-burke stefan-burke merged commit b911903 into main Aug 22, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/test-prepare-logo-pdf-generator branch August 22, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant