Skip to content

Commit

Permalink
Merge pull request #134 from flackou/fix_unsafe_raw_sql_warning
Browse files Browse the repository at this point in the history
Fix unsafe raw SQL warning
  • Loading branch information
Michael Noack committed Apr 17, 2018
2 parents 9e5251a + 6448e9a commit 59a860a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/geokit-rails/acts_as_mappable.rb
Expand Up @@ -153,7 +153,9 @@ def by_distance(options = {})
units = extract_units_from_options(options)
formula = extract_formula_from_options(options)
distance_column_name = distance_sql(origin, units, formula)
with_latlng.order("#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}")
with_latlng.order(Arel.sql(
"#{distance_column_name} #{options[:reverse] ? 'DESC' : 'ASC'}"
))
end

def with_latlng
Expand Down
5 changes: 3 additions & 2 deletions test/boot.rb
@@ -1,7 +1,8 @@
require 'pathname'

require 'test/unit'
require "active_support/version"
require 'active_support/test_case'
require "active_support/testing/autorun" if ActiveSupport::VERSION::MAJOR >= 4

require 'active_record'
require 'active_record/fixtures'
Expand All @@ -28,4 +29,4 @@
ActiveRecord::Base.establish_connection(db_config[ADAPTER])

ActiveRecord::Migration.verbose = false
load schema_file
load schema_file
8 changes: 7 additions & 1 deletion test/test_helper.rb
Expand Up @@ -34,6 +34,8 @@
ActiveRecord::Base.send(:include, Geokit::ActsAsMappable::Glue)
ActionController::Base.send(:include, Geokit::GeocoderControl)
ActionController::Base.send(:include, Geokit::IpGeocodeLookup)
# Rails >= 4 requires models classes to be loaded before fixtures are created
Dir[PLUGIN_ROOT + "test/models/*.rb"].each { |file| require file }

class GeokitTestCase < ActiveSupport::TestCase
begin
Expand All @@ -43,7 +45,11 @@ class GeokitTestCase < ActiveSupport::TestCase
end

self.fixture_path = (PLUGIN_ROOT + 'test/fixtures').to_s
self.use_transactional_fixtures = true
if Rails::VERSION::MAJOR >= 5
self.use_transactional_tests = true
else
self.use_transactional_fixtures = true
end
self.use_instantiated_fixtures = false

fixtures :all
Expand Down

0 comments on commit 59a860a

Please sign in to comment.