a52b6f1c87
* Add explicit wrap_parameters to controllers for flat JSON API support Virtual attributes (has_rich_text, has_one_attached, delegated setters, ActiveModel attrs) are not in Model.attribute_names, so wrap_parameters auto-detection silently drops them from flat JSON requests. Add explicit include: lists matching each controller's permitted params. * Convert short-form wrap_parameters to explicit include: lists Defense-in-depth: these controllers only have real-column params today, so auto-detection works, but explicit lists prevent future regressions if virtual attributes are added. * Add flat JSON param tests for all wrap_parameters controllers 17 new tests covering every controller with wrap_parameters, verifying that flat (unwrapped) JSON payloads are correctly wrapped and processed. Focuses on virtual attributes that would be silently dropped without explicit include: lists.
45 lines
1013 B
Ruby
45 lines
1013 B
Ruby
class Signups::CompletionsController < ApplicationController
|
|
wrap_parameters :signup, include: %i[ full_name ]
|
|
|
|
layout "public"
|
|
|
|
disallow_account_scope
|
|
|
|
def new
|
|
@signup = Signup.new(identity: Current.identity)
|
|
end
|
|
|
|
def create
|
|
@signup = Signup.new(signup_params)
|
|
|
|
if @signup.complete
|
|
welcome_to_account
|
|
else
|
|
invalid_signup
|
|
end
|
|
end
|
|
|
|
private
|
|
def signup_params
|
|
params.expect(signup: %i[ full_name ]).with_defaults(identity: Current.identity)
|
|
end
|
|
|
|
def welcome_to_account
|
|
respond_to do |format|
|
|
format.html do
|
|
flash[:welcome_letter] = true
|
|
redirect_to landing_url(script_name: @signup.account.slug)
|
|
end
|
|
|
|
format.json { head :created }
|
|
end
|
|
end
|
|
|
|
def invalid_signup
|
|
respond_to do |format|
|
|
format.html { render :new, status: :unprocessable_entity }
|
|
format.json { render json: { errors: @signup.errors.full_messages }, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|