Skip to content

Add comprehensive request specs for InspectionsController with enhanced coverage and error handling#222

Merged
stefan-burke merged 3 commits intomainfrom
terragon/test-inspections-controller-lines
Aug 22, 2025
Merged

Add comprehensive request specs for InspectionsController with enhanced coverage and error handling#222
stefan-burke merged 3 commits intomainfrom
terragon/test-inspections-controller-lines

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

@stefan-burke stefan-burke commented Aug 21, 2025

Summary

  • Adds extensive request specs covering InspectionsController actions
  • Tests GET, PATCH, and POST endpoints with various contexts and edge cases
  • Covers JSON responses, error handling, event logging, prefill logic, and inactive user redirects
  • Includes new tests for assessments disabled scenario, HEAD requests, event log display, and image processing errors
  • Adds validation for inspection completability with environment-specific behaviors
  • Enhances change tracking and event logging on updates

Changes

Request Specs

  • Created spec/requests/inspections/inspections_coverage_spec.rb with 416 lines of tests
  • Created spec/requests/inspections/inspections_spec.rb with 292 lines of additional tests
  • Tests for GET /show including HEAD requests and JSON format responses
  • Tests for PATCH /update handling image processing errors gracefully
  • Tests for PATCH /update_unit with success and failure scenarios
  • Tests for GET /log to verify inspection event logs
  • Tests behavior when assessments are disabled via environment variable
  • Tests assessment params handling and filtering of system attributes
  • Tests validation of inspection completability with different environment behaviors
  • Tests prefill functionality for inspection edit views with previous inspection data
  • Tests error handling in inspection event logging
  • Tests change tracking and event logging on updates
  • Tests validation and redirection for invalid tab parameters
  • Tests handling of inactive users with appropriate redirects

Test plan

  • Run the full RSpec suite to ensure all new request specs pass
  • Verify coverage improvements for InspectionsController endpoints
  • Confirm error handling and edge cases are properly tested and handled

🌿 Generated by Terry


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

📎 Task: https://www.terragonlabs.com/task/ad86a8ec-5585-4145-b7a5-2b332a846b97

stefan-burke and others added 3 commits August 21, 2025 09:18
…troller

- Add extensive request specs covering GET show, PATCH update, PATCH update_unit, GET log actions
- Test handling of image processing errors, unit updates, event logging, and assessment params
- Verify behavior with assessments disabled and inactive users
- Include tests for prefill functionality, validation, and error handling
- Ensure coverage of event logging and change tracking in inspection updates
- Improve test coverage and robustness for inspections feature

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

- Use actual InspectionBlueprint rendering for JSON response test
- Add tests for assessment params handling including updates and filtering
- Enhance error logging test in production environment
- Refine prefill field translation tests for assessments
- Verify change tracking and event logging on inspection updates
- Remove mocks and improve test reliability and coverage

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

- Add tests for assessments disabled scenario returning 404
- Add JSON format response test for inspection data
- Add image processing error handling test
- Add event logging verification on unit change
- Add HEAD request test for inspections
- Add inspection event log display test
- Add prefill functionality tests for inspection edit
- Add validation for tab parameter in edit action
- Add error handling tests for inspection event logging
- Add tests for tracking changes in inspection updates
- Add tests for validating inspection completability with error handling

This commit significantly improves test coverage and robustness of the inspections controller.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke changed the title Add comprehensive request specs for InspectionsController Add comprehensive request specs for InspectionsController with enhanced coverage and error handling Aug 22, 2025
@stefan-burke stefan-burke marked this pull request as ready for review August 22, 2025 10:07
@stefan-burke stefan-burke merged commit de80577 into main Aug 22, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/test-inspections-controller-lines branch October 12, 2025 22:51
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