.vbw-planning/milestones/07-rails-audit-and-refactoring/06-test-infrastructure/03-PLAN.md
Use create_source! with appropriate attributes. Test the module's public method(s) directly, not through FeedFetcher integration. </action> <verify> PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/fetching/feed_fetcher/adaptive_interval_test.rb -- all tests pass </verify> <done> adaptive_interval_test.rb has 5+ tests covering interval calculation, bounds, and edge cases </done> </task> <task type="auto"> <name>Create SourceUpdater unit tests</name> <files> test/lib/source_monitor/fetching/feed_fetcher/source_updater_test.rb lib/source_monitor/fetching/feed_fetcher/source_updater.rb </files> <action> Read lib/source_monitor/fetching/feed_fetcher/source_updater.rb to understand the public interface. Create test/lib/source_monitor/fetching/feed_fetcher/source_updater_test.rb with tests covering:
Use create_source! with specific attributes. Stub external dependencies (HTTP, Feedjira) if SourceUpdater calls them -- but it likely operates on already-parsed data.
</action>
<verify>
PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/fetching/feed_fetcher/source_updater_test.rb -- all tests pass
</verify>
<done>
source_updater_test.rb has 5+ tests covering success/failure updates, log creation, and edge cases
</done>
</task>
<task type="auto">
<name>Create SharedLoggableTests module</name>
<files>
test/support/shared_loggable_tests.rb
</files>
<action>
Create test/support/shared_loggable_tests.rb with a SharedLoggableTests module (using ActiveSupport::Concern or plain module with def self.included(base)) that defines shared tests for the Loggable concern:
The including test class must define a build_loggable(overrides = {}) method that returns an unsaved instance of the concrete model (FetchLog, ScrapeLog, or HealthCheckLog).
</action>
<verify>
ruby -c test/support/shared_loggable_tests.rb (syntax valid)
</verify>
<done>
SharedLoggableTests module exists with 5+ shared test methods for Loggable concern contract
</done>
</task>
<task type="auto">
<name>Include SharedLoggableTests in log model tests</name>
<files>
test/models/source_monitor/fetch_log_test.rb
test/models/source_monitor/scrape_log_test.rb
test/models/source_monitor/health_check_log_test.rb
</files>
<action>
For each log model test file (create if missing):
build_loggable(overrides = {}) that returns an unsaved instance of the specific model with valid defaults (e.g., FetchLog.new(source: create_source!, started_at: Time.current))If the test file doesn't exist yet (likely for some log models), create it with the standard Minitest structure:
require "test_helper"
require_relative "../../../support/shared_loggable_tests"
module SourceMonitor
class FetchLogTest < ActiveSupport::TestCase
include SharedLoggableTests
# ...
end
end