You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Fix Couchbase integration test failures and improve error handling
This commit addresses the failing integration tests and implements a robust
error handling strategy for Couchbase connections.
## Problem Fixed
- 25 out of 27 integration tests were failing with "NoMethodError: undefined
method 'get' for nil"
- Couchbase collection constants (AIRLINE_COLLECTION, AIRPORT_COLLECTION,
ROUTE_COLLECTION) were nil due to silent initialization failures
## Changes Made
### Core Fixes
- Created CouchbaseConnection concern for centralized connection checking
- Updated all models (Airline, Airport, Route, Hotel) to use ensure_couchbase!
- Changed ApplicationController to inherit from ActionController::API
- Improved Couchbase initializer with environment-specific error handling and
retry logic for transient failures
- Removed skip_before_action :verify_authenticity_token from all API controllers
(not needed for ActionController::API)
### Code Organization
- Renamed HotelSearch model to Hotel for consistency with other models
- Reorganized test files following RSpec conventions:
* spec/requests/swagger/ - Swagger/rswag documentation specs
* spec/requests/api/v1/ - Integration test specs
* Removed test/integration/ directory
### New Features
- Added health check endpoint (GET /api/v1/health) for monitoring Couchbase
connectivity
- Added retry logic for CI to handle transient network failures
- Added comprehensive troubleshooting documentation in README.md
### CI/CD Improvements
- Updated CI workflow to validate Couchbase configuration before running tests
- Added connection test step to verify database availability
- Updated test paths to use spec/requests instead of test/integration
## Test Results
- All 27 integration tests now pass (0 failures)
- Swagger documentation regenerated successfully (64 examples)
- Health endpoint verified working
## Files Modified
- Models: airline.rb, airport.rb, route.rb, hotel.rb (renamed from hotel_search.rb)
- Controllers: airlines, airports, routes, hotels, health (new), application
- Config: couchbase.rb initializer, routes.rb, ci.yml
- Tests: Reorganized from test/integration/ to spec/requests/api/v1/
- Docs: README.md with troubleshooting guide
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
0 commit comments