Skip to content

Commit

Permalink
tweak the link sorter test to help understand why it's started failin…
Browse files Browse the repository at this point in the history
…g more regularly for postgres
  • Loading branch information
stuzart committed Sep 24, 2024
1 parent 9961495 commit 8707a12
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/unit/list_sorter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ class ListSorterTest < ActiveSupport::TestCase
end

test 'sort by views' do
d1 = FactoryBot.create(:document, title: 'document a', policy: FactoryBot.create(:publicly_viewable_policy))
d2 = FactoryBot.create(:document, title: 'document b', policy: FactoryBot.create(:publicly_viewable_policy))
d3 = FactoryBot.create(:document, title: 'document c', policy: FactoryBot.create(:publicly_viewable_policy))
d4 = FactoryBot.create(:document, title: 'document d', policy: FactoryBot.create(:publicly_viewable_policy))
d5 = FactoryBot.create(:document, title: 'document e', policy: FactoryBot.create(:publicly_viewable_policy))
d6 = FactoryBot.create(:document, title: 'document f', policy: FactoryBot.create(:publicly_viewable_policy))
d1 = FactoryBot.create(:document, title: 'document 1', policy: FactoryBot.create(:publicly_viewable_policy))
d2 = FactoryBot.create(:document, title: 'document 2', policy: FactoryBot.create(:publicly_viewable_policy))
d3 = FactoryBot.create(:document, title: 'document 3', policy: FactoryBot.create(:publicly_viewable_policy))
d4 = FactoryBot.create(:document, title: 'document 4', policy: FactoryBot.create(:publicly_viewable_policy))
d5 = FactoryBot.create(:document, title: 'document 5', policy: FactoryBot.create(:publicly_viewable_policy))
d6 = FactoryBot.create(:document, title: 'document 6', policy: FactoryBot.create(:publicly_viewable_policy))
FactoryBot.create(:activity_log, action: 'show', activity_loggable: d4, created_at: 10.minutes.ago)
FactoryBot.create(:activity_log, action: 'show', activity_loggable: d4, created_at: 9.minutes.ago)
FactoryBot.create(:activity_log, action: 'show', activity_loggable: d4, created_at: 8.minutes.ago)
Expand All @@ -170,10 +170,10 @@ class ListSorterTest < ActiveSupport::TestCase
views_ordered = [d4, d3, d6, d5, d1, d2]
# Tests enum strategy
docs = [d1, d2, d3, d4, d5, d6]
assert_equal views_ordered, Seek::ListSorter.sort_by_order(docs, '--views_desc')
assert_equal views_ordered.collect(&:title), Seek::ListSorter.sort_by_order(docs, '--views_desc').collect(&:title)
# Tests relation strategy
docs = Document.all
assert_equal views_ordered, Seek::ListSorter.sort_by_order(docs, '--views_desc')
assert_equal views_ordered.collect(&:title), Seek::ListSorter.sort_by_order(docs, '--views_desc').collect(&:title)
end

test 'complex sorting' do
Expand Down

0 comments on commit 8707a12

Please sign in to comment.