From 78723345c04c1a067d01f582d85bdafac18ba18c Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 30 Nov 2021 22:56:00 +0100 Subject: [PATCH] DEV: Fix a flaky bookmarks test (#15129) * 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
' 66 # ./spec/rails_helper.rb:284:in `block (2 levels) in ' 67 # ./vendor/bundle/ruby/2.7.0/gems/webmock-3.14.0/lib/webmock/rspec.rb:37:in `block (2 levels) in ' 68 ``` * Change test * Revert "DEV: Specify bookmarks order" This reverts commit 1f50026231c4d5e1823e8d0d79770fa73ff09f1c. --- spec/components/topic_view_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb index 755247d2cfe..2a209e47fa6 100644 --- a/spec/components/topic_view_spec.rb +++ b/spec/components/topic_view_spec.rb @@ -416,7 +416,7 @@ describe TopicView do it "gets the first post bookmark reminder at for the user" do topic_view = TopicView.new(topic.id, user) - first, second = topic_view.bookmarks + first, second = topic_view.bookmarks.sort_by(&:id) expect(first[:post_id]).to eq(bookmark1.post_id) expect(first[:reminder_at]).to eq_time(bookmark1.reminder_at) expect(second[:post_id]).to eq(bookmark2.post_id)