DEV: Specify bookmarks order

It's better to order by id than to have a semi-random order. Fixes a flaky test:

```
 1) TopicView with a few sample posts #bookmarks gets the first post bookmark reminder at for the user
59
     Failure/Error: expect(first[:post_id]).to eq(bookmark1.post_id)
60

61
       expected: 1901
62
            got: 1902
63

64
       (compared using ==)
65
     # ./spec/components/topic_view_spec.rb:420:in `block (4 levels) in <main>'
66
     # ./spec/rails_helper.rb:284:in `block (2 levels) in <top (required)>'
67
     # ./vendor/bundle/ruby/2.7.0/gems/webmock-3.14.0/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
68
```
This commit is contained in:
Jarek Radosz 2021-11-29 18:59:37 +01:00
parent 3dc0b9e077
commit 1f50026231
1 changed files with 1 additions and 1 deletions

View File

@ -410,7 +410,7 @@ class TopicView
def bookmarks def bookmarks
@bookmarks ||= @topic.bookmarks.where(user: @user).joins(:topic).select( @bookmarks ||= @topic.bookmarks.where(user: @user).joins(:topic).select(
:id, :post_id, "topics.id AS topic_id", :for_topic, :reminder_at, :name, :auto_delete_preference :id, :post_id, "topics.id AS topic_id", :for_topic, :reminder_at, :name, :auto_delete_preference
) ).order(:id)
end end
MAX_PARTICIPANTS = 24 MAX_PARTICIPANTS = 24