Skip to content

Add comprehensive RSpec tests for ImageProcessable concern#248

Merged
stefan-burke merged 4 commits intomainfrom
terragon/increase-rspec-coverage-image-processable
Sep 2, 2025
Merged

Add comprehensive RSpec tests for ImageProcessable concern#248
stefan-burke merged 4 commits intomainfrom
terragon/increase-rspec-coverage-image-processable

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • Introduces extensive RSpec tests for the ImageProcessable concern in the controller context
  • Covers image parameter processing, image uploading, validation, and error handling
  • Ensures robust handling of valid and invalid images, including edge cases and exceptions

Changes

New Test Suite: image_processable_spec.rb

  • Controller Setup: Anonymous controller including ImageProcessable with routes for create, upload, and validate actions
  • process_image_params Tests:
    • Validates processing of single and multiple image fields
    • Confirms skipping of blank or non-file parameters
    • Handles invalid images by setting fields to nil
    • Tests graceful handling of NotAnImageError and ImageProcessingError
  • process_image Tests:
    • Verifies successful processing returns processed IO
    • Checks invalid images raise NotAnImageError and redirect with alert
    • Tests processing failures and Vips errors with proper logging and user feedback
  • validate_image! Tests:
    • Confirms valid images pass without error
    • Ensures invalid images raise NotAnImageError with appropriate response
  • handle_image_error Tests:
    • Tests HTML and Turbo Stream responses for image-related errors
    • Validates flash messages and redirects
  • Rescue_from Handlers:
    • Confirms controller rescues from NotAnImageError and ImageProcessingError with redirects and alerts
  • Integration with Strong Parameters:
    • Ensures compatibility with ActionController::Parameters for image processing

Test plan

  • Run all new specs to verify coverage and correctness
  • Confirm error handling paths do not raise unexpected exceptions
  • Validate flash messages and HTTP responses for error scenarios
  • Ensure image processing logic behaves as expected with mocks and stubs

🌿 Generated by Terry


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

📎 Task: https://www.terragonlabs.com/task/b02ed618-0b63-493c-98a0-60266fe931c1

stefan-burke and others added 4 commits September 1, 2025 02:07
…ble concern

Add a new spec file for the ImageProcessable concern with 346 lines of tests covering:
- process_image_params method for valid, invalid, blank, and non-file inputs
- process_image method for valid, invalid, and error scenarios
- validate_image! method for validation success and failure
- handle_image_error method for different error handling formats
- rescue_from handlers for image-related errors
- integration with ActionController::Parameters

This ensures robust test coverage for image processing functionality in controllers.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
… processing

- Added new flash partial for displaying flash messages in views.
- Expanded ImageProcessable concern controller tests with new test methods for create, upload, validate actions.
- Added tests for error handling methods and rescue_from handlers for image processing errors.
- Improved test coverage for image validation, processing, and error scenarios.
- Refactored test syntax for consistency and clarity.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…ith flash

- Changed turbo_stream error response to redirect_back with status :see_other instead of rendering a partial.
- Updated specs to expect redirect and flash message handling for turbo_stream format.
- Improved test formatting and consistency in image_processable_spec.rb.

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 September 2, 2025 17:54
@stefan-burke stefan-burke merged commit c3edb80 into main Sep 2, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/increase-rspec-coverage-image-processable branch September 2, 2025 17:54
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