Commit d2a370a75069c0373f0520c5defb90c3954830cb

Authored by Andrew Kane
1 parent 20a15fa4

Fixed tests for ActiveRecord below 4.1

Showing 2 changed files with 16 additions and 16 deletions   Show diff stats
test/index_test.rb
... ... @@ -102,33 +102,29 @@ class IndexTest < Minitest::Test
102 102 assert_raises(Searchkick::InvalidQueryError) { Product.search(query: {boom: true}) }
103 103 end
104 104  
105   - def test_dangerous_reindex
106   - skip if mongoid2? || nobrainer?
107   - assert_raises(Searchkick::DangerousOperation) { Product.where(id: [1, 2, 3]).reindex }
108   - end
  105 + unless mongoid2? || nobrainer? || activerecord_below41?
  106 + def test_dangerous_reindex
  107 + assert_raises(Searchkick::DangerousOperation) { Product.where(id: [1, 2, 3]).reindex }
  108 + end
109 109  
110   - def test_dangerous_reindex_accepted
111   - skip if nobrainer?
112   - store_names ["Product A", "Product B"]
113   - Product.where(name: "Product A").reindex(accept_danger: true)
114   - assert_search "product", ["Product A"]
115   - end
  110 + def test_dangerous_reindex_accepted
  111 + store_names ["Product A", "Product B"]
  112 + Product.where(name: "Product A").reindex(accept_danger: true)
  113 + assert_search "product", ["Product A"]
  114 + end
116 115  
117   - def test_dangerous_reindex_inheritance
118   - skip if mongoid2? || nobrainer?
119   - assert_raises(Searchkick::DangerousOperation) { Dog.where(id: [1, 2, 3]).reindex }
  116 + def test_dangerous_reindex_inheritance
  117 + assert_raises(Searchkick::DangerousOperation) { Dog.where(id: [1, 2, 3]).reindex }
  118 + end
120 119 end
121 120  
122 121 if defined?(ActiveRecord)
123   -
124 122 def test_transaction
125 123 Product.transaction do
126 124 store_names ["Product A"]
127 125 raise ActiveRecord::Rollback
128 126 end
129   -
130 127 assert_search "product", [], conversions: false
131 128 end
132   -
133 129 end
134 130 end
... ...
test/test_helper.rb
... ... @@ -30,6 +30,10 @@ def nobrainer?
30 30 defined?(NoBrainer)
31 31 end
32 32  
  33 +def activerecord_below41?
  34 + defined?(ActiveRecord) && ActiveRecord::VERSION < "4.1"
  35 +end
  36 +
33 37 if defined?(Mongoid)
34 38 Mongoid.logger.level = Logger::INFO
35 39 Mongo::Logger.logger.level = Logger::INFO if defined?(Mongo::Logger)
... ...