geokit-rails 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +80 -0
- data/.gitignore +44 -37
- data/CHANGELOG.md +106 -101
- data/CONFIG.markdown +67 -67
- data/Gemfile +3 -3
- data/MIT-LICENSE +19 -19
- data/README.markdown +726 -726
- data/Rakefile +17 -17
- data/gemfiles/rails7.1.gemfile +11 -0
- data/gemfiles/{rails5.gemfile → rails7.2.gemfile} +7 -7
- data/gemfiles/{rails6.0.gemfile → rails8.0.gemfile} +7 -8
- data/gemfiles/{rails6.1.gemfile → rails8.1.gemfile} +7 -8
- data/geokit-rails.gemspec +34 -34
- data/lib/generators/geokit_rails/install_generator.rb +13 -13
- data/lib/generators/templates/geokit_config.rb +100 -100
- data/lib/geokit-rails/acts_as_mappable/class_methods.rb +299 -297
- data/lib/geokit-rails/acts_as_mappable/glue.rb +54 -54
- data/lib/geokit-rails/acts_as_mappable.rb +78 -78
- data/lib/geokit-rails/adapters/abstract.rb +30 -30
- data/lib/geokit-rails/adapters/mysql.rb +21 -21
- data/lib/geokit-rails/adapters/mysql2.rb +8 -8
- data/lib/geokit-rails/adapters/mysql2spatial.rb +8 -8
- data/lib/geokit-rails/adapters/oracleenhanced.rb +32 -32
- data/lib/geokit-rails/adapters/postgresql.rb +21 -21
- data/lib/geokit-rails/adapters/sqlite.rb +53 -53
- data/lib/geokit-rails/adapters/sqlserver.rb +45 -45
- data/lib/geokit-rails/distance_collection.rb +8 -8
- data/lib/geokit-rails/geocoder_control.rb +19 -19
- data/lib/geokit-rails/ip_geocode_lookup.rb +44 -45
- data/lib/geokit-rails/railtie.rb +37 -37
- data/lib/geokit-rails/version.rb +3 -3
- data/lib/geokit-rails.rb +11 -11
- data/test/acts_as_mappable_test.rb +486 -478
- data/test/adapter_resolution_test.rb +46 -0
- data/test/boot.rb +40 -32
- data/test/database.yml +31 -28
- data/test/distance_collection_test.rb +41 -41
- data/test/dummy/Rakefile +6 -6
- data/test/dummy/app/assets/stylesheets/application.css +1 -1
- data/test/dummy/app/channels/application_cable/channel.rb +4 -4
- data/test/dummy/app/channels/application_cable/connection.rb +4 -4
- data/test/dummy/app/controllers/application_controller.rb +3 -3
- data/test/dummy/app/controllers/location_aware_controller.rb +42 -42
- data/test/dummy/app/helpers/application_helper.rb +2 -2
- data/test/dummy/app/jobs/application_job.rb +7 -7
- data/test/dummy/app/mailers/application_mailer.rb +4 -4
- data/test/dummy/app/models/application_record.rb +3 -3
- data/test/dummy/app/views/layouts/application.html.erb +15 -15
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -13
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -1
- data/test/dummy/bin/rails +4 -4
- data/test/dummy/bin/rake +4 -4
- data/test/dummy/bin/setup +33 -33
- data/test/dummy/config/application.rb +22 -22
- data/test/dummy/config/boot.rb +5 -5
- data/test/dummy/config/cable.yml +10 -10
- data/test/dummy/config/database.yml +25 -25
- data/test/dummy/config/environment.rb +5 -5
- data/test/dummy/config/environments/development.rb +68 -68
- data/test/dummy/config/environments/production.rb +87 -87
- data/test/dummy/config/environments/test.rb +60 -60
- data/test/dummy/config/initializers/content_security_policy.rb +25 -25
- data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -8
- data/test/dummy/config/initializers/inflections.rb +16 -16
- data/test/dummy/config/initializers/permissions_policy.rb +11 -11
- data/test/dummy/config/locales/en.yml +33 -33
- data/test/dummy/config/puma.rb +43 -43
- data/test/dummy/config/routes.rb +6 -6
- data/test/dummy/config/storage.yml +34 -34
- data/test/dummy/config.ru +6 -6
- data/test/dummy/public/404.html +67 -67
- data/test/dummy/public/422.html +67 -67
- data/test/dummy/public/500.html +66 -66
- data/test/fixtures/companies.yml +9 -9
- data/test/fixtures/custom_locations.yml +61 -61
- data/test/fixtures/locations.yml +61 -61
- data/test/fixtures/mock_addresses.yml +16 -16
- data/test/fixtures/mock_families.yml +2 -2
- data/test/fixtures/mock_houses.yml +8 -8
- data/test/fixtures/mock_organizations.yml +4 -4
- data/test/fixtures/mock_people.yml +4 -4
- data/test/ip_geocode_lookup_test.rb +52 -48
- data/test/models/company.rb +2 -2
- data/test/models/custom_location.rb +11 -11
- data/test/models/location.rb +3 -3
- data/test/models/mock_address.rb +3 -3
- data/test/models/mock_family.rb +4 -4
- data/test/models/mock_house.rb +2 -2
- data/test/models/mock_organization.rb +5 -5
- data/test/models/mock_person.rb +6 -6
- data/test/models/store.rb +2 -2
- data/test/schema.rb +61 -61
- data/test/tasks.rake +37 -37
- data/test/test_helper.rb +83 -73
- metadata +13 -15
- data/.travis.yml +0 -55
- data/gemfiles/rails3.gemfile +0 -8
- data/gemfiles/rails4.gemfile +0 -8
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class AdapterResolutionTest < GeokitTestCase
|
|
6
|
+
def test_mysql2_adapter
|
|
7
|
+
begin
|
|
8
|
+
# Defines the top-level ::Mysql2 module, which must not be mistaken for
|
|
9
|
+
# the Geokit adapter of the same name.
|
|
10
|
+
require 'mysql2'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
skip 'the mysql2 gem cannot be loaded here'
|
|
13
|
+
end
|
|
14
|
+
adapter = finder_adapter_for('Mysql2')
|
|
15
|
+
assert_instance_of Geokit::Adapters::Mysql2, adapter
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Database gems can define a top-level class named like an adapter, as the
|
|
19
|
+
# trilogy gem does with Trilogy.
|
|
20
|
+
def test_ignores_top_level_class_named_like_the_adapter
|
|
21
|
+
Object.const_set(:OracleEnhanced, Class.new)
|
|
22
|
+
adapter = finder_adapter_for('OracleEnhanced')
|
|
23
|
+
assert_instance_of Geokit::Adapters::OracleEnhanced, adapter
|
|
24
|
+
ensure
|
|
25
|
+
Object.send(:remove_const, :OracleEnhanced)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_unsupported_adapter
|
|
29
|
+
assert_raises(Geokit::ActsAsMappable::UnsupportedAdapter) do
|
|
30
|
+
finder_adapter_for('Unknown')
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# Resolves the adapter on a throwaway model whose connection reports the
|
|
37
|
+
# given adapter name, leaving Location's real connection and memoized
|
|
38
|
+
# adapter untouched.
|
|
39
|
+
def finder_adapter_for(adapter_name)
|
|
40
|
+
fake_connection = Struct.new(:adapter_name).new(adapter_name)
|
|
41
|
+
model = Class.new(Location) do
|
|
42
|
+
define_singleton_method(:connection) { fake_connection }
|
|
43
|
+
end
|
|
44
|
+
model.geokit_finder_adapter
|
|
45
|
+
end
|
|
46
|
+
end
|
data/test/boot.rb
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
require 'pathname'
|
|
2
|
-
|
|
3
|
-
require "active_support/version"
|
|
4
|
-
require 'active_support/test_case'
|
|
5
|
-
require "active_support/testing/autorun" if ActiveSupport::VERSION::MAJOR >= 4
|
|
6
|
-
|
|
7
|
-
require 'active_record'
|
|
8
|
-
require 'active_record/fixtures'
|
|
9
|
-
|
|
10
|
-
require 'action_controller'
|
|
11
|
-
# require 'action_dispatch'
|
|
12
|
-
# require 'action_dispatch/testing/test_process'
|
|
13
|
-
|
|
14
|
-
pwd = Pathname.new(File.dirname(__FILE__)).expand_path
|
|
15
|
-
|
|
16
|
-
PLUGIN_ROOT = pwd + '..'
|
|
17
|
-
ADAPTER = ENV['DB'] || 'sqlite'
|
|
18
|
-
|
|
19
|
-
$LOAD_PATH << (PLUGIN_ROOT + 'lib')
|
|
20
|
-
$LOAD_PATH << (PLUGIN_ROOT + 'test/models')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
require "active_support/version"
|
|
4
|
+
require 'active_support/test_case'
|
|
5
|
+
require "active_support/testing/autorun" if ActiveSupport::VERSION::MAJOR >= 4
|
|
6
|
+
|
|
7
|
+
require 'active_record'
|
|
8
|
+
require 'active_record/fixtures'
|
|
9
|
+
|
|
10
|
+
require 'action_controller'
|
|
11
|
+
# require 'action_dispatch'
|
|
12
|
+
# require 'action_dispatch/testing/test_process'
|
|
13
|
+
|
|
14
|
+
pwd = Pathname.new(File.dirname(__FILE__)).expand_path
|
|
15
|
+
|
|
16
|
+
PLUGIN_ROOT = pwd + '..'
|
|
17
|
+
ADAPTER = ENV['DB'] || 'sqlite'
|
|
18
|
+
|
|
19
|
+
$LOAD_PATH << (PLUGIN_ROOT + 'lib')
|
|
20
|
+
$LOAD_PATH << (PLUGIN_ROOT + 'test/models')
|
|
21
|
+
|
|
22
|
+
require 'erb'
|
|
23
|
+
|
|
24
|
+
config_file = PLUGIN_ROOT + 'test/database.yml'
|
|
25
|
+
config_content = ERB.new(IO.read(config_file)).result
|
|
26
|
+
if defined?(YAML.safe_load)
|
|
27
|
+
db_config = YAML.safe_load(config_content, aliases: true)
|
|
28
|
+
else
|
|
29
|
+
# Fallback for older Ruby versions that don't support YAML.safe_load
|
|
30
|
+
db_config = YAML.load(config_content) # rubocop:disable Security/YAMLLoad
|
|
31
|
+
end
|
|
32
|
+
logger_file = PLUGIN_ROOT + "test/#{ADAPTER}-debug.log"
|
|
33
|
+
schema_file = PLUGIN_ROOT + 'test/schema.rb'
|
|
34
|
+
|
|
35
|
+
ActiveRecord::Base.configurations = db_config
|
|
36
|
+
ActiveRecord::Base.logger = Logger.new(logger_file)
|
|
37
|
+
ActiveRecord::Base.establish_connection(db_config[ADAPTER])
|
|
38
|
+
|
|
39
|
+
ActiveRecord::Migration.verbose = false
|
|
40
|
+
load schema_file
|
data/test/database.yml
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
base: &base
|
|
2
|
-
host: localhost
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
base: &base
|
|
2
|
+
host: <%= ENV.fetch('DB_HOST', 'localhost') %>
|
|
3
|
+
<% if ENV['DB_PORT'] %>
|
|
4
|
+
port: <%= ENV['DB_PORT'] %>
|
|
5
|
+
<% end %>
|
|
6
|
+
username: <%= ENV.fetch('DB_USERNAME', 'tests') %>
|
|
7
|
+
password: <%= ENV['DB_PASSWORD'] %>
|
|
8
|
+
|
|
9
|
+
mysql:
|
|
10
|
+
adapter: mysql2
|
|
11
|
+
database: geokit_rails_tests
|
|
12
|
+
<<: *base
|
|
13
|
+
|
|
14
|
+
mysql2spatial:
|
|
15
|
+
adapter: mysql2spatial
|
|
16
|
+
database: geokit_rails_tests
|
|
17
|
+
|
|
18
|
+
postgresql:
|
|
19
|
+
adapter: postgresql
|
|
20
|
+
database: geokit_rails_tests
|
|
21
|
+
<<: *base
|
|
22
|
+
|
|
23
|
+
sqlserver:
|
|
24
|
+
adapter: sqlserver
|
|
25
|
+
mode: ODBC
|
|
26
|
+
dsn: geokit_rails_tests
|
|
27
|
+
username: tests
|
|
28
|
+
|
|
29
|
+
sqlite:
|
|
30
|
+
adapter: sqlite3
|
|
31
|
+
database: test/test.sqlite3
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
Geokit::Geocoders::provider_order = [:google, :us]
|
|
4
|
-
|
|
5
|
-
class DistanceCollectionTest < GeokitTestCase
|
|
6
|
-
|
|
7
|
-
LOCATION_A_IP = "217.10.83.5"
|
|
8
|
-
|
|
9
|
-
def setup
|
|
10
|
-
@location_a = Geokit::GeoLoc.new
|
|
11
|
-
@location_a.lat = 32.918593
|
|
12
|
-
@location_a.lng = -96.958444
|
|
13
|
-
@location_a.city = "Irving"
|
|
14
|
-
@location_a.state = "TX"
|
|
15
|
-
@location_a.country_code = "US"
|
|
16
|
-
@location_a.success = true
|
|
17
|
-
|
|
18
|
-
@sw = Geokit::LatLng.new(32.91663,-96.982841)
|
|
19
|
-
@ne = Geokit::LatLng.new(32.96302,-96.919495)
|
|
20
|
-
@bounds_center=Geokit::LatLng.new((@sw.lat+@ne.lat)/2,(@sw.lng+@ne.lng)/2)
|
|
21
|
-
|
|
22
|
-
@starbucks = companies(:starbucks)
|
|
23
|
-
@loc_a = locations(:a)
|
|
24
|
-
@custom_loc_a = custom_locations(:a)
|
|
25
|
-
@loc_e = locations(:e)
|
|
26
|
-
@custom_loc_e = custom_locations(:e)
|
|
27
|
-
|
|
28
|
-
@barnes_and_noble = mock_organizations(:barnes_and_noble)
|
|
29
|
-
@address = mock_addresses(:address_barnes_and_noble)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_distance_collection
|
|
33
|
-
# Improve this test later on.
|
|
34
|
-
locations = Location.with_latlng.all
|
|
35
|
-
unsorted = [locations(:a), locations(:b), locations(:c), locations(:d), locations(:e), locations(:f)]
|
|
36
|
-
sorted_manually = locations.sort_by{|l| l.distance_to(locations(:a))}
|
|
37
|
-
sorted_automatically = DistanceCollection.new(unsorted)
|
|
38
|
-
sorted_automatically.set_distance_from(locations(:a))
|
|
39
|
-
assert_equal sorted_manually, sorted_automatically.sort_by(&:distance)
|
|
40
|
-
end
|
|
41
|
-
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
Geokit::Geocoders::provider_order = [:google, :us]
|
|
4
|
+
|
|
5
|
+
class DistanceCollectionTest < GeokitTestCase
|
|
6
|
+
|
|
7
|
+
LOCATION_A_IP = "217.10.83.5"
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
@location_a = Geokit::GeoLoc.new
|
|
11
|
+
@location_a.lat = 32.918593
|
|
12
|
+
@location_a.lng = -96.958444
|
|
13
|
+
@location_a.city = "Irving"
|
|
14
|
+
@location_a.state = "TX"
|
|
15
|
+
@location_a.country_code = "US"
|
|
16
|
+
@location_a.success = true
|
|
17
|
+
|
|
18
|
+
@sw = Geokit::LatLng.new(32.91663,-96.982841)
|
|
19
|
+
@ne = Geokit::LatLng.new(32.96302,-96.919495)
|
|
20
|
+
@bounds_center=Geokit::LatLng.new((@sw.lat+@ne.lat)/2,(@sw.lng+@ne.lng)/2)
|
|
21
|
+
|
|
22
|
+
@starbucks = companies(:starbucks)
|
|
23
|
+
@loc_a = locations(:a)
|
|
24
|
+
@custom_loc_a = custom_locations(:a)
|
|
25
|
+
@loc_e = locations(:e)
|
|
26
|
+
@custom_loc_e = custom_locations(:e)
|
|
27
|
+
|
|
28
|
+
@barnes_and_noble = mock_organizations(:barnes_and_noble)
|
|
29
|
+
@address = mock_addresses(:address_barnes_and_noble)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_distance_collection
|
|
33
|
+
# Improve this test later on.
|
|
34
|
+
locations = Location.with_latlng.all
|
|
35
|
+
unsorted = [locations(:a), locations(:b), locations(:c), locations(:d), locations(:e), locations(:f)]
|
|
36
|
+
sorted_manually = locations.sort_by{|l| l.distance_to(locations(:a))}
|
|
37
|
+
sorted_automatically = DistanceCollection.new(unsorted)
|
|
38
|
+
sorted_automatically.set_distance_from(locations(:a))
|
|
39
|
+
assert_equal sorted_manually, sorted_automatically.sort_by(&:distance)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
42
|
end
|
data/test/dummy/Rakefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
-
|
|
4
|
-
require_relative "config/application"
|
|
5
|
-
|
|
6
|
-
Rails.application.load_tasks
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require_relative "config/application"
|
|
5
|
+
|
|
6
|
+
Rails.application.load_tasks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* Application styles */
|
|
1
|
+
/* Application styles */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module ApplicationCable
|
|
2
|
-
class Channel < ActionCable::Channel::Base
|
|
3
|
-
end
|
|
4
|
-
end
|
|
1
|
+
module ApplicationCable
|
|
2
|
+
class Channel < ActionCable::Channel::Base
|
|
3
|
+
end
|
|
4
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module ApplicationCable
|
|
2
|
-
class Connection < ActionCable::Connection::Base
|
|
3
|
-
end
|
|
4
|
-
end
|
|
1
|
+
module ApplicationCable
|
|
2
|
+
class Connection < ActionCable::Connection::Base
|
|
3
|
+
end
|
|
4
|
+
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class ApplicationController < ActionController::Base
|
|
2
|
-
attr_accessor :remote_ip
|
|
3
|
-
end
|
|
1
|
+
class ApplicationController < ActionController::Base
|
|
2
|
+
attr_accessor :remote_ip
|
|
3
|
+
end
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
class LocationAwareController < ApplicationController #:nodoc: all
|
|
2
|
-
before_action :set_ip, only: [:index,:cookietest,:sessiontest]
|
|
3
|
-
before_action :set_ip_bad, only: [:failtest]
|
|
4
|
-
before_action :setup, only: [:cookietest,:sessiontest]
|
|
5
|
-
geocode_ip_address
|
|
6
|
-
|
|
7
|
-
def index
|
|
8
|
-
render plain: ''
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def cookietest
|
|
12
|
-
cookies[:geo_location] = @success.to_json
|
|
13
|
-
render plain: ''
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def sessiontest
|
|
17
|
-
session[:geo_location] = @success.to_json
|
|
18
|
-
render plain: ''
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def failtest
|
|
22
|
-
render plain: ''
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def rescue_action(e) raise e end;
|
|
26
|
-
private
|
|
27
|
-
def set_ip
|
|
28
|
-
request.remote_ip = "good ip"
|
|
29
|
-
end
|
|
30
|
-
def set_ip_bad
|
|
31
|
-
request.remote_ip = "bad ip"
|
|
32
|
-
end
|
|
33
|
-
def setup
|
|
34
|
-
@success = Geokit::GeoLoc.new
|
|
35
|
-
@success.provider = "hostip"
|
|
36
|
-
@success.lat = 41.7696
|
|
37
|
-
@success.lng = -88.4588
|
|
38
|
-
@success.city = "Sugar Grove"
|
|
39
|
-
@success.state = "IL"
|
|
40
|
-
@success.country_code = "US"
|
|
41
|
-
@success.success = true
|
|
42
|
-
end
|
|
1
|
+
class LocationAwareController < ApplicationController #:nodoc: all
|
|
2
|
+
before_action :set_ip, only: [:index,:cookietest,:sessiontest]
|
|
3
|
+
before_action :set_ip_bad, only: [:failtest]
|
|
4
|
+
before_action :setup, only: [:cookietest,:sessiontest]
|
|
5
|
+
geocode_ip_address
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
render plain: ''
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def cookietest
|
|
12
|
+
cookies[:geo_location] = @success.to_json
|
|
13
|
+
render plain: ''
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def sessiontest
|
|
17
|
+
session[:geo_location] = @success.to_json
|
|
18
|
+
render plain: ''
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def failtest
|
|
22
|
+
render plain: ''
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def rescue_action(e) raise e end;
|
|
26
|
+
private
|
|
27
|
+
def set_ip
|
|
28
|
+
request.remote_ip = "good ip"
|
|
29
|
+
end
|
|
30
|
+
def set_ip_bad
|
|
31
|
+
request.remote_ip = "bad ip"
|
|
32
|
+
end
|
|
33
|
+
def setup
|
|
34
|
+
@success = Geokit::GeoLoc.new
|
|
35
|
+
@success.provider = "hostip"
|
|
36
|
+
@success.lat = 41.7696
|
|
37
|
+
@success.lng = -88.4588
|
|
38
|
+
@success.city = "Sugar Grove"
|
|
39
|
+
@success.state = "IL"
|
|
40
|
+
@success.country_code = "US"
|
|
41
|
+
@success.success = true
|
|
42
|
+
end
|
|
43
43
|
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module ApplicationHelper
|
|
2
|
-
end
|
|
1
|
+
module ApplicationHelper
|
|
2
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
class ApplicationJob < ActiveJob::Base
|
|
2
|
-
# Automatically retry jobs that encountered a deadlock
|
|
3
|
-
# retry_on ActiveRecord::Deadlocked
|
|
4
|
-
|
|
5
|
-
# Most jobs are safe to ignore if the underlying records are no longer available
|
|
6
|
-
# discard_on ActiveJob::DeserializationError
|
|
7
|
-
end
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
|
4
|
+
|
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
|
7
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class ApplicationMailer < ActionMailer::Base
|
|
2
|
-
default from: "from@example.com"
|
|
3
|
-
layout "mailer"
|
|
4
|
-
end
|
|
1
|
+
class ApplicationMailer < ActionMailer::Base
|
|
2
|
+
default from: "from@example.com"
|
|
3
|
+
layout "mailer"
|
|
4
|
+
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
class ApplicationRecord < ActiveRecord::Base
|
|
2
|
-
primary_abstract_class
|
|
3
|
-
end
|
|
1
|
+
class ApplicationRecord < ActiveRecord::Base
|
|
2
|
+
primary_abstract_class
|
|
3
|
+
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>Dummy</title>
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<%= csrf_meta_tags %>
|
|
7
|
-
<%= csp_meta_tag %>
|
|
8
|
-
|
|
9
|
-
<%= stylesheet_link_tag "application" %>
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
<%= yield %>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<%= csrf_meta_tags %>
|
|
7
|
+
<%= csp_meta_tag %>
|
|
8
|
+
|
|
9
|
+
<%= stylesheet_link_tag "application" %>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
<%= yield %>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
5
|
-
<style>
|
|
6
|
-
/* Email styles need to be inline */
|
|
7
|
-
</style>
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body>
|
|
11
|
-
<%= yield %>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
/* Email styles need to be inline */
|
|
7
|
+
</style>
|
|
8
|
+
</head>
|
|
9
|
+
|
|
10
|
+
<body>
|
|
11
|
+
<%= yield %>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= yield %>
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rails
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
APP_PATH = File.expand_path("../config/application", __dir__)
|
|
3
|
-
require_relative "../config/boot"
|
|
4
|
-
require "rails/commands"
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
|
3
|
+
require_relative "../config/boot"
|
|
4
|
+
require "rails/commands"
|
data/test/dummy/bin/rake
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
require_relative "../config/boot"
|
|
3
|
-
require "rake"
|
|
4
|
-
Rake.application.run
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require_relative "../config/boot"
|
|
3
|
+
require "rake"
|
|
4
|
+
Rake.application.run
|
data/test/dummy/bin/setup
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
require "fileutils"
|
|
3
|
-
|
|
4
|
-
# path to your application root.
|
|
5
|
-
APP_ROOT = File.expand_path("..", __dir__)
|
|
6
|
-
|
|
7
|
-
def system!(*args)
|
|
8
|
-
system(*args) || abort("\n== Command #{args} failed ==")
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
FileUtils.chdir APP_ROOT do
|
|
12
|
-
# This script is a way to set up or update your development environment automatically.
|
|
13
|
-
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
14
|
-
# Add necessary setup steps to this file.
|
|
15
|
-
|
|
16
|
-
puts "== Installing dependencies =="
|
|
17
|
-
system! "gem install bundler --conservative"
|
|
18
|
-
system("bundle check") || system!("bundle install")
|
|
19
|
-
|
|
20
|
-
# puts "\n== Copying sample files =="
|
|
21
|
-
# unless File.exist?("config/database.yml")
|
|
22
|
-
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
|
23
|
-
# end
|
|
24
|
-
|
|
25
|
-
puts "\n== Preparing database =="
|
|
26
|
-
system! "bin/rails db:prepare"
|
|
27
|
-
|
|
28
|
-
puts "\n== Removing old logs and tempfiles =="
|
|
29
|
-
system! "bin/rails log:clear tmp:clear"
|
|
30
|
-
|
|
31
|
-
puts "\n== Restarting application server =="
|
|
32
|
-
system! "bin/rails restart"
|
|
33
|
-
end
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
# path to your application root.
|
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
|
6
|
+
|
|
7
|
+
def system!(*args)
|
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
FileUtils.chdir APP_ROOT do
|
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
14
|
+
# Add necessary setup steps to this file.
|
|
15
|
+
|
|
16
|
+
puts "== Installing dependencies =="
|
|
17
|
+
system! "gem install bundler --conservative"
|
|
18
|
+
system("bundle check") || system!("bundle install")
|
|
19
|
+
|
|
20
|
+
# puts "\n== Copying sample files =="
|
|
21
|
+
# unless File.exist?("config/database.yml")
|
|
22
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
puts "\n== Preparing database =="
|
|
26
|
+
system! "bin/rails db:prepare"
|
|
27
|
+
|
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
|
30
|
+
|
|
31
|
+
puts "\n== Restarting application server =="
|
|
32
|
+
system! "bin/rails restart"
|
|
33
|
+
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require_relative "boot"
|
|
2
|
-
|
|
3
|
-
require "rails/all"
|
|
4
|
-
|
|
5
|
-
# Require the gems listed in Gemfile, including any gems
|
|
6
|
-
# you've limited to :test, :development, or :production.
|
|
7
|
-
Bundler.require(*Rails.groups)
|
|
8
|
-
require "geokit-rails"
|
|
9
|
-
|
|
10
|
-
module Dummy
|
|
11
|
-
class Application < Rails::Application
|
|
12
|
-
config.load_defaults Rails::VERSION::STRING.to_f
|
|
13
|
-
|
|
14
|
-
# Configuration for the application, engines, and railties goes here.
|
|
15
|
-
#
|
|
16
|
-
# These settings can be overridden in specific environments using the files
|
|
17
|
-
# in config/environments, which are processed later.
|
|
18
|
-
#
|
|
19
|
-
# config.time_zone = "Central Time (US & Canada)"
|
|
20
|
-
# config.eager_load_paths << Rails.root.join("extras")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
require_relative "boot"
|
|
2
|
+
|
|
3
|
+
require "rails/all"
|
|
4
|
+
|
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
7
|
+
Bundler.require(*Rails.groups)
|
|
8
|
+
require "geokit-rails"
|
|
9
|
+
|
|
10
|
+
module Dummy
|
|
11
|
+
class Application < Rails::Application
|
|
12
|
+
config.load_defaults Rails::VERSION::STRING.to_f
|
|
13
|
+
|
|
14
|
+
# Configuration for the application, engines, and railties goes here.
|
|
15
|
+
#
|
|
16
|
+
# These settings can be overridden in specific environments using the files
|
|
17
|
+
# in config/environments, which are processed later.
|
|
18
|
+
#
|
|
19
|
+
# config.time_zone = "Central Time (US & Canada)"
|
|
20
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
|
21
|
+
end
|
|
22
|
+
end
|
data/test/dummy/config/boot.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Set up gems listed in the Gemfile.
|
|
2
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
|
3
|
-
|
|
4
|
-
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|
|
1
|
+
# Set up gems listed in the Gemfile.
|
|
2
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__)
|
|
3
|
+
|
|
4
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
|
5
|
+
$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__)
|