Commit f3dd9864fc2f9ee4fd158b4f4dffc383820aae65
1 parent
0fc09572
Exists in
master
and in
1 other branch
Improved tests [skip ci]
Showing
1 changed file
with
3 additions
and
11 deletions
Show diff stats
test/pagination_test.rb
... | ... | @@ -4,11 +4,7 @@ class PaginationTest < Minitest::Test |
4 | 4 | def test_limit |
5 | 5 | store_names ["Product A", "Product B", "Product C", "Product D"] |
6 | 6 | assert_order "product", ["Product A", "Product B"], order: {name: :asc}, limit: 2 |
7 | - end | |
8 | - | |
9 | - def test_limit_relation | |
10 | - store_names ["Product A", "Product B", "Product C", "Product D"] | |
11 | - assert_equal ["Product A", "Product B"], Product.search("product", order: {name: :asc}).limit(2).map(&:name) | |
7 | + assert_order_relation ["Product A", "Product B"], Product.search("product").order(name: :asc).limit(2) | |
12 | 8 | end |
13 | 9 | |
14 | 10 | def test_no_limit |
... | ... | @@ -20,11 +16,7 @@ class PaginationTest < Minitest::Test |
20 | 16 | def test_offset |
21 | 17 | store_names ["Product A", "Product B", "Product C", "Product D"] |
22 | 18 | assert_order "product", ["Product C", "Product D"], order: {name: :asc}, offset: 2, limit: 100 |
23 | - end | |
24 | - | |
25 | - def test_offset_relation | |
26 | - store_names ["Product A", "Product B", "Product C", "Product D"] | |
27 | - assert_equal ["Product C", "Product D"], Product.search("product", order: {name: :asc}).offset(2).limit(100).map(&:name) | |
19 | + assert_order_relation ["Product C", "Product D"], Product.search("product").order(name: :asc).offset(2).limit(100) | |
28 | 20 | end |
29 | 21 | |
30 | 22 | def test_pagination |
... | ... | @@ -55,7 +47,7 @@ class PaginationTest < Minitest::Test |
55 | 47 | |
56 | 48 | def test_pagination_relation |
57 | 49 | store_names ["Product A", "Product B", "Product C", "Product D", "Product E", "Product F"] |
58 | - products = Product.search("product", order: {name: :asc}, padding: 1).page(2).per_page(2) | |
50 | + products = Product.search("product", padding: 1).order(name: :asc).page(2).per_page(2) | |
59 | 51 | assert_equal ["Product D", "Product E"], products.map(&:name) |
60 | 52 | assert_equal "product", products.entry_name |
61 | 53 | assert_equal 2, products.current_page | ... | ... |