mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-05 05:30:44 +08:00
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 |
||
|---|---|---|
| .. | ||
| discourse_automation | ||
| user_badge_granted_spec.rb | ||