Consolidate user settings update protocol - #1652
skyfallwastaken wants to merge 1 commit into
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a05ac7-e6c4-720e-b250-7b0cd93639bd Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Pull request overview
This PR consolidates the repeated “update current user settings + redirect/notice + validation re-render” protocol into a single helper on Settings::BaseController, then updates several settings controllers to use it to keep response behaviour consistent.
Changes:
- Added
update_user_settingstoSettings::BaseControllerto centralise update + redirect/back behaviour, notices, Inertiaclear_historysupport, and validation rendering. - Refactored Appearance, Editors, Privacy and Profile settings controllers to use the shared helper (keeping Appearance’s Inertia history clearing).
- Updated and added controller tests to assert redirect destinations (including referrer-based redirects), persisted settings, and flash notices/errors.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/controllers/settings/base_controller.rb | Introduces update_user_settings helper for consistent settings update/redirect/error handling. |
| app/controllers/settings/appearance_controller.rb | Switches theme update to use the shared helper while preserving clear_history. |
| app/controllers/settings/editors_controller.rb | Switches editors update to use the shared helper with direct redirect. |
| app/controllers/settings/privacy_controller.rb | Switches privacy update to use the shared helper with referrer-based redirect. |
| app/controllers/settings/profile_controller.rb | Switches profile section updates to use the shared helper with referrer-based redirect. |
| test/controllers/settings_appearance_controller_test.rb | Asserts flash notice is set on successful theme update (and keeps existing Inertia assertions). |
| test/controllers/settings_editors_controller_test.rb | Adds coverage for editors update persistence, redirect behaviour and success notice. |
| test/controllers/settings_profile_controller_test.rb | Updates redirect expectations to follow referrer, and strengthens invalid update assertions for flash error and persistence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Greptile SummaryConsolidates repeated user-settings update behavior into a private
Confidence Score: 5/5The PR appears safe to merge because the consolidated helper preserves the response behavior of every migrated settings action. Each migrated controller supplies the redirect mode and fallback used by its previous implementation, appearance retains Inertia history clearing, and validation failures retain the same flash and unprocessable-entity rendering path. Important Files Changed
Reviews (1): Last reviewed commit: "Consolidate settings update protocol" | Re-trigger Greptile |
f1786c8 to
6101271
Compare
Summary of the problem
Several simple settings controllers repeat the same user update, success notice, redirect and validation response protocol. This makes the stable response behaviour harder to keep consistent.
Describe your changes
Adds a narrow helper to Settings::BaseController for updates, direct or referrer based redirects, common notices and validation re renders. Appearance, Editors, Privacy and Profile now use it. Appearance still clears Inertia history.
The Slack and GitHub action stays custom to preserve its current synchronous Slack status side effect. Goals and notifications are unchanged.
Screenshots / Media
Not applicable. There are no visual changes.