feat: enhance application update logic to handle non-editable statuses#2585
feat: enhance application update logic to handle non-editable statuses#2585AnujChhikara wants to merge 2 commits intodevelopfrom
Conversation
- Added a check to prevent updates on applications that are not in an editable status, returning a conflict error when attempting to edit reviewed applications. - Updated integration tests to verify the new behavior for applications that have already been reviewed. - Enhanced unit tests to ensure proper error handling for non-editable application statuses.
WalkthroughThe PR prevents editing of applications that have already been reviewed. Applications can only be edited when their status is PENDING or CHANGES_REQUESTED; attempting to edit others returns a 409 conflict. Successful edits reset status to PENDING. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@models/applications.ts`:
- Around line 153-163: The current guard checks isEditableApplicationStatus
(using APPLICATION_STATUS_TYPES) before verifying ownership, which leaks status
info; change the order in the function so you first compare application.userId
against userId and return { status: APPLICATION_STATUS.unauthorized } if they
differ, and only after passing that ownership check evaluate
isEditableApplicationStatus and return { status: APPLICATION_STATUS.notPending }
as needed; update the block that references isEditableApplicationStatus,
application.userId, userId, APPLICATION_STATUS_TYPES,
APPLICATION_STATUS.notPending, and APPLICATION_STATUS.unauthorized accordingly.
In `@test/integration/application.test.ts`:
- Around line 542-555: Update the test fixture so the created application is
explicitly marked as reviewed before calling applicationModel.addApplication:
when building reviewedApplicationData (currently derived from
applicationsData[1]), add the non-editable status property (use the project's
canonical value or enum, e.g. APPLICATION_STATUSES.REVIEWED or the string used
elsewhere) so the test always exercises the "already reviewed" branch; ensure
you modify the object passed to applicationModel.addApplication in this test in
application.test.ts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 954f4ccf-cb03-4ad6-8694-b27b400f6ea2
📒 Files selected for processing (4)
controllers/applications.tsmodels/applications.tstest/integration/application.test.tstest/unit/controllers/applications.test.ts
Date: 8 March 2026
Developer Name: @AnujChhikara
Issue Ticket Number
Tech Doc Link
Business Doc Link
Description
Documentation Updated?
Under Feature Flag
Database Changes
Breaking Changes
Development Tested?
Screenshots
Screenshot 1
Test Coverage
Screenshot 1
Additional Notes