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
Fix question/answer feature bugs - all tests passing
**Rails 8 params.expect() Issue:**
- Changed PeopleController person_params from params.expect() to params.require().permit()
(same fix as BillablesController - nested attributes with dynamic keys don't work with expect)
- Fixed update_answers to handle ActionController::Parameters correctly (not a Hash)
**Dynamic Question Loading:**
- Created person_questions_controller.js Stimulus controller for AJAX updates
- Added PeopleController#get_questions action for dynamic question fetching
- Split questions partial into container (_questions.html.erb) and content (_questions_content.html.erb)
- Modified Person model to support pre-calculated questions for AJAX
- Connected package select and option checkboxes to trigger dynamic updates
- Only update on user interaction, not on initial page load (prevent form conflicts)
**Question Removal Fix:**
- Changed from rendering _destroy checkbox to creating _destroy field dynamically via JavaScript
- Prevents ActiveRecord from seeing questions as 'changed' when they're not
- Avoids triggering validation errors on unrelated questions
- JavaScript now creates hidden _destroy field only when Remove Question is clicked
**Form Field Fixes:**
- Fixed textarea label association so Capybara can find fields by label text
- Updated questions_controller.js removeQuestion to create field dynamically
**Test Improvements:**
- Added proper waits for dynamic content loading
- Used specific selectors for clicking Remove Question link
- Added assertions to verify JavaScript behavior (element hiding, field creation)
- All 13 question tests now passing (100% success rate, 39 assertions)
**Core Functionality Working:**
✅ Add questions to billable options
✅ Remove questions from options
✅ Questions appear dynamically when options/packages selected
✅ Answer radio button questions
✅ Answer textarea questions
✅ Save answers to database
✅ Summary views and PDF generation
0 commit comments