Commit c10c0e8
Add application_form_class method to Flex::Case (#188)
## Changes
- Added `application_form_class` class method to `Flex::Case` that
returns the application form class name using string substitution
- Updated `start_on_application_form_created` in
`business_process_builder.rb` to use the new method instead of hardcoded
string manipulation
- Allows subclasses to override the method for custom application form
naming conventions
This changes allows us to have application form subclasses that aren't suffixed with ApplicationForm, such as PaidLeaveRequest or ActivityReport
## Context
This change refactors hardcoded string substitution logic into a
reusable class method. Previously, the business process builder was
directly performing `case_class.name.sub("Case",
"ApplicationFormCreated")` to generate event names. Now it calls
`case_class.application_form_class` which returns the application form
class name that can be customized by subclasses.
The implementation maintains backward compatibility by using the same
string substitution logic (`name.sub("Case", "ApplicationForm")`) as the
default behavior.
**Key areas for review:**
- Verify the string substitution logic works correctly for all Case
subclasses
- Confirm that event name generation still matches what ApplicationForm
classes publish
- Check that the method allows appropriate subclass customization
## Testing
- **Full test suite**: All 787 tests pass with 0 failures
- **Linting**: All style checks pass with no offenses detected
- **Event name verification**: Confirmed in Rails console that event
names match correctly:
- `PassportCase.application_form_class` → `"PassportApplicationForm"`
- `TestCase.application_form_class` → `"TestApplicationForm"`
- **Business process functionality**: PassportBusinessProcess acceptance
test passes, confirming cases are created correctly when application
forms are submitted
The existing test suite provides good coverage for this change since it
exercises the business process event handling that relies on the
modified code.
---
**Link to Devin run**:
https://app.devin.ai/sessions/353c6623acf94683970eea40c0e23270
**Requested by**: @lorenyu
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Loren Yu <yuloren@gmail.com>1 parent 9103eb0 commit c10c0e8
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
0 commit comments