geokit-rails 2.3.2 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +29 -3
  3. data/CHANGELOG.md +5 -0
  4. data/README.markdown +7 -7
  5. data/gemfiles/rails3.gemfile +1 -0
  6. data/gemfiles/rails4.gemfile +1 -1
  7. data/gemfiles/rails5.gemfile +0 -1
  8. data/gemfiles/rails6.0.gemfile +8 -0
  9. data/gemfiles/rails6.1.gemfile +8 -0
  10. data/geokit-rails.gemspec +6 -5
  11. data/lib/geokit-rails/acts_as_mappable/class_methods.rb +297 -0
  12. data/lib/geokit-rails/acts_as_mappable/glue.rb +54 -0
  13. data/lib/geokit-rails/acts_as_mappable.rb +0 -347
  14. data/lib/geokit-rails/{core_extensions.rb → distance_collection.rb} +0 -0
  15. data/lib/geokit-rails/ip_geocode_lookup.rb +4 -7
  16. data/lib/geokit-rails/version.rb +1 -1
  17. data/lib/geokit-rails.rb +3 -1
  18. data/test/distance_collection_test.rb +42 -0
  19. data/test/dummy/Rakefile +6 -0
  20. data/test/dummy/app/assets/images/.keep +0 -0
  21. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  22. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  23. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  24. data/test/dummy/app/controllers/application_controller.rb +3 -0
  25. data/test/dummy/app/controllers/concerns/.keep +0 -0
  26. data/test/dummy/app/controllers/location_aware_controller.rb +43 -0
  27. data/test/dummy/app/helpers/application_helper.rb +2 -0
  28. data/test/dummy/app/jobs/application_job.rb +7 -0
  29. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  30. data/test/dummy/app/models/application_record.rb +3 -0
  31. data/test/dummy/app/models/concerns/.keep +0 -0
  32. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  33. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  34. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  35. data/test/dummy/bin/rails +4 -0
  36. data/test/dummy/bin/rake +4 -0
  37. data/test/dummy/bin/setup +33 -0
  38. data/test/dummy/config/application.rb +22 -0
  39. data/test/dummy/config/boot.rb +5 -0
  40. data/test/dummy/config/cable.yml +10 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +68 -0
  44. data/test/dummy/config/environments/production.rb +87 -0
  45. data/test/dummy/config/environments/test.rb +60 -0
  46. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  48. data/test/dummy/config/initializers/inflections.rb +16 -0
  49. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  50. data/test/dummy/config/locales/en.yml +33 -0
  51. data/test/dummy/config/puma.rb +43 -0
  52. data/test/dummy/config/routes.rb +6 -0
  53. data/test/dummy/config/storage.yml +34 -0
  54. data/test/dummy/config.ru +6 -0
  55. data/test/dummy/lib/assets/.keep +0 -0
  56. data/test/dummy/log/.keep +0 -0
  57. data/test/dummy/public/404.html +67 -0
  58. data/test/dummy/public/422.html +67 -0
  59. data/test/dummy/public/500.html +66 -0
  60. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  61. data/test/dummy/public/apple-touch-icon.png +0 -0
  62. data/test/dummy/public/favicon.ico +0 -0
  63. data/test/dummy/storage/.keep +0 -0
  64. data/test/dummy/tmp/.keep +0 -0
  65. data/test/dummy/tmp/pids/.keep +0 -0
  66. data/test/dummy/tmp/storage/.keep +0 -0
  67. data/test/ip_geocode_lookup_test.rb +49 -0
  68. data/test/test_helper.rb +17 -0
  69. metadata +129 -27
  70. data/test/ip_geocode_lookup_test.disabled.rb +0 -82
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class IpGeocodeLookupTest < ActionDispatch::IntegrationTest#ActiveSupport::TestCase#ActionController::TestCase
4
+ # tests LocationAwareController
5
+
6
+ def setup
7
+ # @controller = LocationAwareController
8
+ @success = Geokit::GeoLoc.new
9
+ @success.provider = "hostip"
10
+ @success.lat = 41.7696
11
+ @success.lng = -88.4588
12
+ @success.city = "Sugar Grove"
13
+ @success.state = "IL"
14
+ @success.country_code = "US"
15
+ @success.success = true
16
+
17
+ @failure = Geokit::GeoLoc.new
18
+ @failure.provider = "hostip"
19
+ @failure.city = "(Private Address)"
20
+ @failure.success = false
21
+ end
22
+
23
+ def test_no_location_in_cookie_or_session
24
+ Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("good ip").returns(@success)
25
+ get '/'
26
+ assert_response :success
27
+ assert_equal @success, @request.session[:geo_location]
28
+ assert_not_nil cookies[:geo_location]
29
+ assert_equal @success.to_json, cookies[:geo_location]
30
+ end
31
+
32
+ def test_location_in_cookie
33
+ get '/cookietest'
34
+ assert_not_nil cookies[:geo_location]
35
+ assert_equal @success.to_json, cookies[:geo_location]
36
+ end
37
+
38
+ def test_location_in_session
39
+ get '/sessiontest'
40
+ assert_response :success
41
+ assert_equal @success, Geokit::GeoLoc.new(JSON.parse(session[:geo_location]).transform_keys(&:to_sym))
42
+ end
43
+
44
+ def test_ip_not_located
45
+ Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("bad ip").returns(@failure)
46
+ get '/failtest'
47
+ assert_nil @request.session[:geo_location]
48
+ end
49
+ end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,19 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require_relative "../test/dummy/config/environment"
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
6
+ require "rails/test_help"
7
+
8
+ # Load fixtures from the engine
9
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
10
+ ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
11
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
12
+ ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
13
+ ActiveSupport::TestCase.fixtures :all
14
+ end
15
+
16
+
1
17
  require 'pathname'
2
18
 
3
19
  require 'boot'
@@ -7,6 +23,7 @@ unless ENV['COVERAGE'] == 'off'
7
23
  COVERAGE_THRESHOLD = 35
8
24
  require 'simplecov'
9
25
  require 'simplecov-rcov'
26
+ gem 'coveralls_reborn', '~> 0.26.0'
10
27
  require 'coveralls'
11
28
  Coveralls.wear!
12
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geokit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-01-08 00:00:00.000000000 Z
14
+ date: 2023-01-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -59,14 +59,14 @@ dependencies:
59
59
  name: simplecov
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - "~>"
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: 0.16.1
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: 0.16.1
72
72
  - !ruby/object:Gem::Dependency
@@ -83,6 +83,20 @@ dependencies:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
+ - !ruby/object:Gem::Dependency
87
+ name: net-http
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
86
100
  - !ruby/object:Gem::Dependency
87
101
  name: rake
88
102
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +140,7 @@ dependencies:
126
140
  - !ruby/object:Gem::Version
127
141
  version: '0.9'
128
142
  - !ruby/object:Gem::Dependency
129
- name: coveralls
143
+ name: coveralls_reborn
130
144
  requirement: !ruby/object:Gem::Requirement
131
145
  requirements:
132
146
  - - ">="
@@ -141,44 +155,30 @@ dependencies:
141
155
  version: '0'
142
156
  - !ruby/object:Gem::Dependency
143
157
  name: mysql2
144
- requirement: !ruby/object:Gem::Requirement
145
- requirements:
146
- - - "~>"
147
- - !ruby/object:Gem::Version
148
- version: '0.2'
149
- type: :development
150
- prerelease: false
151
- version_requirements: !ruby/object:Gem::Requirement
152
- requirements:
153
- - - "~>"
154
- - !ruby/object:Gem::Version
155
- version: '0.2'
156
- - !ruby/object:Gem::Dependency
157
- name: activerecord-mysql2spatial-adapter
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
- version: '0'
162
+ version: '0.2'
163
163
  type: :development
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: '0'
169
+ version: '0.2'
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: pg
172
172
  requirement: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - "~>"
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0.10'
177
177
  type: :development
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
180
180
  requirements:
181
- - - "~>"
181
+ - - ">="
182
182
  - !ruby/object:Gem::Version
183
183
  version: '0.10'
184
184
  - !ruby/object:Gem::Dependency
@@ -217,11 +217,15 @@ files:
217
217
  - gemfiles/rails3.gemfile
218
218
  - gemfiles/rails4.gemfile
219
219
  - gemfiles/rails5.gemfile
220
+ - gemfiles/rails6.0.gemfile
221
+ - gemfiles/rails6.1.gemfile
220
222
  - geokit-rails.gemspec
221
223
  - lib/generators/geokit_rails/install_generator.rb
222
224
  - lib/generators/templates/geokit_config.rb
223
225
  - lib/geokit-rails.rb
224
226
  - lib/geokit-rails/acts_as_mappable.rb
227
+ - lib/geokit-rails/acts_as_mappable/class_methods.rb
228
+ - lib/geokit-rails/acts_as_mappable/glue.rb
225
229
  - lib/geokit-rails/adapters/abstract.rb
226
230
  - lib/geokit-rails/adapters/mysql.rb
227
231
  - lib/geokit-rails/adapters/mysql2.rb
@@ -230,7 +234,7 @@ files:
230
234
  - lib/geokit-rails/adapters/postgresql.rb
231
235
  - lib/geokit-rails/adapters/sqlite.rb
232
236
  - lib/geokit-rails/adapters/sqlserver.rb
233
- - lib/geokit-rails/core_extensions.rb
237
+ - lib/geokit-rails/distance_collection.rb
234
238
  - lib/geokit-rails/geocoder_control.rb
235
239
  - lib/geokit-rails/ip_geocode_lookup.rb
236
240
  - lib/geokit-rails/railtie.rb
@@ -238,6 +242,55 @@ files:
238
242
  - test/acts_as_mappable_test.rb
239
243
  - test/boot.rb
240
244
  - test/database.yml
245
+ - test/distance_collection_test.rb
246
+ - test/dummy/Rakefile
247
+ - test/dummy/app/assets/images/.keep
248
+ - test/dummy/app/assets/stylesheets/application.css
249
+ - test/dummy/app/channels/application_cable/channel.rb
250
+ - test/dummy/app/channels/application_cable/connection.rb
251
+ - test/dummy/app/controllers/application_controller.rb
252
+ - test/dummy/app/controllers/concerns/.keep
253
+ - test/dummy/app/controllers/location_aware_controller.rb
254
+ - test/dummy/app/helpers/application_helper.rb
255
+ - test/dummy/app/jobs/application_job.rb
256
+ - test/dummy/app/mailers/application_mailer.rb
257
+ - test/dummy/app/models/application_record.rb
258
+ - test/dummy/app/models/concerns/.keep
259
+ - test/dummy/app/views/layouts/application.html.erb
260
+ - test/dummy/app/views/layouts/mailer.html.erb
261
+ - test/dummy/app/views/layouts/mailer.text.erb
262
+ - test/dummy/bin/rails
263
+ - test/dummy/bin/rake
264
+ - test/dummy/bin/setup
265
+ - test/dummy/config.ru
266
+ - test/dummy/config/application.rb
267
+ - test/dummy/config/boot.rb
268
+ - test/dummy/config/cable.yml
269
+ - test/dummy/config/database.yml
270
+ - test/dummy/config/environment.rb
271
+ - test/dummy/config/environments/development.rb
272
+ - test/dummy/config/environments/production.rb
273
+ - test/dummy/config/environments/test.rb
274
+ - test/dummy/config/initializers/content_security_policy.rb
275
+ - test/dummy/config/initializers/filter_parameter_logging.rb
276
+ - test/dummy/config/initializers/inflections.rb
277
+ - test/dummy/config/initializers/permissions_policy.rb
278
+ - test/dummy/config/locales/en.yml
279
+ - test/dummy/config/puma.rb
280
+ - test/dummy/config/routes.rb
281
+ - test/dummy/config/storage.yml
282
+ - test/dummy/lib/assets/.keep
283
+ - test/dummy/log/.keep
284
+ - test/dummy/public/404.html
285
+ - test/dummy/public/422.html
286
+ - test/dummy/public/500.html
287
+ - test/dummy/public/apple-touch-icon-precomposed.png
288
+ - test/dummy/public/apple-touch-icon.png
289
+ - test/dummy/public/favicon.ico
290
+ - test/dummy/storage/.keep
291
+ - test/dummy/tmp/.keep
292
+ - test/dummy/tmp/pids/.keep
293
+ - test/dummy/tmp/storage/.keep
241
294
  - test/fixtures/companies.yml
242
295
  - test/fixtures/custom_locations.yml
243
296
  - test/fixtures/locations.yml
@@ -247,7 +300,7 @@ files:
247
300
  - test/fixtures/mock_organizations.yml
248
301
  - test/fixtures/mock_people.yml
249
302
  - test/fixtures/stores.yml
250
- - test/ip_geocode_lookup_test.disabled.rb
303
+ - test/ip_geocode_lookup_test.rb
251
304
  - test/models/company.rb
252
305
  - test/models/custom_location.rb
253
306
  - test/models/location.rb
@@ -279,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
332
  - !ruby/object:Gem::Version
280
333
  version: '0'
281
334
  requirements: []
282
- rubygems_version: 3.1.4
335
+ rubygems_version: 3.1.2
283
336
  signing_key:
284
337
  specification_version: 4
285
338
  summary: Geokit helpers for rails apps.
@@ -287,6 +340,55 @@ test_files:
287
340
  - test/acts_as_mappable_test.rb
288
341
  - test/boot.rb
289
342
  - test/database.yml
343
+ - test/distance_collection_test.rb
344
+ - test/dummy/Rakefile
345
+ - test/dummy/app/assets/images/.keep
346
+ - test/dummy/app/assets/stylesheets/application.css
347
+ - test/dummy/app/channels/application_cable/channel.rb
348
+ - test/dummy/app/channels/application_cable/connection.rb
349
+ - test/dummy/app/controllers/application_controller.rb
350
+ - test/dummy/app/controllers/concerns/.keep
351
+ - test/dummy/app/controllers/location_aware_controller.rb
352
+ - test/dummy/app/helpers/application_helper.rb
353
+ - test/dummy/app/jobs/application_job.rb
354
+ - test/dummy/app/mailers/application_mailer.rb
355
+ - test/dummy/app/models/application_record.rb
356
+ - test/dummy/app/models/concerns/.keep
357
+ - test/dummy/app/views/layouts/application.html.erb
358
+ - test/dummy/app/views/layouts/mailer.html.erb
359
+ - test/dummy/app/views/layouts/mailer.text.erb
360
+ - test/dummy/bin/rails
361
+ - test/dummy/bin/rake
362
+ - test/dummy/bin/setup
363
+ - test/dummy/config.ru
364
+ - test/dummy/config/application.rb
365
+ - test/dummy/config/boot.rb
366
+ - test/dummy/config/cable.yml
367
+ - test/dummy/config/database.yml
368
+ - test/dummy/config/environment.rb
369
+ - test/dummy/config/environments/development.rb
370
+ - test/dummy/config/environments/production.rb
371
+ - test/dummy/config/environments/test.rb
372
+ - test/dummy/config/initializers/content_security_policy.rb
373
+ - test/dummy/config/initializers/filter_parameter_logging.rb
374
+ - test/dummy/config/initializers/inflections.rb
375
+ - test/dummy/config/initializers/permissions_policy.rb
376
+ - test/dummy/config/locales/en.yml
377
+ - test/dummy/config/puma.rb
378
+ - test/dummy/config/routes.rb
379
+ - test/dummy/config/storage.yml
380
+ - test/dummy/lib/assets/.keep
381
+ - test/dummy/log/.keep
382
+ - test/dummy/public/404.html
383
+ - test/dummy/public/422.html
384
+ - test/dummy/public/500.html
385
+ - test/dummy/public/apple-touch-icon-precomposed.png
386
+ - test/dummy/public/apple-touch-icon.png
387
+ - test/dummy/public/favicon.ico
388
+ - test/dummy/storage/.keep
389
+ - test/dummy/tmp/.keep
390
+ - test/dummy/tmp/pids/.keep
391
+ - test/dummy/tmp/storage/.keep
290
392
  - test/fixtures/companies.yml
291
393
  - test/fixtures/custom_locations.yml
292
394
  - test/fixtures/locations.yml
@@ -296,7 +398,7 @@ test_files:
296
398
  - test/fixtures/mock_organizations.yml
297
399
  - test/fixtures/mock_people.yml
298
400
  - test/fixtures/stores.yml
299
- - test/ip_geocode_lookup_test.disabled.rb
401
+ - test/ip_geocode_lookup_test.rb
300
402
  - test/models/company.rb
301
403
  - test/models/custom_location.rb
302
404
  - test/models/location.rb
@@ -1,82 +0,0 @@
1
- require 'test_helper'
2
-
3
- module TestApp
4
- class Application < Rails::Application
5
- end
6
- end
7
-
8
- TestApp::Application.routes.draw do
9
- match ':controller(/:action(/:id(.:format)))'
10
- end
11
-
12
- class LocationAwareController < ActionController::Base #:nodoc: all
13
- geocode_ip_address
14
-
15
- def index
16
- render :nothing => true
17
- end
18
-
19
- def rescue_action(e) raise e end;
20
- end
21
-
22
- class ActionController::TestRequest #:nodoc: all
23
- attr_accessor :remote_ip
24
- end
25
-
26
- class IpGeocodeLookupTest < ActionController::TestCase
27
- tests LocationAwareController
28
-
29
- def setup
30
- @success = Geokit::GeoLoc.new
31
- @success.provider = "hostip"
32
- @success.lat = 41.7696
33
- @success.lng = -88.4588
34
- @success.city = "Sugar Grove"
35
- @success.state = "IL"
36
- @success.country_code = "US"
37
- @success.success = true
38
-
39
- @failure = Geokit::GeoLoc.new
40
- @failure.provider = "hostip"
41
- @failure.city = "(Private Address)"
42
- @failure.success = false
43
- end
44
-
45
- def test_no_location_in_cookie_or_session
46
- Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("good ip").returns(@success)
47
- @request.remote_ip = "good ip"
48
- get :index
49
- verify
50
- end
51
-
52
- def test_location_in_cookie
53
- @request.remote_ip = "good ip"
54
- @request.cookies['geo_location'] = @success.to_yaml
55
- get :index
56
- verify
57
- end
58
-
59
- def test_location_in_session
60
- @request.remote_ip = "good ip"
61
- @request.session[:geo_location] = @success
62
- @request.cookies['geo_location'] = CGI::Cookie.new('geo_location', @success.to_yaml)
63
- get :index
64
- verify
65
- end
66
-
67
- def test_ip_not_located
68
- Geokit::Geocoders::MultiGeocoder.expects(:geocode).with("bad ip").returns(@failure)
69
- @request.remote_ip = "bad ip"
70
- get :index
71
- assert_nil @request.session[:geo_location]
72
- end
73
-
74
- private
75
-
76
- def verify
77
- assert_response :success
78
- assert_equal @success, @request.session[:geo_location]
79
- assert_not_nil cookies['geo_location']
80
- assert_equal @success, YAML.load(cookies['geo_location'])
81
- end
82
- end