Fix sample_data CLEAR=true scope, count message, and production guard - #82
Merged
Merged
Conversation
- Scope CLEAR=true deletion to non-"pages" post types so hand-authored static pages survive, matching the generator which skips "pages" - Print the count and scope of posts to be deleted before destroying, and report the actual deleted count (previously always "Cleared 0") - Harden the production guard: keep the interactive prompt when a TTY is present, but abort when stdin is not a TTY or gets returns nil (EOF), unless CONFIRM_PRODUCTION=true is set explicitly. EOF is never treated as consent. - Add tests covering the deleted-count message, static page preservation, and production non-interactive/EOF abort behavior Closes #59 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CAFZmU5SJSERBVyedpsYQW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #59
Summary
Fixes three problems in
lib/tasks/bunko/sample_data.rake:CLEAR=truedeleted ALL posts, including hand-authored static pages. The generator itself skips the reserved"pages"post type, so clearing is now scoped the same way:Post.joins(:post_type).where.not(post_types: {name: "pages"}). Static pages surviveCLEAR=true.Post.countafter deletion. The count is now captured before destroying, and the task prints exactly what will be deleted (count + scope: "Deleting N post(s) from all post types except 'pages'") before doing it, then reports the actual number cleared.$stdin.getsreturnsnilimmediately without a TTY (CI, cron, piped stdin), soCLEAR=truecould wipe production content with no confirmation. Now: the interactive prompt is kept when a TTY is present, but if$stdin.tty?is false orgetsreturnsnil(EOF), the task aborts unlessCONFIRM_PRODUCTION=trueis set explicitly. EOF is never treated as consent.Tests
Added to
test/tasks/bunko_sample_data_task_test.rb:CLEAR=truewhile non-page posts are clearedCONFIRM_PRODUCTION=trueCONFIRM_PRODUCTION=truegetsreturns nil (EOF) abortsResults
bundle exec rake(Ruby 4.0.2): 368 runs, 1343 assertions, 0 failures, 0 errors, 1 skip (pre-existing skip)bundle exec standardrb: no offenses🤖 Generated with Claude Code
https://claude.ai/code/session_01CAFZmU5SJSERBVyedpsYQW
Generated by Claude Code