Skip to content

test: Add tests for upcoming scope ordering fix (PR #2515)#2516

Merged
olleolleolle merged 1 commit intocodebar:masterfrom
mroderick:add-tests-for-2515
Mar 10, 2026
Merged

test: Add tests for upcoming scope ordering fix (PR #2515)#2516
olleolleolle merged 1 commit intocodebar:masterfrom
mroderick:add-tests-for-2515

Conversation

@mroderick
Copy link
Collaborator

Summary

This PR adds regression tests to ensure the fix from #2515 continues to work correctly.

Background

PR #2515 fixed an issue where today_and_upcoming and upcoming scopes were returning workshops in the wrong order. The Workshop model has a default_scope that sorts by date_and_time DESC, but for upcoming events we want them sorted ascending (soonest first).

The fix changed order(date_and_time: :asc) to reorder(date_and_time: :asc) to override the default scope.

Changes

Added two new test cases to spec/models/concerns/listable_spec.rb:

  1. today_and_upcoming scope: Verifies workshops are returned ordered from soonest to furthest
  2. upcoming scope: Verifies workshops are returned ordered from soonest to furthest

These tests would fail without the reorder fix because the default_scope would override the ascending order, causing workshops to be returned furthest-first instead of soonest-first.

Testing

  • All existing tests continue to pass
  • New tests verify the correct ordering behavior
  • Verified that the tests fail when using order instead of reorder

Relates to #2515

Add tests to verify that today_and_upcoming and upcoming scopes
return workshops in ascending order (soonest first), overriding
the Workshop default_scope which orders in descending order.

This ensures the fix in PR codebar#2515 is properly covered by tests.
@mroderick mroderick marked this pull request as ready for review March 10, 2026 12:55
Copy link
Collaborator

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks!

@olleolleolle olleolleolle merged commit dc84bf1 into codebar:master Mar 10, 2026
8 checks passed
@mroderick mroderick deleted the add-tests-for-2515 branch March 10, 2026 13:37
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.

2 participants