activerecord-spatial 1.0.0 → 2.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1670 -0
  3. data/Gemfile +12 -13
  4. data/Guardfile +7 -10
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +8 -19
  7. data/Rakefile +2 -1
  8. data/activerecord-spatial.gemspec +12 -13
  9. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions/active_record.rb +46 -0
  10. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +7 -38
  11. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/postgis.rb +6 -7
  12. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/unknown_srid.rb +4 -5
  13. data/lib/activerecord-spatial/active_record/models/geography_column.rb +1 -2
  14. data/lib/activerecord-spatial/active_record/models/geometry_column.rb +1 -2
  15. data/lib/activerecord-spatial/active_record/models/spatial_column.rb +1 -2
  16. data/lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb +5 -6
  17. data/lib/activerecord-spatial/active_record.rb +0 -1
  18. data/lib/activerecord-spatial/associations/active_record.rb +62 -120
  19. data/lib/activerecord-spatial/associations/base.rb +26 -75
  20. data/lib/activerecord-spatial/associations/preloader/spatial_association.rb +57 -0
  21. data/lib/activerecord-spatial/associations/reflection/spatial_reflection.rb +41 -0
  22. data/lib/activerecord-spatial/associations.rb +26 -4
  23. data/lib/activerecord-spatial/spatial_columns.rb +85 -94
  24. data/lib/activerecord-spatial/spatial_function.rb +62 -51
  25. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_0.rb +48 -0
  26. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_2.rb +46 -0
  27. data/lib/activerecord-spatial/spatial_scope_constants/postgis_legacy.rb +30 -0
  28. data/lib/activerecord-spatial/spatial_scope_constants.rb +10 -61
  29. data/lib/activerecord-spatial/spatial_scopes.rb +47 -49
  30. data/lib/activerecord-spatial/version.rb +1 -2
  31. data/lib/activerecord-spatial.rb +2 -6
  32. data/lib/tasks/test.rake +21 -19
  33. data/test/.rubocop.yml +35 -0
  34. data/test/accessors_geographies_tests.rb +19 -19
  35. data/test/accessors_geometries_tests.rb +19 -19
  36. data/test/adapter_tests.rb +1 -2
  37. data/test/associations_tests.rb +181 -203
  38. data/test/geography_column_tests.rb +2 -3
  39. data/test/geometry_column_tests.rb +1 -2
  40. data/test/models/bar.rb +2 -3
  41. data/test/models/blort.rb +1 -2
  42. data/test/models/foo.rb +2 -3
  43. data/test/models/foo3d.rb +2 -3
  44. data/test/models/foo_geography.rb +2 -3
  45. data/test/models/zortable.rb +2 -3
  46. data/test/spatial_function_tests.rb +12 -17
  47. data/test/spatial_scopes_geographies_tests.rb +17 -20
  48. data/test/spatial_scopes_tests.rb +84 -75
  49. data/test/test_helper.rb +66 -79
  50. metadata +16 -14
  51. data/lib/activerecord-spatial/associations/active_record_3.rb +0 -123
@@ -1,5 +1,5 @@
1
1
 
2
- $: << File.dirname(__FILE__)
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
3
  require 'test_helper'
4
4
 
5
5
  class SpatialScopesTests < ActiveRecordSpatialTestCase
@@ -13,82 +13,80 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
13
13
  end
14
14
 
15
15
  def test_contains
16
- ids_tester(:st_contains, 'POINT(3 3)', [ 3 ])
16
+ ids_tester(:st_contains, 'POINT(3 3)', [3])
17
17
  end
18
18
 
19
19
  def test_containsproperly
20
- ids_tester(:st_containsproperly, 'LINESTRING(-4 -4, 4 4)', [ 3 ])
20
+ ids_tester(:st_containsproperly, 'LINESTRING(-4 -4, 4 4)', [3])
21
21
  end
22
22
 
23
23
  def test_covers
24
- ids_tester(:st_covers, 'LINESTRING(-4 -4, 4 4)', [ 3 ])
24
+ ids_tester(:st_covers, 'LINESTRING(-4 -4, 4 4)', [3])
25
25
  end
26
26
 
27
27
  def test_coveredby
28
- ids_tester(:st_coveredby, 'POLYGON((-6 -6, -6 6, 6 6, 6 -6, -6 -6))', [ 1, 3 ])
28
+ ids_tester(:st_coveredby, 'POLYGON((-6 -6, -6 6, 6 6, 6 -6, -6 -6))', [1, 3])
29
29
  end
30
30
 
31
31
  def test_crosses
32
- ids_tester(:st_crosses, 'LINESTRING(-6 -6, 4 4)', [ 3 ])
32
+ ids_tester(:st_crosses, 'LINESTRING(-6 -6, 4 4)', [3])
33
33
  end
34
34
 
35
35
  def test_disjoint
36
- ids_tester(:st_disjoint, 'POINT(100 100)', [ 1, 2, 3 ])
36
+ ids_tester(:st_disjoint, 'POINT(100 100)', [1, 2, 3])
37
37
  end
38
38
 
39
39
  def test_equal
40
- ids_tester(:st_equals, 'POLYGON((-5 -5, -5 5, 5 5, 5 -5, -5 -5))', [ 3 ])
40
+ ids_tester(:st_equals, 'POLYGON((-5 -5, -5 5, 5 5, 5 -5, -5 -5))', [3])
41
41
  end
42
42
 
43
43
  def test_intersects
44
- ids_tester(:st_intersects, 'LINESTRING(-5 -5, 10 10)', [ 1, 2, 3 ])
44
+ ids_tester(:st_intersects, 'LINESTRING(-5 -5, 10 10)', [1, 2, 3])
45
45
  end
46
46
 
47
47
  def test_orderingequals
48
- ids_tester(:st_orderingequals, 'POLYGON((-5 -5, -5 5, 5 5, 5 -5, -5 -5))', [ 3 ])
48
+ ids_tester(:st_orderingequals, 'POLYGON((-5 -5, -5 5, 5 5, 5 -5, -5 -5))', [3])
49
49
  end
50
50
 
51
51
  def test_overlaps
52
- ids_tester(:st_overlaps, 'POLYGON((-6 -6, -5 0, 0 0, 0 -5, -6 -6))', [ 3 ])
52
+ ids_tester(:st_overlaps, 'POLYGON((-6 -6, -5 0, 0 0, 0 -5, -6 -6))', [3])
53
53
  end
54
54
 
55
55
  def test_touches
56
- ids_tester(:st_touches, 'POLYGON((-5 -5, -5 -10, -10 -10, -10 -5, -5 -5))', [ 3 ])
56
+ ids_tester(:st_touches, 'POLYGON((-5 -5, -5 -10, -10 -10, -10 -5, -5 -5))', [3])
57
57
  end
58
58
 
59
59
  def test_within
60
- ids_tester(:st_within, 'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))', [ 1, 2 ])
60
+ ids_tester(:st_within, 'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))', [1, 2])
61
61
  end
62
62
 
63
63
  def test_dwithin
64
- ids_tester(:st_dwithin, [ 'POINT(5 5)', 10 ], [ 1, 2, 3 ])
64
+ ids_tester(:st_dwithin, ['POINT(5 5)', 10], [1, 2, 3])
65
65
  end
66
66
 
67
67
  def test_dfullywithin
68
- ids_tester(:st_dfullywithin, [ 'POINT(5 5)', 10 ], [ 1, 2 ])
68
+ ids_tester(:st_dfullywithin, ['POINT(5 5)', 10], [1, 2])
69
69
  end
70
70
 
71
71
  def test_geometry_type
72
- ids_tester(:st_geometry_type, 'ST_Point', [ 1, 2 ])
73
- ids_tester(:st_geometry_type, [ 'ST_Point', 'ST_Polygon' ], [ 1, 2, 3 ])
74
- ids_tester(:st_geometry_type, [ 'ST_MultiLineString' ], [])
72
+ ids_tester(:st_geometry_type, 'ST_Point', [1, 2])
73
+ ids_tester(:st_geometry_type, %w{ ST_Point ST_Polygon }, [1, 2, 3])
74
+ ids_tester(:st_geometry_type, ['ST_MultiLineString'], [])
75
75
  end
76
76
 
77
77
  def test_allow_null
78
- begin
79
- foo = Foo.create(:name => 'four')
80
- ids_tester(:st_contains, [ 'POINT(3 3)', { :allow_null => true } ], [ 3, foo.id ])
81
- ensure
82
- Foo.find_by_name('four').destroy
83
- end
78
+ foo = Foo.create(name: 'four')
79
+ ids_tester(:st_contains, ['POINT(3 3)', { allow_null: true }], [3, foo.id])
80
+ ensure
81
+ Foo.find_by_name('four').destroy
84
82
  end
85
83
 
86
84
  def test_nil_relationship
87
- assert_equal([ 1, 2, 3 ], Foo.st_within(nil).to_a.collect(&:id).sort)
85
+ assert_equal([1, 2, 3], Foo.st_within(nil).to_a.collect(&:id).sort)
88
86
  end
89
87
 
90
88
  def test_with_column
91
- assert_equal([1, 2, 3], Foo.st_disjoint('POINT(100 100)', :column => :the_other_geom).to_a.collect(&:id).sort)
89
+ assert_equal([1, 2, 3], Foo.st_disjoint('POINT(100 100)', column: :the_other_geom).to_a.collect(&:id).sort)
92
90
  end
93
91
 
94
92
  def test_with_srid_switching
@@ -101,8 +99,8 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
101
99
  end
102
100
 
103
101
  def test_with_srid_transform
104
- assert_equal([1, 2, 3], Foo.st_disjoint('SRID=4269; POINT(100 100)', :column => :the_other_geom).to_a.collect(&:id).sort)
105
- assert_equal([3], Foo.st_contains('SRID=4269; POINT(7 7)', :column => :the_other_geom).to_a.collect(&:id).sort)
102
+ assert_equal([1, 2, 3], Foo.st_disjoint('SRID=4269; POINT(100 100)', column: :the_other_geom).to_a.collect(&:id).sort)
103
+ assert_equal([3], Foo.st_contains('SRID=4269; POINT(7 7)', column: :the_other_geom).to_a.collect(&:id).sort)
106
104
  end
107
105
 
108
106
  def test_order_by_st_distance
@@ -110,7 +108,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
110
108
  end
111
109
 
112
110
  def test_order_by_st_distance_desc
113
- assert_equal([2, 1, 3], Foo.order_by_st_distance('POINT(1 1)', :desc => true).to_a.collect(&:id))
111
+ assert_equal([2, 1, 3], Foo.order_by_st_distance('POINT(1 1)', desc: true).to_a.collect(&:id))
114
112
  end
115
113
 
116
114
  def test_order_by_st_distance_sphere
@@ -118,7 +116,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
118
116
  end
119
117
 
120
118
  def test_order_by_st_distance_sphere_desc
121
- assert_equal([2, 1, 3], Foo.order_by_st_distance_sphere('POINT(1 1)', :desc => true).to_a.collect(&:id))
119
+ assert_equal([2, 1, 3], Foo.order_by_st_distance_sphere('POINT(1 1)', desc: true).to_a.collect(&:id))
122
120
  end
123
121
 
124
122
  def test_order_by_st_max_distance
@@ -126,7 +124,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
126
124
  end
127
125
 
128
126
  def test_order_by_st_max_distance_desc
129
- assert_equal([2, 3, 1], Foo.order_by_st_maxdistance('POINT(1 1)', :desc => true).to_a.collect(&:id))
127
+ assert_equal([2, 3, 1], Foo.order_by_st_maxdistance('POINT(1 1)', desc: true).to_a.collect(&:id))
130
128
  end
131
129
 
132
130
  def test_order_by_st_area
@@ -134,7 +132,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
134
132
  end
135
133
 
136
134
  def test_order_by_st_area_desc
137
- assert_equal([3, 1, 2], Foo.order_by_st_area(:desc => true).to_a.collect(&:id))
135
+ assert_equal([3, 1, 2], Foo.order_by_st_area(desc: true).to_a.collect(&:id))
138
136
  end
139
137
 
140
138
  def test_order_by_st_ndims
@@ -142,7 +140,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
142
140
  end
143
141
 
144
142
  def test_order_by_st_ndims_desc
145
- assert_equal([1, 2, 3], Foo.order_by_st_ndims(:desc => true).to_a.collect(&:id))
143
+ assert_equal([1, 2, 3], Foo.order_by_st_ndims(desc: true).to_a.collect(&:id))
146
144
  end
147
145
 
148
146
  def test_order_by_st_npoints
@@ -150,7 +148,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
150
148
  end
151
149
 
152
150
  def test_order_by_st_npoints_desc
153
- assert_equal([3, 1, 2], Foo.order_by_st_npoints(:desc => true).to_a.collect(&:id))
151
+ assert_equal([3, 1, 2], Foo.order_by_st_npoints(desc: true).to_a.collect(&:id))
154
152
  end
155
153
 
156
154
  def test_order_by_st_nrings
@@ -158,7 +156,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
158
156
  end
159
157
 
160
158
  def test_order_by_st_nrings_desc
161
- assert_equal([3, 1, 2], Foo.order_by_st_nrings(:desc => true).to_a.collect(&:id))
159
+ assert_equal([3, 1, 2], Foo.order_by_st_nrings(desc: true).to_a.collect(&:id))
162
160
  end
163
161
 
164
162
  def test_order_by_st_numgeometries
@@ -166,7 +164,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
166
164
  end
167
165
 
168
166
  def test_order_by_st_numgeometries_desc
169
- assert_equal([1, 2, 3], Foo.order_by_st_numgeometries(:desc => true).to_a.collect(&:id))
167
+ assert_equal([1, 2, 3], Foo.order_by_st_numgeometries(desc: true).to_a.collect(&:id))
170
168
  end
171
169
 
172
170
  def test_order_by_st_numinteriorring
@@ -174,7 +172,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
174
172
  end
175
173
 
176
174
  def test_order_by_st_numinteriorring_desc
177
- assert_equal([1, 2, 3], Foo.order_by_st_numinteriorring(:desc => true).to_a.collect(&:id))
175
+ assert_equal([1, 2, 3], Foo.order_by_st_numinteriorring(desc: true).to_a.collect(&:id))
178
176
  end
179
177
 
180
178
  def test_order_by_st_numinteriorrings
@@ -182,7 +180,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
182
180
  end
183
181
 
184
182
  def test_order_by_st_numinteriorrings_desc
185
- assert_equal([1, 2, 3], Foo.order_by_st_numinteriorrings(:desc => true).to_a.collect(&:id))
183
+ assert_equal([1, 2, 3], Foo.order_by_st_numinteriorrings(desc: true).to_a.collect(&:id))
186
184
  end
187
185
 
188
186
  def test_order_by_st_numpoints
@@ -190,7 +188,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
190
188
  end
191
189
 
192
190
  def test_order_by_st_numpoints_desc
193
- assert_equal([1, 2, 3], Foo.order_by_st_numpoints(:desc => true).to_a.collect(&:id))
191
+ assert_equal([1, 2, 3], Foo.order_by_st_numpoints(desc: true).to_a.collect(&:id))
194
192
  end
195
193
 
196
194
  def test_order_by_st_length3d
@@ -198,7 +196,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
198
196
  end
199
197
 
200
198
  def test_order_by_st_length3d_desc
201
- assert_equal([1, 2, 3], Foo.order_by_st_length3d(:desc => true).to_a.collect(&:id))
199
+ assert_equal([1, 2, 3], Foo.order_by_st_length3d(desc: true).to_a.collect(&:id))
202
200
  end
203
201
 
204
202
  def test_order_by_st_length
@@ -206,7 +204,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
206
204
  end
207
205
 
208
206
  def test_order_by_st_length_desc
209
- assert_equal([1, 2, 3], Foo.order_by_st_length(:desc => true).to_a.collect(&:id))
207
+ assert_equal([1, 2, 3], Foo.order_by_st_length(desc: true).to_a.collect(&:id))
210
208
  end
211
209
 
212
210
  def test_order_by_st_length2d
@@ -214,7 +212,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
214
212
  end
215
213
 
216
214
  def test_order_by_st_length2d_desc
217
- assert_equal([1, 2, 3], Foo.order_by_st_length2d(:desc => true).to_a.collect(&:id))
215
+ assert_equal([1, 2, 3], Foo.order_by_st_length2d(desc: true).to_a.collect(&:id))
218
216
  end
219
217
 
220
218
  def test_order_by_st_length3d_spheroid
@@ -228,7 +226,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
228
226
  [1, 2, 3]
229
227
  end
230
228
 
231
- assert_equal(expected, Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).to_a.collect(&:id))
229
+ assert_equal(expected, Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', desc: true).to_a.collect(&:id))
232
230
  end
233
231
 
234
232
  def test_order_by_st_length2d_spheroid
@@ -236,7 +234,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
236
234
  end
237
235
 
238
236
  def test_order_by_st_length2d_spheroid_desc
239
- assert_equal([3, 1, 2], Foo.order_by_st_length2d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).to_a.collect(&:id))
237
+ assert_equal([3, 1, 2], Foo.order_by_st_length2d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', desc: true).to_a.collect(&:id))
240
238
  end
241
239
 
242
240
  def test_order_by_st_length_spheroid
@@ -250,7 +248,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
250
248
  [1, 2, 3]
251
249
  end
252
250
 
253
- assert_equal(expected, Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).to_a.collect(&:id))
251
+ assert_equal(expected, Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', desc: true).to_a.collect(&:id))
254
252
  end
255
253
 
256
254
  def test_order_by_st_perimeter
@@ -258,7 +256,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
258
256
  end
259
257
 
260
258
  def test_order_by_st_perimeter_desc
261
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter(:desc => true).to_a.collect(&:id))
259
+ assert_equal([3, 1, 2], Foo.order_by_st_perimeter(desc: true).to_a.collect(&:id))
262
260
  end
263
261
 
264
262
  def test_order_by_st_perimeter2d
@@ -266,7 +264,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
266
264
  end
267
265
 
268
266
  def test_order_by_st_perimeter2d_desc
269
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter2d(:desc => true).to_a.collect(&:id))
267
+ assert_equal([3, 1, 2], Foo.order_by_st_perimeter2d(desc: true).to_a.collect(&:id))
270
268
  end
271
269
 
272
270
  def test_order_by_st_perimeter3d
@@ -274,7 +272,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
274
272
  end
275
273
 
276
274
  def test_order_by_st_perimeter3d_desc
277
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter3d(:desc => true).to_a.collect(&:id))
275
+ assert_equal([3, 1, 2], Foo.order_by_st_perimeter3d(desc: true).to_a.collect(&:id))
278
276
  end
279
277
 
280
278
  def test_order_by_st_hausdorffdistance
@@ -282,7 +280,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
282
280
  end
283
281
 
284
282
  def test_order_by_st_hausdorffdistance_desc
285
- assert_equal([2, 3, 1], Foo.order_by_st_hausdorffdistance('POINT(1 1)', :desc => true).to_a.collect(&:id))
283
+ assert_equal([2, 3, 1], Foo.order_by_st_hausdorffdistance('POINT(1 1)', desc: true).to_a.collect(&:id))
286
284
  end
287
285
 
288
286
  def test_order_by_st_hausdorffdistance_with_densify_frac
@@ -294,7 +292,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
294
292
  end
295
293
 
296
294
  def test_order_by_st_distance_spheroid_desc
297
- assert_equal([1, 3, 2], Foo.order_by_st_distance_spheroid('POINT(10 10)', 'SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).to_a.collect(&:id))
295
+ assert_equal([1, 3, 2], Foo.order_by_st_distance_spheroid('POINT(10 10)', 'SPHEROID["WGS 84", 6378137, 298.257223563]', desc: true).to_a.collect(&:id))
298
296
  end
299
297
 
300
298
  def test_order_by_st_area_with_desc_symbol
@@ -304,13 +302,25 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
304
302
  def test_3dintersects
305
303
  skip('ST_3dintersects is unavailable') unless Foo3d.respond_to?(:st_3dintersects)
306
304
 
307
- ids_tester(:st_3dintersects, 'LINESTRING(-5 -5 -5, 10 10 10)', [ 1, 3 ], Foo3d)
305
+ expected = if ActiveRecordSpatial::POSTGIS[:lib] >= '2.2'
306
+ [1, 2, 3]
307
+ else
308
+ [1, 3]
309
+ end
310
+
311
+ ids_tester(:st_3dintersects, 'LINESTRING(-5 -5 -5, 10 10 10)', expected, Foo3d)
308
312
  end
309
313
 
310
314
  def test_3ddistance
311
315
  skip('ST_3ddistance is unavailable') unless Foo3d.respond_to?(:order_by_st_3ddistance)
312
316
 
313
- assert_equal([3, 2, 1], Foo3d.order_by_st_3ddistance('POINT(10 10)').to_a.collect(&:id))
317
+ expected = if ActiveRecordSpatial::POSTGIS[:lib] >= '2.2'
318
+ [2, 3, 1]
319
+ else
320
+ [3, 2, 1]
321
+ end
322
+
323
+ assert_equal(expected, Foo3d.order_by_st_3ddistance('POINT(10 10)').to_a.collect(&:id))
314
324
  end
315
325
 
316
326
  def test_3dmaxdistance
@@ -322,13 +332,13 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
322
332
  def test_3ddwithin
323
333
  skip('ST_3ddwithin is unavailable') unless Foo3d.respond_to?(:st_3ddwithin)
324
334
 
325
- ids_tester(:st_3ddwithin, [ 'LINESTRING(-5 -5 -5, 10 10 10)', 10 ], [ 1, 2, 3 ], Foo3d)
335
+ ids_tester(:st_3ddwithin, ['LINESTRING(-5 -5 -5, 10 10 10)', 10], [1, 2, 3], Foo3d)
326
336
  end
327
337
 
328
338
  def test_3ddfullywithin
329
339
  skip('ST_3ddfullywithin is unavilable') unless Foo3d.respond_to?(:st_3ddfullywithin)
330
340
 
331
- ids_tester(:st_3ddfullywithin, [ 'LINESTRING(-10 -10 -10, 10 10 10)', 100 ], [ 1, 2, 3 ], Foo3d)
341
+ ids_tester(:st_3ddfullywithin, ['LINESTRING(-10 -10 -10, 10 10 10)', 100], [1, 2, 3], Foo3d)
332
342
  end
333
343
 
334
344
  def test_order_by_with_column_wrapper
@@ -337,9 +347,9 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
337
347
  assert_sql(/ST_envelope\("foos"."the_geom"\)/) do
338
348
  values = Foo.
339
349
  order_by_st_perimeter(
340
- :desc => true,
341
- :column => {
342
- :wrapper => :envelope
350
+ desc: true,
351
+ column: {
352
+ wrapper: :envelope
343
353
  }
344
354
  ).to_a.collect(&:id)
345
355
  end
@@ -353,10 +363,10 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
353
363
  assert_sql(/ST_geometryn\("foos"."the_geom", 1\)/) do
354
364
  values = Foo.
355
365
  order_by_st_perimeter(
356
- :desc => true,
357
- :column => {
358
- :wrapper => {
359
- :geometryn => 1
366
+ desc: true,
367
+ column: {
368
+ wrapper: {
369
+ geometryn: 1
360
370
  }
361
371
  }
362
372
  ).to_a.collect(&:id)
@@ -371,10 +381,10 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
371
381
  assert_sql(/ST_snap\("foos"."the_geom", 'POINT \(0 0\)', 1.0\)/) do
372
382
  values = Foo.
373
383
  order_by_st_perimeter(
374
- :desc => true,
375
- :column => {
376
- :wrapper => {
377
- :snap => [
384
+ desc: true,
385
+ column: {
386
+ wrapper: {
387
+ snap: [
378
388
  'POINT (0 0)',
379
389
  1.0
380
390
  ]
@@ -393,8 +403,8 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
393
403
  values = Foo.
394
404
  st_within(
395
405
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
396
- :column => {
397
- :wrapper => :centroid
406
+ column: {
407
+ wrapper: :centroid
398
408
  }
399
409
  ).to_a.collect(&:id)
400
410
  end
@@ -409,9 +419,9 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
409
419
  values = Foo.
410
420
  st_within(
411
421
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
412
- :column => {
413
- :wrapper => {
414
- :geometryn => 1
422
+ column: {
423
+ wrapper: {
424
+ geometryn: 1
415
425
  }
416
426
  }
417
427
  ).to_a.collect(&:id)
@@ -420,16 +430,16 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
420
430
  assert_equal([1, 2], values)
421
431
  end
422
432
 
423
- def test_relationship_with_column_wrapper_and_options
433
+ def test_relationship_with_column_wrapper_and_options
424
434
  values = nil
425
435
 
426
436
  assert_sql(/ST_snap\("foos"."the_geom", 'POINT \(0 0\)', 1.0\)/) do
427
437
  values = Foo.
428
438
  st_within(
429
439
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
430
- :column => {
431
- :wrapper => {
432
- :snap => [
440
+ column: {
441
+ wrapper: {
442
+ snap: [
433
443
  'POINT (0 0)',
434
444
  1.0
435
445
  ]
@@ -441,4 +451,3 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
441
451
  assert_equal([1, 2], values)
442
452
  end
443
453
  end
444
-