Remove raising status validator so invalid status returns a validation error - #85
Merged
Merged
Conversation
validate_status_value raised ArgumentError inside a validation callback, so a tampered form/API status value produced a 500 instead of a validation error. The inclusion validation on :status already covers the same check, so the custom validator is deleted and tests now assert validation errors instead of raises. Closes #56 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MSumqtaUuj2UhU4Wtm1C1H
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.
Fixes the 500 caused by raising ArgumentError inside a validation callback.
Problem
validate_status_valueinlib/bunko/models/post_methods/publishable.rbraisedArgumentErrormid-validation, so a tampered form/API status value produced a 500 instead ofvalid? == false. It also duplicated the existinginclusionvalidation on:status.Changes
validate_status_valueand itsvalidateregistration; theinclusionvalidation already covers invalid values.test/models/post_publishing_test.rb: invalid status now assertsActiveRecord::RecordInvalid/ errors on:statusinstead ofArgumentError; blank status asserts the presence error.QA Notes
Saving a post with any invalid status now adds
"<value> is not a valid status"toerrors[:status]and never raises.Test coverage
Publishing suite passes (59 runs, 0 failures); standardrb clean.
Closes #56
🤖 Generated with Claude Code
https://claude.ai/code/session_01MSumqtaUuj2UhU4Wtm1C1H