Rename Person tab to Profile, add client property ownership #169
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "rename-person-to-profile"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Rename "Person" to "Profile" throughout the app. Remove the Platform nav slot (Feature Flags remains accessible from Profile page). Add
owner_usernameto properties so clients can create and edit their own property via self-service.Changes
owner_username(string, indexed) column to properties tableProfileController#indexloads client's property viaowner_username/properties/newroute + form for client self-service property creationauthorize_property_accessbefore_action: clients can only view/edit properties they ownTest Plan
/profilereturns 200,/personreturns 404/properties/newand create a propertyowner_usernamestampedReview Checklist
.person-*selectors)Related Notes
Closes #137
Foundation for Phase 3 client self-service. The
owner_usernamecolumn enables the client request flow (#123) where clients interact with their own property from the Profile page.PR #169 Review
DOMAIN REVIEW
Stack: Ruby on Rails 8.1, RSpec request specs, PostgreSQL migration.
Authorization logic (
authorize_property_access):@propertyviaProperty.find(params[:id])-- raisesActiveRecord::RecordNotFound(404) for non-existent IDs.head :not_foundfor non-owners -- correct security pattern (no 403 info leak).owner_usernameis NOT inproperty_params-- cannot be mass-assigned by user input. Server-side stamping only. Good.createaction logic:owner_usernameonly when user hasclientrole AND does NOT haveleadrole. This means a lead who is also a client does NOT get stamped -- intentional (leads manage all properties). Reasonable.:editinstead of:new. This is a bug -- the user came from/properties/newbut on error sees the edit template (which has different fields like the "Active" checkbox and "Save" button instead of "Create Property").require_rolewithexcept::require_role :lead, :admin, :super_admin, except: [:show, :new, :edit, :create, :update]-- this meansindex,manage,resolve,toggle_activestill require lead+. The excepted actions (show,new,edit,create,update) are open to ALL authenticated users. This is intentional but relies entirely onauthorize_property_accessforshow/edit/update. Thenewandcreateactions are unguarded -- any authenticated user (member, client, lead, etc.) can create a property. That may be acceptable as a design choice, but it is worth noting thatmemberrole users can also create properties.Migration safety:
add_column+add_index-- safe, reversible, no data loss risk. Non-nullable constraint not set (appropriate since existing rows have no owner).BLOCKERS
1. Spec/View mismatch -- tests will FAIL (BLOCKER)
The view (
profile/index.html.erb) removed the role guard on "My Property":But the spec still asserts "My Property" is NOT visible to member/lead/admin/super_admin:
Lines 80-105 of the renamed spec contain 4 assertions that will fail against the new view. These must be updated to match the new behavior (My Property visible to all roles) or the tests will break CI.
2.
createrenders wrong template on validation failure (BLOCKER)This renders the
edittemplate which has an "Active" checkbox and "Save" button that don't exist in thenewform context. Should berender :new.NITS
Branch naming: Branch is
rename-person-to-profile-- SOP convention is{issue-number}-{kebab-case}, should be137-rename-person-to-profile. Non-blocking but noted.newaction open to all roles: Any authenticated user (includingmember) can hit/properties/newandcreate. If the intent is client-only self-service, consider addingrequire_role :client, :lead, :admin, :super_admin, only: [:new, :create]or a before_action guard. Currently amemberwith no client role can create a property (though it won't getowner_usernamestamped).No spec coverage for
new/createactions: The existingproperties_spec.rbhas no tests forGET /properties/neworPOST /propertiesfrom a client perspective. The Test Plan in the PR body lists these as manual checks, but automated coverage for the authorization boundary would strengthen confidence. Not a blocker since existing property specs cover the CRUD path, but the new ownership-guarded path deserves its own spec context.Platform nav slot removal: The gear icon for Platform is removed from the nav bar but Feature Flags remains accessible from the Profile page. The removal is clean but there's no redirect/deprecation for users who bookmarked the nav position. Low risk.
CSS rename completeness: The rename from
.person-*to.profile-*covers all 6 selectors in the stylesheet. No orphaned references found. Clean.SOP COMPLIANCE
rename-person-to-profile-- missing137-prefix)PROCESS OBSERVATIONS
VERDICT: NOT APPROVED
Two blockers must be resolved:
profile_spec.rb"My Property section" assertions to expect visibility for ALL roles (matching the new unconditional view).render :edittorender :newin thecreateaction's failure path.PR #169 Re-Review
PREVIOUS BLOCKERS -- RESOLVED
Spec/view mismatch on "My Property" visibility -- FIXED. The view now renders the "My Property" section unconditionally (no role guard), and the spec iterates all five roles asserting visibility for each. Behavior and test are aligned.
createaction rendered:editon failure -- FIXED. Now correctly renders:new, status: :unprocessable_entity.DOMAIN REVIEW (Ruby on Rails)
Authorization model (
require_rolewithexcept):The PR changes the line to:
This means
show,new,edit,create, andupdatebypass the role gate entirely -- any authenticated user can hit these actions. Theauthorize_property_accessbefore_action only covers[:show, :edit, :update]. This means:new-- open to all authenticated users. Acceptable for self-service.create-- open to all authenticated users. The action stampsowner_usernameonly for clients who are NOT leads, which is correct behavior.This is intentionally open by design (self-service property creation). The ownership check on show/edit/update ensures clients can only access their own property. Leads/admins/super_admins bypass. Sound authorization model.
Migration: Simple
add_column+add_index, fully reversible. No data migration needed.Property model:
owned_byscope added. Clean.Controller logic:
authorize_property_accessloads@propertyonce and short-circuits for privileged roles or ownership match. Returnshead :not_foundto avoid leaking existence. This is well-structured.BLOCKERS
None.
NITS
owner_usernamenot inproperty_paramswhitelist -- Currently the owner is set programmatically increate, which is correct. However, if a futureupdateaction needs to reassign ownership, this will need to be added. For now, the omission is intentional and secure (prevents clients from modifying ownership via form submission). Just noting for awareness.No spec coverage for
newandcreateactions -- The profile spec tests the profile page well, but there are no request specs exercisingGET /properties/neworPOST /propertiesfor the client self-service flow. This is borderline -- the authorization logic and ownership stamping are important paths. Consider adding specs for: (a) client can create a property, (b) created property getsowner_usernamestamped, (c) client cannot access another user's property. These are listed in the Test Plan but not implemented in this PR.CSS rename is thorough -- All
.person-*classes renamed to.profile-*. No orphaned selectors found.SOP COMPLIANCE
rename-person-to-profile-- descriptive, though not prefixed with issue number137-)PROCESS OBSERVATIONS
VERDICT: APPROVED