Skip to content

Add rspec coverage for the status-history state machine - #4

Merged
darreneid merged 1 commit into
stagingfrom
status-history-specs
Jul 28, 2026
Merged

Add rspec coverage for the status-history state machine#4
darreneid merged 1 commit into
stagingfrom
status-history-specs

Conversation

@darreneid

Copy link
Copy Markdown
Collaborator

Exhaustive coverage of the feature as CI-gated rspec, run inside a Discourse host (backend_tests) — no staging instance or API key needed. Complements the deployed-instance smoke suite (#2).

spec/requests/.../custom_fields_controller_spec.rb — admin PUT endpoint

  • All 12 ordered api_update status transitions → correct row (from/to, source=api_update, user_id, null post_id, duration >= 0).
  • Invalid status → 422, nothing recorded.
  • No-op status change → no row.
  • Row attributed to the pre-change assignee.
  • from_status = NULL when the topic had no prior status.
  • Duration measured from the previous recorded change.
  • Non-admins forbidden.

spec/integration/status_transitions_spec.rbpost_created/topic_created

  • topic_created seeds new (no row); a non-admin author sets waiting_*.
  • Customer reply reopens snoozed→open; closed→open (recent + assigned, reassigned), →new (no last-assignee), →new (closed > 1 month ago).
  • Customer reply to an open topic → sets waiting_*, no row.
  • Admin whisper reopens snoozed/closed.
  • Admin regular reply clears waiting_*, no row.

Testing

Ran locally via LOAD_PLUGINS=1 bin/rspec (identical to CI): 29 examples, 0 failures.

🤖 Generated with Claude Code

- request spec for the admin PUT controller: all 12 api_update status
  transitions, invalid -> 422, no-op, pre-change assignee attribution,
  from_status=null (no prior status), and duration from the prior change
- integration spec for the post_created/topic_created handlers: customer and
  whisper reopens (snoozed/closed, incl. the 1-month rule), waiting_* behavior,
  and topic_created seeding

Runs in CI (backend_tests) inside the Discourse host.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@darreneid
darreneid force-pushed the status-history-specs branch from 13bcf9d to fffbb6f Compare July 28, 2026 20:50
@darreneid
darreneid merged commit f03cd28 into staging Jul 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant