1 # frozen_string_literal: true
5 class PaginationMethodsTest < ActiveSupport::TestCase
6 include PaginationMethods
8 test "#get_page_items can sort any records with compatible ids" do
9 n1 = create(:changeset_comment_notification)
10 n2 = create(:gpx_import_failure_notification)
11 items = Noticed::Notification.all
13 paged_items = get_page_items(items)
15 assert_equal [n2, n1], paged_items.items
18 test "#get_page_items can sort records by an arbitrary column" do
19 create(:user, :display_name => "Alba")
20 create(:user, :display_name => "Calle")
21 create(:user, :display_name => "Berhane")
24 paged_items = get_page_items(items, :cursor_column => :display_name)
25 actual_names = paged_items.items.map(&:display_name)
26 assert_equal %w[Calle Berhane Alba], actual_names
32 # Methods below are stubs for controller methods
33 # that the PaginationMethods concern requires to work.