Commit 169dc02ccbb847118bdc45307a20ac721f8c14aa
1 parent
11d740c4
Exists in
master
and in
2 other branches
Moved relation tests
Showing
2 changed files
with
29 additions
and
26 deletions
Show diff stats
test/pagination_test.rb
... | ... | @@ -11,32 +11,6 @@ class PaginationTest < Minitest::Test |
11 | 11 | assert_equal ["Product A", "Product B"], Product.search("product", order: {name: :asc}).limit(2).map(&:name) |
12 | 12 | end |
13 | 13 | |
14 | - def test_limit_relation_loaded | |
15 | - Product.search_index.refresh | |
16 | - products = Product.search("*") | |
17 | - refute products.loaded? | |
18 | - assert_equal 0, products.count | |
19 | - assert products.loaded? | |
20 | - error = assert_raises(Searchkick::Error) do | |
21 | - products.limit!(2) | |
22 | - end | |
23 | - assert_equal "Relation loaded", error.message | |
24 | - end | |
25 | - | |
26 | - def test_limit_relation_clone | |
27 | - products = Product.search("*") | |
28 | - assert_equal 10, products.limit(10).limit_value | |
29 | - assert_equal 10000, products.limit_value | |
30 | - end | |
31 | - | |
32 | - def test_limit_relation_only | |
33 | - assert_equal 10, Product.search("*").limit(10).only(:limit).limit_value | |
34 | - end | |
35 | - | |
36 | - def test_limit_relation_except | |
37 | - assert_equal 10000, Product.search("*").limit(10).except(:limit).limit_value | |
38 | - end | |
39 | - | |
40 | 14 | def test_no_limit |
41 | 15 | names = 20.times.map { |i| "Product #{i}" } |
42 | 16 | store_names names | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +require_relative "test_helper" | |
2 | + | |
3 | +class RelationTest < Minitest::Test | |
4 | + def test_loaded | |
5 | + Product.search_index.refresh | |
6 | + products = Product.search("*") | |
7 | + refute products.loaded? | |
8 | + assert_equal 0, products.count | |
9 | + assert products.loaded? | |
10 | + error = assert_raises(Searchkick::Error) do | |
11 | + products.limit!(2) | |
12 | + end | |
13 | + assert_equal "Relation loaded", error.message | |
14 | + end | |
15 | + | |
16 | + def test_clone | |
17 | + products = Product.search("*") | |
18 | + assert_equal 10, products.limit(10).limit_value | |
19 | + assert_equal 10000, products.limit_value | |
20 | + end | |
21 | + | |
22 | + def test_only | |
23 | + assert_equal 10, Product.search("*").limit(10).only(:limit).limit_value | |
24 | + end | |
25 | + | |
26 | + def test_except | |
27 | + assert_equal 10000, Product.search("*").limit(10).except(:limit).limit_value | |
28 | + end | |
29 | +end | ... | ... |