You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reverse the association between application forms and cases (#71)
## Changes
- ApplicationForm publishes Created event on create
- Minor: Rename application form id in ApplicationFormSubmitted event
payload from id to application_form_id
- BusinessProcess now always starts when an ApplicationForm is created.
We moved the case creation logic from ApplicationForm to the
BusinessProcess. The business process now listens for
ApplicationFormCreated events and creates the case and executes the
start step when
- Get rid of BusinessProcess.execute for now since business processes
start when an application form is created and cannot be manually started
(this means BusinessProcess currently doesn't properly implement the
Step interface)
- Decoupled executing of BusinessProcess from the Case class, so Case no
longer has an execute_business_process method that's called after_create
- Reversed the association between case and application form. Case now
has an application_form_id, while ApplicationForm no longer has a
case_id
Migrations for test app (will need to do for demo too)
- Add application_form_id to passport_cases and test_cases
- Remove case_id from test_application_forms and
passport_application_forms
Misc
- Fix the publish_event_with_payload rspec matcher
- Replaces some `puts` lines with `Rails.logger.debug`
- Order methods in BusinessProcess alphabetically within each visibility
section
## Context
Moving in a direction that decouples application form from case based on
this conversation
https://nava.slack.com/archives/C03G1SWD9H7/p1747252433304899
Note: This currently breaks a couple of things about BusinessProcess
which we can address in a future PR:
- BusinessProcess no longer implements execute, so it no longer can act
as a step in another BusinessProcess (note that it doesn't seem like we
had a test for this, or maybe we did and I got rid of it by accident)
- Relatedly: BusinessProcess can only trigger on an
ApplicationFormCreated event, not manually through execute or through
any other start event. An upcoming PR should generalize the start
functionality to allow different start events (e.g. see BPMN
https://www.trisotech.com/bpmn-101-three-ways-a-process-starts/). We'll
need to update BusinessProcess to allow multiple start events and to
have a separate handler for start events.
Rails.logger.debug"Current step: #{current_step}, Next step: #{next_step}"
118
-
returnunlessnext_step# Skip processing if no valid transition exists
101
+
defcreate_case_from_event(event)
102
+
Rails.logger.debug"Creating case from event: #{event[:name]} with payload: #{event[:payload]}"
103
+
raise"Cannot create case from event #{event[:name]}. Event must be an ApplicationFormCreated event"unlessevent[:name].end_with?("ApplicationFormCreated")
0 commit comments