discourse/plugins/automation/spec/services
Régis Hanol e70137509e
DEV: Refactor automation Update service per PR #36458 feedback (#36771)
Addresses code review feedback to improve the automation Update service
by following Discourse service best practices and extracting complex
logic into a dedicated action class.

Changes:
- Extract logging logic to
`DiscourseAutomation::Action::LogAutomationUpdate` action class,
removing utility methods from the service (per service guidelines that
discourage utility methods in services)
- Use `model` step for `previous_state` instead of regular step
- Simplify `capture_previous_state` using `slice` and `merge`
- Pass `previous_state` as explicit parameter to `log_action`
- Remove unused `params` from `apply_forced_triggerable`
- Simplify attributes building with
`symbolize_keys.slice().compact_blank`
- Simplify save logic: `save!(validate: context[:clear_trigger].blank?)`
- Use `index_with` for building change hashes in action class
- Use `have_attributes` matcher in request specs
- Simplify boolean checks with `value.in?([true, false])`

References:
- PR feedback: https://github.com/discourse/discourse/pull/36458
- Service objects guide:
https://meta.discourse.org/t/using-service-objects-in-discourse/333641
2025-12-18 18:16:03 +01:00
..
discourse_automation DEV: Refactor automation Update service per PR #36458 feedback (#36771) 2025-12-18 18:16:03 +01:00
user_badge_granted_spec.rb