.vbw-planning/milestones/07-rails-audit-and-refactoring/02-model-layer-hardening/02-SUMMARY.md
Moved ensure_feed_content_record from a manual call in ItemCreator to an after_create_commit callback on Item, so ItemContent records are automatically created when items with feed content are persisted. Also cleaned up compute_feed_word_count local variable naming for clarity.
f62a63c fix(models): move ensure_feed_content_record to after_create_commit callbackb66d6b2 fix(tests): update tests for after_create_commit item_content callbackClean up compute_feed_word_count -- Renamed local variable from content to feed_content in ItemContent#compute_feed_word_count for clarity and to avoid shadowing the model attribute name.
Add after_create_commit callback to Item -- Added after_create_commit :ensure_feed_content_record, if: -> { content.present? } so ItemContent records are automatically created when items with feed content are persisted.
Remove manual ensure_feed_content_record call from ItemCreator -- Removed the explicit call in ItemCreator#create_new_item since the callback now handles it. The public method remains available for backfill operations.
Write tests for callback behavior -- Replaced 3 manual-call tests with 4 tests covering: auto-creation on item create with content, no creation without content, idempotency of manual calls, and blank content guard.
| Action | Path |
|---|---|
| MODIFY | app/models/source_monitor/item_content.rb |
| MODIFY | app/models/source_monitor/item.rb |
| MODIFY | lib/source_monitor/items/item_creator.rb |
| MODIFY | test/models/source_monitor/item_test.rb |
| MODIFY | test/models/source_monitor/source_test.rb |
| MODIFY | test/lib/source_monitor/analytics/scrape_recommendations_test.rb |
| MODIFY | test/lib/source_monitor/dashboard/stats_query_test.rb |
| MODIFY | test/controllers/source_monitor/dashboard_controller_test.rb |
| MODIFY | test/controllers/source_monitor/source_scrape_tests_controller_test.rb |
| MODIFY | test/controllers/source_monitor/sources_controller_test.rb |
| MODIFY | test/controllers/source_monitor/items_controller_test.rb |
| MODIFY | test/jobs/source_monitor/download_content_images_job_test.rb |
| MODIFY | test/tasks/backfill_word_counts_task_test.rb |