Merged
Conversation
- submitter is found by slug and authorized
bernardodsanderson
approved these changes
Mar 10, 2026
Collaborator
bernardodsanderson
left a comment
There was a problem hiding this comment.
LGTM! A few optional comments, nothing major.
| ) | ||
| end | ||
|
|
||
| describe 'POST /api/submitters/:slug/request_changes' do |
Collaborator
There was a problem hiding this comment.
[optional] We're missing a test case for non-completed submitter?
| expect(response).to have_http_status(:ok) | ||
| end | ||
|
|
||
| it 'is idempotent when changes already requested' do |
Collaborator
There was a problem hiding this comment.
TIL about idempotent 💡
config/routes.rb
Outdated
| resources :submitter_email_clicks, only: %i[create] | ||
| resources :submitter_form_views, only: %i[create] | ||
| resources :submitters, only: %i[index show update] | ||
| resources :submitters, only: %i[], param: 'slug' do |
Collaborator
There was a problem hiding this comment.
[optional] I don't think you need the %i, either way though
Suggested change
| resources :submitters, only: %i[], param: 'slug' do | |
| resources :submitters, only: [], param: :slug do |
| before_action :load_submitter | ||
|
|
||
| def request_changes | ||
| @submitter.update!(changes_requested_at: Time.current, completed_at: nil) unless @submitter.changes_requested_at? |
Collaborator
There was a problem hiding this comment.
[optional] So this endpoint modifies the submitter state without creating a SubmissionEvent. Not sure if that's something we want or not, but in other state transitions we seem to be doing that.
- Return 422 if submitter has not yet completed the form - Wrap state update in a transaction and create a SubmissionEvent (with optional reason and requested_by) to match web controller behavior - Add tests for: SubmissionEvent creation, reason param, non-completed submitter guard, and idempotent protection (duplicate creation on multiple calls) - Clean up routes: replace %i[] with [] and 'slug' string with :slug symbol
bernardodsanderson
approved these changes
Mar 10, 2026
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.
Summary
Adds a new API endpoint to programmatically request changes from a submitter after they've completed a form. Foundation for next PR, nothing to demo here.
Changes
POST /api/submitters/:slug/request_changesclearscompleted_at, setschanges_requested_at, allowing the submitter to re-fill the form