test/boost_test.rb in searchkick-3.0.2 vs test/boost_test.rb in searchkick-3.0.3

- old
+ new

@@ -147,9 +147,27 @@ assert_first "tomato", "Tomato B", boost_where: {user_ids: {value: 2, factor: 10}} assert_first "tomato", "Tomato B", boost_where: {user_ids: {value: [1, 4], factor: 10}} assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"], boost_where: {user_ids: [{value: 1, factor: 10}, {value: 3, factor: 20}]} end + def test_boost_by_recency + store [ + {name: "Article 1", created_at: 2.days.ago}, + {name: "Article 2", created_at: 1.day.ago}, + {name: "Article 3", created_at: Time.now} + ] + assert_order "article", ["Article 3", "Article 2", "Article 1"], boost_by_recency: {created_at: {scale: "7d", decay: 0.5}} + end + + def test_boost_by_recency_origin + store [ + {name: "Article 1", created_at: 2.days.ago}, + {name: "Article 2", created_at: 1.day.ago}, + {name: "Article 3", created_at: Time.now} + ] + assert_order "article", ["Article 1", "Article 2", "Article 3"], boost_by_recency: {created_at: {origin: 2.days.ago, scale: "7d", decay: 0.5}} + end + def test_boost_by_distance store [ {name: "San Francisco", latitude: 37.7833, longitude: -122.4167}, {name: "San Antonio", latitude: 29.4167, longitude: -98.5000}, {name: "San Marino", latitude: 43.9333, longitude: 12.4667}