From 70d743c7620212e2ae9a9e7dade05aa2fe302a62 Mon Sep 17 00:00:00 2001 From: Sean Hill <seandhi@gmail.com> Date: Wed, 29 May 2013 19:48:00 -0500 Subject: [PATCH] Add tests for custom distance and bearing columns. --- test/near_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/near_test.rb b/test/near_test.rb index 05411dd5..4e95b922 100644 --- a/test/near_test.rb +++ b/test/near_test.rb @@ -35,6 +35,24 @@ class NearTest < Test::Unit::TestCase assert_no_consecutive_comma(result[:select]) end + def test_near_scope_options_with_custom_distance_column + result = Event.send(:near_scope_options, 1.0, 2.0, 5, :distance_column => 'calculated_distance') + + assert_no_match /AS distance/, result[:select] + assert_match /AS calculated_distance/, result[:select] + assert_no_match /\bdistance\b/, result[:order] + assert_match /calculated_distance/, result[:order] + assert_no_consecutive_comma(result[:select]) + end + + def test_near_scope_options_with_custom_bearing_column + result = Event.send(:near_scope_options, 1.0, 2.0, 5, :bearing_column => 'calculated_bearing') + + assert_no_match /AS bearing/, result[:select] + assert_match /AS calculated_bearing/, result[:select] + assert_no_consecutive_comma(result[:select]) + end + private def assert_no_consecutive_comma(string) -- GitLab