activerecord-spatial 2.0.0 → 3.0.0
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 +5 -5
- data/.rubocop.yml +3314 -1052
- data/.travis.yml +17 -0
- data/Gemfile +1 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +6 -12
- data/activerecord-spatial.gemspec +1 -1
- data/lib/activerecord-spatial.rb +1 -0
- data/lib/activerecord-spatial/active_record.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions/active_record.rb +4 -3
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/postgis.rb +1 -0
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/unknown_srid.rb +2 -1
- data/lib/activerecord-spatial/active_record/models/geography_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/geometry_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/spatial_column.rb +1 -0
- data/lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb +1 -0
- data/lib/activerecord-spatial/associations.rb +4 -12
- data/lib/activerecord-spatial/associations/active_record.rb +96 -54
- data/lib/activerecord-spatial/associations/base.rb +2 -19
- data/lib/activerecord-spatial/associations/reflection/spatial_reflection.rb +1 -0
- data/lib/activerecord-spatial/associations/spatial_association.rb +41 -0
- data/lib/activerecord-spatial/spatial_columns.rb +1 -0
- data/lib/activerecord-spatial/spatial_function.rb +2 -1
- data/lib/activerecord-spatial/spatial_scope_constants.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_0.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_2.rb +1 -0
- data/lib/activerecord-spatial/spatial_scope_constants/postgis_legacy.rb +1 -0
- data/lib/activerecord-spatial/spatial_scopes.rb +14 -13
- data/lib/activerecord-spatial/version.rb +2 -1
- data/test/accessors_geographies_tests.rb +2 -1
- data/test/accessors_geometries_tests.rb +2 -1
- data/test/adapter_tests.rb +5 -4
- data/test/associations_tests.rb +40 -25
- data/test/geography_column_tests.rb +2 -1
- data/test/geometry_column_tests.rb +2 -1
- data/test/models/bar.rb +1 -9
- data/test/models/blort.rb +1 -7
- data/test/models/foo.rb +3 -9
- data/test/models/foo3d.rb +1 -9
- data/test/models/foo_geography.rb +1 -8
- data/test/models/zortable.rb +1 -9
- data/test/schema.rb +54 -0
- data/test/spatial_function_tests.rb +2 -1
- data/test/spatial_scopes_geographies_tests.rb +2 -1
- data/test/spatial_scopes_tests.rb +2 -1
- data/test/test_helper.rb +57 -91
- metadata +9 -7
- data/lib/activerecord-spatial/associations/preloader/spatial_association.rb +0 -57
data/test/models/bar.rb
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unless ActiveRecordSpatialTestCase.table_exists?('bars')
|
|
3
|
-
ActiveRecord::Migration.create_table(:bars) do |t|
|
|
4
|
-
t.text :name
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'bars', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
8
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'bars', 'the_other_geom', 4326, 'GEOMETRY', 2)})
|
|
9
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
10
2
|
|
|
11
3
|
class Bar < ActiveRecord::Base
|
|
12
4
|
include ActiveRecordSpatial::SpatialColumns
|
data/test/models/blort.rb
CHANGED
data/test/models/foo.rb
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
unless ActiveRecordSpatialTestCase.table_exists?('foos')
|
|
3
|
-
ActiveRecord::Migration.create_table(:foos) do |t|
|
|
4
|
-
t.text :name
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foos', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
8
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foos', 'the_other_geom', 4326, 'GEOMETRY', 2)})
|
|
9
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
10
2
|
|
|
11
3
|
class Foo < ActiveRecord::Base
|
|
12
4
|
include ActiveRecordSpatial::SpatialColumns
|
|
13
5
|
include ActiveRecordSpatial::SpatialScopes
|
|
14
6
|
|
|
15
7
|
create_spatial_column_accessors!
|
|
8
|
+
|
|
9
|
+
has_many :blorts
|
|
16
10
|
end
|
data/test/models/foo3d.rb
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unless ActiveRecordSpatialTestCase.table_exists?('foo3ds')
|
|
3
|
-
ActiveRecord::Migration.create_table(:foo3ds) do |t|
|
|
4
|
-
t.text :name
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foo3ds', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 3)})
|
|
8
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foo3ds', 'the_other_geom', 4326, 'GEOMETRY', 3)})
|
|
9
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
10
2
|
|
|
11
3
|
class Foo3d < ActiveRecord::Base
|
|
12
4
|
include ActiveRecordSpatial::SpatialColumns
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unless ActiveRecordSpatialTestCase.table_exists?('foo_geographies')
|
|
3
|
-
ActiveRecord::Migration.create_table(:foo_geographies) do |t|
|
|
4
|
-
t.text :name
|
|
5
|
-
t.column :the_geom, :geography
|
|
6
|
-
t.column :the_other_geom, 'geography(Geometry, 4326)'
|
|
7
|
-
end
|
|
8
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
9
2
|
|
|
10
3
|
class FooGeography < ActiveRecord::Base
|
|
11
4
|
include ActiveRecordSpatial::SpatialColumns
|
data/test/models/zortable.rb
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
unless ActiveRecordSpatialTestCase.table_exists?('zortables')
|
|
3
|
-
ActiveRecord::Migration.create_table(:zortables) do |t|
|
|
4
|
-
t.text :name
|
|
5
|
-
t.text :zortable_type
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
ARBC.execute(%{SELECT AddGeometryColumn('public', 'zortables', 'zortable_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
9
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
10
2
|
|
|
11
3
|
class Zortable < ActiveRecord::Base
|
|
12
4
|
include ActiveRecordSpatial::SpatialColumns
|
data/test/schema.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
ActiveRecord::Schema.define do
|
|
4
|
+
unless ARBC.data_source_exists?(:foos)
|
|
5
|
+
create_table(:foos) do |t|
|
|
6
|
+
t.text :name
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foos', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
10
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foos', 'the_other_geom', 4326, 'GEOMETRY', 2)})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
unless ARBC.data_source_exists?(:bars)
|
|
14
|
+
create_table(:bars) do |t|
|
|
15
|
+
t.text :name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'bars', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
19
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'bars', 'the_other_geom', 4326, 'GEOMETRY', 2)})
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
unless ARBC.data_source_exists?(:blorts)
|
|
23
|
+
create_table(:blorts) do |t|
|
|
24
|
+
t.text :name
|
|
25
|
+
t.integer :foo_id
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
unless ARBC.data_source_exists?(:foo_geographies)
|
|
30
|
+
create_table(:foo_geographies) do |t|
|
|
31
|
+
t.text :name
|
|
32
|
+
t.column :the_geom, :geography
|
|
33
|
+
t.column :the_other_geom, 'geography(Geometry, 4326)'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
unless ARBC.data_source_exists?(:foo3ds)
|
|
38
|
+
create_table(:foo3ds) do |t|
|
|
39
|
+
t.text :name
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foo3ds', 'the_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 3)})
|
|
43
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'foo3ds', 'the_other_geom', 4326, 'GEOMETRY', 3)})
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
unless ARBC.data_source_exists?(:zortables)
|
|
47
|
+
create_table(:zortables) do |t|
|
|
48
|
+
t.text :name
|
|
49
|
+
t.text :zortable_type
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
ARBC.execute(%{SELECT AddGeometryColumn('public', 'zortables', 'zortable_geom', #{ActiveRecordSpatial::UNKNOWN_SRID}, 'GEOMETRY', 2)})
|
|
53
|
+
end
|
|
54
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
|
|
2
3
|
require 'simplecov'
|
|
3
4
|
|
|
@@ -34,15 +35,15 @@ puts "Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} - #{RbConfig::CONFIG['RUBY_INSTAL
|
|
|
34
35
|
puts "Geos library #{Geos::VERSION}" if defined?(Geos::VERSION)
|
|
35
36
|
puts "GEOS #{Geos::GEOS_VERSION}"
|
|
36
37
|
puts "GEOS extensions #{Geos::GEOS_EXTENSIONS_VERSION}"
|
|
38
|
+
|
|
37
39
|
if defined?(Geos::FFIGeos)
|
|
38
40
|
puts "Using #{Geos::FFIGeos.geos_library_paths.join(', ')}"
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
ActiveSupport::TestCase.test_order = :random
|
|
42
44
|
ActiveRecord::Base.logger = Logger.new('debug.log') if ENV['ENABLE_LOGGER']
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
45
|
+
|
|
46
|
+
configurations = {}
|
|
46
47
|
|
|
47
48
|
%w{
|
|
48
49
|
database.yml
|
|
@@ -54,15 +55,18 @@ ActiveRecord::Base.configurations = {
|
|
|
54
55
|
|
|
55
56
|
configuration = YAML.safe_load(File.read(file))
|
|
56
57
|
|
|
58
|
+
configurations.merge!(configuration)
|
|
59
|
+
|
|
57
60
|
if configuration['arunit']
|
|
58
|
-
|
|
61
|
+
configurations['arunit'].merge!(configuration['arunit'])
|
|
59
62
|
end
|
|
60
63
|
|
|
61
64
|
if defined?(JRUBY_VERSION) && configuration['jdbc']
|
|
62
|
-
|
|
65
|
+
configurations['arunit'].merge!(configuration['jdbc'])
|
|
63
66
|
end
|
|
64
67
|
end
|
|
65
68
|
|
|
69
|
+
ActiveRecord::Base.configurations = configurations
|
|
66
70
|
ActiveRecord::Base.establish_connection :arunit
|
|
67
71
|
ARBC = ActiveRecord::Base.connection
|
|
68
72
|
|
|
@@ -74,33 +78,17 @@ end
|
|
|
74
78
|
|
|
75
79
|
puts 'Checking for PostGIS install'
|
|
76
80
|
2.times do
|
|
77
|
-
|
|
78
|
-
postgis_version = ActiveRecordSpatial::POSTGIS[:lib]
|
|
81
|
+
postgis_version = ActiveRecordSpatial::POSTGIS[:lib]
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
rescue ActiveRecord::StatementInvalid
|
|
85
|
-
puts "Trying to install PostGIS. If this doesn't work, you'll have to do this manually!"
|
|
86
|
-
|
|
87
|
-
plpgsql = ARBC.select_rows(%{SELECT count(*) FROM pg_language WHERE lanname = 'plpgsql'}).first.first.to_i
|
|
88
|
-
ARBC.execute(%{CREATE LANGUAGE plpgsql}) if plpgsql.zero?
|
|
89
|
-
|
|
90
|
-
%w{
|
|
91
|
-
postgis.sql
|
|
92
|
-
spatial_ref_sys.sql
|
|
93
|
-
}.each do |file|
|
|
94
|
-
if !(found = Dir.glob(POSTGIS_PATHS).collect { |path|
|
|
95
|
-
File.join(path, file)
|
|
96
|
-
}.first)
|
|
97
|
-
puts "ERROR: Couldn't find #{file}. Try setting the POSTGIS_PATH to give us a hint!"
|
|
98
|
-
exit
|
|
99
|
-
else
|
|
100
|
-
ARBC.execute(File.read(found))
|
|
101
|
-
end
|
|
102
|
-
end
|
|
83
|
+
if postgis_version.present?
|
|
84
|
+
puts "PostGIS info from postgis_full_version(): #{postgis_version}"
|
|
85
|
+
break
|
|
103
86
|
end
|
|
87
|
+
rescue ActiveRecord::StatementInvalid, PG::UndefinedFunction
|
|
88
|
+
puts "Trying to install PostGIS. If this doesn't work, you'll have to do this manually!"
|
|
89
|
+
|
|
90
|
+
ARBC.enable_extension('plpgsql') unless ARBC.extension_enabled?('plpgsql')
|
|
91
|
+
ARBC.enable_extension('postgis') unless ARBC.extension_enabled?('postgis')
|
|
104
92
|
end
|
|
105
93
|
|
|
106
94
|
class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
@@ -109,26 +97,26 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
|
109
97
|
include ActiveRecord::TestFixtures
|
|
110
98
|
self.fixture_path = BASE_PATH.join('fixtures')
|
|
111
99
|
|
|
112
|
-
REGEXP_WKB_HEX = /[A-Fa-f0-9\s]
|
|
100
|
+
REGEXP_WKB_HEX = /[A-Fa-f0-9\s]+/.freeze
|
|
113
101
|
|
|
114
|
-
POINT_WKT = 'POINT(10 10.01)'
|
|
115
|
-
POINT_EWKT = 'SRID=4326; POINT(10 10.01)'
|
|
116
|
-
POINT_EWKT_WITH_DEFAULT = 'SRID=default; POINT(10 10.01)'
|
|
117
|
-
POINT_WKB = '0101000000000000000000244085EB51B81E052440'
|
|
118
|
-
POINT_WKB_BIN = "\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\x40\x85\xEB\x51\xB8\x1E\x05\x24\x40"
|
|
119
|
-
POINT_EWKB = '0101000020E6100000000000000000244085EB51B81E052440'
|
|
120
|
-
POINT_EWKB_BIN = "\x01\x01\x00\x00\x20\xE6\x10\x00\x00\x00\x00\x00\x00\x00\x00\x24\x40\x85\xEB\x51\xB8\x1E\x05\x24\x40"
|
|
121
|
-
POINT_G_LAT_LNG = '(10.01, 10)'
|
|
122
|
-
POINT_G_LAT_LNG_URL_VALUE = '10.01,10'
|
|
102
|
+
POINT_WKT = 'POINT(10 10.01)'
|
|
103
|
+
POINT_EWKT = 'SRID=4326; POINT(10 10.01)'
|
|
104
|
+
POINT_EWKT_WITH_DEFAULT = 'SRID=default; POINT(10 10.01)'
|
|
105
|
+
POINT_WKB = '0101000000000000000000244085EB51B81E052440'
|
|
106
|
+
POINT_WKB_BIN = "\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x24\x40\x85\xEB\x51\xB8\x1E\x05\x24\x40"
|
|
107
|
+
POINT_EWKB = '0101000020E6100000000000000000244085EB51B81E052440'
|
|
108
|
+
POINT_EWKB_BIN = "\x01\x01\x00\x00\x20\xE6\x10\x00\x00\x00\x00\x00\x00\x00\x00\x24\x40\x85\xEB\x51\xB8\x1E\x05\x24\x40"
|
|
109
|
+
POINT_G_LAT_LNG = '(10.01, 10)'
|
|
110
|
+
POINT_G_LAT_LNG_URL_VALUE = '10.01,10'
|
|
123
111
|
|
|
124
|
-
POLYGON_WKT = 'POLYGON((0 0, 1 1, 2.5 2.5, 5 5, 0 0))'
|
|
125
|
-
POLYGON_EWKT = 'SRID=4326; POLYGON((0 0, 1 1, 2.5 2.5, 5 5, 0 0))'
|
|
112
|
+
POLYGON_WKT = 'POLYGON((0 0, 1 1, 2.5 2.5, 5 5, 0 0))'
|
|
113
|
+
POLYGON_EWKT = 'SRID=4326; POLYGON((0 0, 1 1, 2.5 2.5, 5 5, 0 0))'
|
|
126
114
|
|
|
127
115
|
POLYGON_WKB = '
|
|
128
116
|
0103000000010000000500000000000000000000000000000000000000000000000000F
|
|
129
117
|
03F000000000000F03F0000000000000440000000000000044000000000000014400000
|
|
130
118
|
00000000144000000000000000000000000000000000
|
|
131
|
-
'.gsub(/\s/, '')
|
|
119
|
+
'.gsub(/\s/, '')
|
|
132
120
|
|
|
133
121
|
POLYGON_WKB_BIN = [
|
|
134
122
|
"\x01\x03\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
|
@@ -136,13 +124,13 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
|
136
124
|
"\x00\x00\x00\x00\x00\xF0\x3F\x00\x00\x00\x00\x00\x00\x04\x40\x00\x00\x00\x00",
|
|
137
125
|
"\x00\x00\x04\x40\x00\x00\x00\x00\x00\x00\x14\x40\x00\x00\x00\x00\x00\x00\x14",
|
|
138
126
|
"\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
139
|
-
].join
|
|
127
|
+
].join
|
|
140
128
|
|
|
141
129
|
POLYGON_EWKB = '
|
|
142
130
|
0103000020E610000001000000050000000000000000000000000000000000000000000
|
|
143
131
|
0000000F03F000000000000F03F00000000000004400000000000000440000000000000
|
|
144
132
|
1440000000000000144000000000000000000000000000000000
|
|
145
|
-
'.gsub(/\s/, '')
|
|
133
|
+
'.gsub(/\s/, '')
|
|
146
134
|
|
|
147
135
|
POLYGON_EWKB_BIN = [
|
|
148
136
|
"\x01\x03\x00\x00\x20\xE6\x10\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00",
|
|
@@ -151,11 +139,11 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
|
151
139
|
"\x00\x00\x00\x00\x04\x40\x00\x00\x00\x00\x00\x00\x04\x40\x00\x00\x00",
|
|
152
140
|
"\x00\x00\x00\x14\x40\x00\x00\x00\x00\x00\x00\x14\x40\x00\x00\x00\x00",
|
|
153
141
|
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
|
154
|
-
].join
|
|
142
|
+
].join
|
|
155
143
|
|
|
156
|
-
POLYGON_WITH_INTERIOR_RING = 'POLYGON((0 0, 5 0, 5 5, 0 5, 0 0),(4 4, 4 1, 1 1, 1 4, 4 4))'
|
|
144
|
+
POLYGON_WITH_INTERIOR_RING = 'POLYGON((0 0, 5 0, 5 5, 0 5, 0 0),(4 4, 4 1, 1 1, 1 4, 4 4))'
|
|
157
145
|
|
|
158
|
-
LINESTRING_WKT = 'LINESTRING (0 0, 5 5, 5 10, 10 10)'
|
|
146
|
+
LINESTRING_WKT = 'LINESTRING (0 0, 5 5, 5 10, 10 10)'
|
|
159
147
|
|
|
160
148
|
GEOMETRYCOLLECTION_WKT = 'GEOMETRYCOLLECTION (
|
|
161
149
|
MULTIPOLYGON (
|
|
@@ -171,46 +159,28 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
|
171
159
|
LINESTRING (0 0, 2 3),
|
|
172
160
|
MULTIPOINT ((0 0), (2 3)),
|
|
173
161
|
POINT (9 0)
|
|
174
|
-
)'
|
|
175
|
-
|
|
176
|
-
BOUNDS_G_LAT_LNG = '((0.1, 0.1), (5.2, 5.2))'.freeze
|
|
177
|
-
BOUNDS_G_LAT_LNG_URL_VALUE = '0.1,0.1,5.2,5.2'.freeze
|
|
162
|
+
)'
|
|
178
163
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
self.fixture_table_names = args.collect do |arg|
|
|
182
|
-
arg.to_s.pluralize
|
|
183
|
-
end
|
|
164
|
+
BOUNDS_G_LAT_LNG = '((0.1, 0.1), (5.2, 5.2))'
|
|
165
|
+
BOUNDS_G_LAT_LNG_URL_VALUE = '0.1,0.1,5.2,5.2'
|
|
184
166
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
fixtures model.tableize
|
|
189
|
-
|
|
190
|
-
ActiveSupport::Dependencies.load_file(BASE_PATH.join("models/#{model}.rb"), [klass])
|
|
191
|
-
end
|
|
167
|
+
def load_models(*args)
|
|
168
|
+
args.each do |model|
|
|
169
|
+
require_dependency(BASE_PATH.join("models/#{model}.rb"))
|
|
192
170
|
end
|
|
171
|
+
end
|
|
193
172
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Foo.class_eval do
|
|
198
|
-
has_many_spatially :foos
|
|
199
|
-
has_many_spatially :bars
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
Bar.class_eval do
|
|
203
|
-
has_many_spatially :foos
|
|
204
|
-
has_many_spatially :bars
|
|
205
|
-
end
|
|
206
|
-
end
|
|
173
|
+
def load_default_models
|
|
174
|
+
load_models(:foo, :bar)
|
|
207
175
|
|
|
208
|
-
|
|
209
|
-
|
|
176
|
+
Foo.class_eval do
|
|
177
|
+
has_many_spatially :foos
|
|
178
|
+
has_many_spatially :bars
|
|
210
179
|
end
|
|
211
180
|
|
|
212
|
-
|
|
213
|
-
|
|
181
|
+
Bar.class_eval do
|
|
182
|
+
has_many_spatially :foos
|
|
183
|
+
has_many_spatially :bars
|
|
214
184
|
end
|
|
215
185
|
end
|
|
216
186
|
|
|
@@ -244,15 +214,11 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
|
244
214
|
end
|
|
245
215
|
|
|
246
216
|
class SpatialTestRunner < Minitest::Reporters::SpecReporter
|
|
247
|
-
|
|
248
|
-
super(suite)
|
|
249
|
-
suite.before_suite if suite.respond_to?(:before_suite)
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
def after_suite(suite)
|
|
253
|
-
super(suite)
|
|
254
|
-
suite.after_suite if suite.respond_to?(:after_suite)
|
|
255
|
-
end
|
|
217
|
+
# no-op
|
|
256
218
|
end
|
|
257
219
|
|
|
258
|
-
Minitest::Reporters.use!(SpatialTestRunner.new)
|
|
220
|
+
Minitest::Reporters.use!(SpatialTestRunner.new, ENV, Minitest::ExtensibleBacktraceFilter.default_filter)
|
|
221
|
+
|
|
222
|
+
require './test/schema'
|
|
223
|
+
|
|
224
|
+
ActiveRecord::FixtureSet.create_fixtures("#{__dir__}/fixtures", Dir.glob("#{__dir__}/fixtures/*.yml").collect { |file| File.basename(file).gsub(/.yml$/, '') })
|