activerecord-spatial 0.0.1 → 0.1.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.
@@ -8,7 +8,7 @@ class SpatialScopesGeographiesTests < ActiveRecordSpatialTestCase
8
8
  end
9
9
 
10
10
  def ids_tester(method, args, ids = [], options = {})
11
- geoms = FooGeography.send(method, *Array.wrap(args)).all(options)
11
+ geoms = FooGeography.send(method, *Array.wrap(args)).where(options[:conditions]).to_a
12
12
  assert_equal(ids.sort, geoms.collect(&:id).sort)
13
13
  end
14
14
 
@@ -42,39 +42,39 @@ class SpatialScopesGeographiesTests < ActiveRecordSpatialTestCase
42
42
  end
43
43
 
44
44
  def test_with_column
45
- assert_equal([3], FooGeography.st_covers('POINT(7 7)', :column => :the_other_geom).all.collect(&:id).sort)
45
+ assert_equal([3], FooGeography.st_covers('POINT(7 7)', :column => :the_other_geom).to_a.collect(&:id).sort)
46
46
  end
47
47
 
48
48
  def test_with_srid_switching
49
- assert_equal([3], FooGeography.st_covers('SRID=4326; POINT(3 3)').all.collect(&:id).sort)
49
+ assert_equal([3], FooGeography.st_covers('SRID=4326; POINT(3 3)').to_a.collect(&:id).sort)
50
50
  end
51
51
 
52
52
  def test_with_srid_default
53
- assert_equal([3], FooGeography.st_covers('SRID=default; POINT(3 3)').all.collect(&:id).sort)
53
+ assert_equal([3], FooGeography.st_covers('SRID=default; POINT(3 3)').to_a.collect(&:id).sort)
54
54
  end
55
55
 
56
56
  def test_with_srid_transform
57
- assert_equal([3], FooGeography.st_covers('SRID=4269; POINT(7 7)', :column => :the_other_geom).all.collect(&:id).sort)
57
+ assert_equal([3], FooGeography.st_covers('SRID=4269; POINT(7 7)', :column => :the_other_geom).to_a.collect(&:id).sort)
58
58
  end
59
59
 
60
60
  def test_order_by_st_distance
61
- assert_equal([3, 1, 2], FooGeography.order_by_st_distance('POINT(1 1)').all.collect(&:id))
61
+ assert_equal([3, 1, 2], FooGeography.order_by_st_distance('POINT(1 1)').to_a.collect(&:id))
62
62
  end
63
63
 
64
64
  def test_order_by_st_distance_desc
65
- assert_equal([2, 1, 3], FooGeography.order_by_st_distance('POINT(1 1)', :desc => true).all.collect(&:id))
65
+ assert_equal([2, 1, 3], FooGeography.order_by_st_distance('POINT(1 1)', :desc => true).to_a.collect(&:id))
66
66
  end
67
67
 
68
68
  def test_order_by_st_area
69
- assert_equal([1, 2, 3], FooGeography.order_by_st_area.order('id').all.collect(&:id))
69
+ assert_equal([1, 2, 3], apply_id_order_scope(FooGeography.order_by_st_area).to_a.collect(&:id))
70
70
  end
71
71
 
72
72
  def test_order_by_st_area_desc
73
- assert_equal([3, 1, 2], FooGeography.order_by_st_area(:desc => true).order('id').all.collect(&:id))
73
+ assert_equal([3, 1, 2], apply_id_order_scope(FooGeography.order_by_st_area(:desc => true)).to_a.collect(&:id))
74
74
  end
75
75
 
76
76
  def test_order_by_st_length
77
- assert_equal([1, 2, 3], FooGeography.order_by_st_length.order('id').all.collect(&:id))
77
+ assert_equal([1, 2, 3], apply_id_order_scope(FooGeography.order_by_st_length).to_a.collect(&:id))
78
78
  end
79
79
 
80
80
  def test_order_by_st_length_desc
@@ -84,23 +84,23 @@ class SpatialScopesGeographiesTests < ActiveRecordSpatialTestCase
84
84
  [3, 1, 2]
85
85
  end
86
86
 
87
- assert_equal(expected, FooGeography.order_by_st_length(:desc => true).order('id').where('true = true').all.collect(&:id))
87
+ assert_equal(expected, apply_id_order_scope(FooGeography.order_by_st_length(:desc => true)).where('true = true').to_a.collect(&:id))
88
88
  end
89
89
 
90
90
  def test_order_by_st_perimeter
91
91
  skip('requires PostGIS 2+') unless FooGeography.respond_to?(:order_by_st_perimeter)
92
92
 
93
- assert_equal([1, 2, 3], FooGeography.order_by_st_perimeter.order('id').all.collect(&:id))
93
+ assert_equal([1, 2, 3], apply_id_order_scope(FooGeography.order_by_st_perimeter).to_a.collect(&:id))
94
94
  end
95
95
 
96
96
  def test_order_by_st_perimeter_desc
97
97
  skip('requires PostGIS 2+') unless FooGeography.respond_to?(:order_by_st_perimeter)
98
98
 
99
- assert_equal([3, 1, 2], FooGeography.order_by_st_perimeter(:desc => true).order('id').all.collect(&:id))
99
+ assert_equal([3, 1, 2], apply_id_order_scope(FooGeography.order_by_st_perimeter(:desc => true)).to_a.collect(&:id))
100
100
  end
101
101
 
102
102
  def test_order_by_st_area_with_desc_symbol
103
- assert_equal([3, 1, 2], FooGeography.order_by_st_area(:desc).order('id').all.collect(&:id))
103
+ assert_equal([3, 1, 2], apply_id_order_scope(FooGeography.order_by_st_area(:desc)).to_a.collect(&:id))
104
104
  end
105
105
  end
106
106
 
@@ -8,7 +8,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
8
8
  end
9
9
 
10
10
  def ids_tester(method, args, ids = [], klass = Foo)
11
- geoms = klass.send(method, *Array.wrap(args)).all
11
+ geoms = klass.send(method, *Array.wrap(args))
12
12
  assert_equal(ids.sort, geoms.collect(&:id).sort)
13
13
  end
14
14
 
@@ -84,141 +84,141 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
84
84
  end
85
85
 
86
86
  def test_nil_relationship
87
- assert_equal([ 1, 2, 3 ], Foo.st_within(nil).all.collect(&:id).sort)
87
+ assert_equal([ 1, 2, 3 ], Foo.st_within(nil).to_a.collect(&:id).sort)
88
88
  end
89
89
 
90
90
  def test_with_column
91
- assert_equal([1, 2, 3], Foo.st_disjoint('POINT(100 100)', :column => :the_other_geom).all.collect(&:id).sort)
91
+ assert_equal([1, 2, 3], Foo.st_disjoint('POINT(100 100)', :column => :the_other_geom).to_a.collect(&:id).sort)
92
92
  end
93
93
 
94
94
  def test_with_srid_switching
95
- assert_equal([1, 2, 3], Foo.st_disjoint('SRID=4326; POINT(100 100)').all.collect(&:id).sort)
95
+ assert_equal([1, 2, 3], Foo.st_disjoint('SRID=4326; POINT(100 100)').to_a.collect(&:id).sort)
96
96
  end
97
97
 
98
98
  def test_with_srid_default
99
- assert_equal([1, 2, 3], Foo.st_disjoint('SRID=default; POINT(100 100)').all.collect(&:id).sort)
100
- assert_equal([3], Foo.st_contains('SRID=default; POINT(-3 -3)').all.collect(&:id).sort)
99
+ assert_equal([1, 2, 3], Foo.st_disjoint('SRID=default; POINT(100 100)').to_a.collect(&:id).sort)
100
+ assert_equal([3], Foo.st_contains('SRID=default; POINT(-3 -3)').to_a.collect(&:id).sort)
101
101
  end
102
102
 
103
103
  def test_with_srid_transform
104
- assert_equal([1, 2, 3], Foo.st_disjoint('SRID=4269; POINT(100 100)', :column => :the_other_geom).all.collect(&:id).sort)
105
- assert_equal([3], Foo.st_contains('SRID=4269; POINT(7 7)', :column => :the_other_geom).all.collect(&:id).sort)
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)
106
106
  end
107
107
 
108
108
  def test_order_by_st_distance
109
- assert_equal([3, 1, 2], Foo.order_by_st_distance('POINT(1 1)').all.collect(&:id))
109
+ assert_equal([3, 1, 2], Foo.order_by_st_distance('POINT(1 1)').to_a.collect(&:id))
110
110
  end
111
111
 
112
112
  def test_order_by_st_distance_desc
113
- assert_equal([2, 1, 3], Foo.order_by_st_distance('POINT(1 1)', :desc => true).all.collect(&:id))
113
+ assert_equal([2, 1, 3], Foo.order_by_st_distance('POINT(1 1)', :desc => true).to_a.collect(&:id))
114
114
  end
115
115
 
116
116
  def test_order_by_st_distance_sphere
117
- assert_equal([3, 1, 2], Foo.order_by_st_distance_sphere('POINT(1 1)').all.collect(&:id))
117
+ assert_equal([3, 1, 2], Foo.order_by_st_distance_sphere('POINT(1 1)').to_a.collect(&:id))
118
118
  end
119
119
 
120
120
  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).all.collect(&:id))
121
+ assert_equal([2, 1, 3], Foo.order_by_st_distance_sphere('POINT(1 1)', :desc => true).to_a.collect(&:id))
122
122
  end
123
123
 
124
124
  def test_order_by_st_max_distance
125
- assert_equal([1, 3, 2], Foo.order_by_st_maxdistance('POINT(1 1)').all.collect(&:id))
125
+ assert_equal([1, 3, 2], Foo.order_by_st_maxdistance('POINT(1 1)').to_a.collect(&:id))
126
126
  end
127
127
 
128
128
  def test_order_by_st_max_distance_desc
129
- assert_equal([2, 3, 1], Foo.order_by_st_maxdistance('POINT(1 1)', :desc => true).all.collect(&:id))
129
+ assert_equal([2, 3, 1], Foo.order_by_st_maxdistance('POINT(1 1)', :desc => true).to_a.collect(&:id))
130
130
  end
131
131
 
132
132
  def test_order_by_st_area
133
- assert_equal([1, 2, 3], Foo.order_by_st_area.order('id').all.collect(&:id))
133
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_area).to_a.collect(&:id))
134
134
  end
135
135
 
136
136
  def test_order_by_st_area_desc
137
- assert_equal([3, 1, 2], Foo.order_by_st_area(:desc => true).order('id').all.collect(&:id))
137
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_area(:desc => true)).to_a.collect(&:id))
138
138
  end
139
139
 
140
140
  def test_order_by_st_ndims
141
- assert_equal([1, 2, 3], Foo.order_by_st_ndims.order('id').all.collect(&:id))
141
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_ndims).to_a.collect(&:id))
142
142
  end
143
143
 
144
144
  def test_order_by_st_ndims_desc
145
- assert_equal([1, 2, 3], Foo.order_by_st_ndims(:desc => true).order('id').all.collect(&:id))
145
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_ndims(:desc => true)).to_a.collect(&:id))
146
146
  end
147
147
 
148
148
  def test_order_by_st_npoints
149
- assert_equal([1, 2, 3], Foo.order_by_st_npoints.order('id').all.collect(&:id))
149
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_npoints).to_a.collect(&:id))
150
150
  end
151
151
 
152
152
  def test_order_by_st_npoints_desc
153
- assert_equal([3, 1, 2], Foo.order_by_st_npoints(:desc => true).order('id').all.collect(&:id))
153
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_npoints(:desc => true)).to_a.collect(&:id))
154
154
  end
155
155
 
156
156
  def test_order_by_st_nrings
157
- assert_equal([1, 2, 3], Foo.order_by_st_nrings.order('id').all.collect(&:id))
157
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_nrings).to_a.collect(&:id))
158
158
  end
159
159
 
160
160
  def test_order_by_st_nrings_desc
161
- assert_equal([3, 1, 2], Foo.order_by_st_nrings(:desc => true).order('id').all.collect(&:id))
161
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_nrings(:desc => true)).to_a.collect(&:id))
162
162
  end
163
163
 
164
164
  def test_order_by_st_numgeometries
165
- assert_equal([1, 2, 3], Foo.order_by_st_numgeometries.order('id').all.collect(&:id))
165
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_numgeometries).to_a.collect(&:id))
166
166
  end
167
167
 
168
168
  def test_order_by_st_numgeometries_desc
169
- assert_equal([1, 2, 3], Foo.order_by_st_numgeometries(:desc => true).order('id').all.collect(&:id))
169
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_numgeometries(:desc => true)).to_a.collect(&:id))
170
170
  end
171
171
 
172
172
  def test_order_by_st_numinteriorring
173
- assert_equal([3, 1, 2], Foo.order_by_st_numinteriorring.order('id').all.collect(&:id))
173
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_numinteriorring).to_a.collect(&:id))
174
174
  end
175
175
 
176
176
  def test_order_by_st_numinteriorring_desc
177
- assert_equal([1, 2, 3], Foo.order_by_st_numinteriorring(:desc => true).order('id').all.collect(&:id))
177
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_numinteriorring(:desc => true)).to_a.collect(&:id))
178
178
  end
179
179
 
180
180
  def test_order_by_st_numinteriorrings
181
- assert_equal([3, 1, 2], Foo.order_by_st_numinteriorrings.order('id').all.collect(&:id))
181
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_numinteriorrings).to_a.collect(&:id))
182
182
  end
183
183
 
184
184
  def test_order_by_st_numinteriorrings_desc
185
- assert_equal([1, 2, 3], Foo.order_by_st_numinteriorrings(:desc => true).order('id').all.collect(&:id))
185
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_numinteriorrings(:desc => true)).to_a.collect(&:id))
186
186
  end
187
187
 
188
188
  def test_order_by_st_numpoints
189
- assert_equal([1, 2, 3], Foo.order_by_st_numpoints.order('id').all.collect(&:id))
189
+ assert_equal([1, 2, 3], Foo.order_by_st_numpoints.order('id').to_a.collect(&:id))
190
190
  end
191
191
 
192
192
  def test_order_by_st_numpoints_desc
193
- assert_equal([1, 2, 3], Foo.order_by_st_numpoints(:desc => true).order('id').all.collect(&:id))
193
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_numpoints(:desc => true)).to_a.collect(&:id))
194
194
  end
195
195
 
196
196
  def test_order_by_st_length3d
197
- assert_equal([1, 2, 3], Foo.order_by_st_length3d.order('id').all.collect(&:id))
197
+ assert_equal([1, 2, 3], Foo.order_by_st_length3d.order('id').to_a.collect(&:id))
198
198
  end
199
199
 
200
200
  def test_order_by_st_length3d_desc
201
- assert_equal([1, 2, 3], Foo.order_by_st_length3d(:desc => true).order('id').all.collect(&:id))
201
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length3d(:desc => true)).to_a.collect(&:id))
202
202
  end
203
203
 
204
204
  def test_order_by_st_length
205
- assert_equal([1, 2, 3], Foo.order_by_st_length.order('id').all.collect(&:id))
205
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length).to_a.collect(&:id))
206
206
  end
207
207
 
208
208
  def test_order_by_st_length_desc
209
- assert_equal([1, 2, 3], Foo.order_by_st_length(:desc => true).order('id').all.collect(&:id))
209
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length(:desc => true)).to_a.collect(&:id))
210
210
  end
211
211
 
212
212
  def test_order_by_st_length2d
213
- assert_equal([1, 2, 3], Foo.order_by_st_length2d.order('id').all.collect(&:id))
213
+ assert_equal([1, 2, 3], Foo.order_by_st_length2d.order('id').to_a.collect(&:id))
214
214
  end
215
215
 
216
216
  def test_order_by_st_length2d_desc
217
- assert_equal([1, 2, 3], Foo.order_by_st_length2d(:desc => true).order('id').all.collect(&:id))
217
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length2d(:desc => true)).to_a.collect(&:id))
218
218
  end
219
219
 
220
220
  def test_order_by_st_length3d_spheroid
221
- assert_equal([1, 2, 3], Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]').order('id').all.collect(&:id))
221
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]')).to_a.collect(&:id))
222
222
  end
223
223
 
224
224
  def test_order_by_st_length3d_spheroid_desc
@@ -228,19 +228,19 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
228
228
  [1, 2, 3]
229
229
  end
230
230
 
231
- assert_equal(expected, Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).order('id').all.collect(&:id))
231
+ assert_equal(expected, apply_id_order_scope(Foo.order_by_st_length3d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true)).to_a.collect(&:id))
232
232
  end
233
233
 
234
234
  def test_order_by_st_length2d_spheroid
235
- assert_equal([1, 2, 3], Foo.order_by_st_length2d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]').order('id').all.collect(&:id))
235
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length2d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]')).to_a.collect(&:id))
236
236
  end
237
237
 
238
238
  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).order('id').all.collect(&:id))
239
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_length2d_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true)).to_a.collect(&:id))
240
240
  end
241
241
 
242
242
  def test_order_by_st_length_spheroid
243
- assert_equal([1, 2, 3], Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]').order('id').all.collect(&:id))
243
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]')).to_a.collect(&:id))
244
244
  end
245
245
 
246
246
  def test_order_by_st_length_spheroid_desc
@@ -250,55 +250,55 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
250
250
  [1, 2, 3]
251
251
  end
252
252
 
253
- assert_equal(expected, Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true).order('id').all.collect(&:id))
253
+ assert_equal(expected, apply_id_order_scope(Foo.order_by_st_length_spheroid('SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true)).to_a.collect(&:id))
254
254
  end
255
255
 
256
256
  def test_order_by_st_perimeter
257
- assert_equal([1, 2, 3], Foo.order_by_st_perimeter.order('id').all.collect(&:id))
257
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_perimeter).to_a.collect(&:id))
258
258
  end
259
259
 
260
260
  def test_order_by_st_perimeter_desc
261
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter(:desc => true).order('id').all.collect(&:id))
261
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_perimeter(:desc => true)).to_a.collect(&:id))
262
262
  end
263
263
 
264
264
  def test_order_by_st_perimeter2d
265
- assert_equal([1, 2, 3], Foo.order_by_st_perimeter2d.order('id').all.collect(&:id))
265
+ assert_equal([1, 2, 3], apply_id_order_scope(Foo.order_by_st_perimeter2d).to_a.collect(&:id))
266
266
  end
267
267
 
268
268
  def test_order_by_st_perimeter2d_desc
269
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter2d(:desc => true).order('id').all.collect(&:id))
269
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_perimeter2d(:desc => true)).to_a.collect(&:id))
270
270
  end
271
271
 
272
272
  def test_order_by_st_perimeter3d
273
- assert_equal([1, 2, 3], Foo.order_by_st_perimeter3d.order('id').all.collect(&:id))
273
+ assert_equal([1, 2, 3], Foo.order_by_st_perimeter3d.order('id').to_a.collect(&:id))
274
274
  end
275
275
 
276
276
  def test_order_by_st_perimeter3d_desc
277
- assert_equal([3, 1, 2], Foo.order_by_st_perimeter3d(:desc => true).order('id').all.collect(&:id))
277
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_perimeter3d(:desc => true)).to_a.collect(&:id))
278
278
  end
279
279
 
280
280
  def test_order_by_st_hausdorffdistance
281
- assert_equal([1, 3, 2], Foo.order_by_st_hausdorffdistance('POINT(1 1)').all.collect(&:id))
281
+ assert_equal([1, 3, 2], Foo.order_by_st_hausdorffdistance('POINT(1 1)').to_a.collect(&:id))
282
282
  end
283
283
 
284
284
  def test_order_by_st_hausdorffdistance_desc
285
- assert_equal([2, 3, 1], Foo.order_by_st_hausdorffdistance('POINT(1 1)', :desc => true).all.collect(&:id))
285
+ assert_equal([2, 3, 1], Foo.order_by_st_hausdorffdistance('POINT(1 1)', :desc => true).to_a.collect(&:id))
286
286
  end
287
287
 
288
288
  def test_order_by_st_hausdorffdistance_with_densify_frac
289
- assert_equal([1, 3, 2], Foo.order_by_st_hausdorffdistance('POINT(1 1)', 0.314).all.collect(&:id))
289
+ assert_equal([1, 3, 2], Foo.order_by_st_hausdorffdistance('POINT(1 1)', 0.314).to_a.collect(&:id))
290
290
  end
291
291
 
292
292
  def test_order_by_st_distance_spheroid
293
- assert_equal([2, 3, 1], Foo.order_by_st_distance_spheroid('POINT(10 10)', 'SPHEROID["WGS 84", 6378137, 298.257223563]').order('id').all.collect(&:id))
293
+ assert_equal([2, 3, 1], apply_id_order_scope(Foo.order_by_st_distance_spheroid('POINT(10 10)', 'SPHEROID["WGS 84", 6378137, 298.257223563]')).to_a.collect(&:id))
294
294
  end
295
295
 
296
296
  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).order('id').all.collect(&:id))
297
+ assert_equal([1, 3, 2], apply_id_order_scope(Foo.order_by_st_distance_spheroid('POINT(10 10)', 'SPHEROID["WGS 84", 6378137, 298.257223563]', :desc => true)).to_a.collect(&:id))
298
298
  end
299
299
 
300
300
  def test_order_by_st_area_with_desc_symbol
301
- assert_equal([3, 1, 2], Foo.order_by_st_area(:desc).order('id').all.collect(&:id))
301
+ assert_equal([3, 1, 2], apply_id_order_scope(Foo.order_by_st_area(:desc)).to_a.collect(&:id))
302
302
  end
303
303
 
304
304
  def test_3dintersects
@@ -310,13 +310,13 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
310
310
  def test_3ddistance
311
311
  skip('ST_3ddistance is unavailable') unless Foo3d.respond_to?(:order_by_st_3ddistance)
312
312
 
313
- assert_equal([3, 2, 1], Foo3d.order_by_st_3ddistance('POINT(10 10)').order('id').all.collect(&:id))
313
+ assert_equal([3, 2, 1], apply_id_order_scope(Foo3d.order_by_st_3ddistance('POINT(10 10)')).to_a.collect(&:id))
314
314
  end
315
315
 
316
316
  def test_3dmaxdistance
317
317
  skip('ST_3dmaxdistance is unavailable') unless Foo3d.respond_to?(:order_by_st_3dmaxdistance)
318
318
 
319
- assert_equal([2, 1, 3], Foo3d.order_by_st_3dmaxdistance('POINT(10 10)').order('id').all.collect(&:id))
319
+ assert_equal([2, 1, 3], apply_id_order_scope(Foo3d.order_by_st_3dmaxdistance('POINT(10 10)')).to_a.collect(&:id))
320
320
  end
321
321
 
322
322
  def test_3ddwithin
@@ -335,13 +335,13 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
335
335
  values = nil
336
336
 
337
337
  assert_sql(/ST_envelope\("foos"."the_geom"\)/) do
338
- values = Foo.
338
+ values = apply_id_order_scope(Foo.
339
339
  order_by_st_perimeter(
340
340
  :desc => true,
341
341
  :column => {
342
342
  :wrapper => :envelope
343
343
  }
344
- ).order('id').all.collect(&:id)
344
+ )).to_a.collect(&:id)
345
345
  end
346
346
 
347
347
  assert_equal([3, 1, 2], values)
@@ -351,7 +351,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
351
351
  values = nil
352
352
 
353
353
  assert_sql(/ST_geometryn\("foos"."the_geom", 1\)/) do
354
- values = Foo.
354
+ values = apply_id_order_scope(Foo.
355
355
  order_by_st_perimeter(
356
356
  :desc => true,
357
357
  :column => {
@@ -359,7 +359,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
359
359
  :geometryn => 1
360
360
  }
361
361
  }
362
- ).order('id').all.collect(&:id)
362
+ )).to_a.collect(&:id)
363
363
  end
364
364
 
365
365
  assert_equal([3, 1, 2], values)
@@ -369,7 +369,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
369
369
  values = nil
370
370
 
371
371
  assert_sql(/ST_snap\("foos"."the_geom", 'POINT \(0 0\)', 1.0\)/) do
372
- values = Foo.
372
+ values = apply_id_order_scope(Foo.
373
373
  order_by_st_perimeter(
374
374
  :desc => true,
375
375
  :column => {
@@ -380,7 +380,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
380
380
  ]
381
381
  }
382
382
  }
383
- ).order('id').all.collect(&:id)
383
+ )).to_a.collect(&:id)
384
384
  end
385
385
 
386
386
  assert_equal([3, 1, 2], values)
@@ -390,13 +390,13 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
390
390
  values = nil
391
391
 
392
392
  assert_sql(/ST_centroid\("foos"."the_geom"\)/) do
393
- values = Foo.
393
+ values = apply_id_order_scope(Foo.
394
394
  st_within(
395
395
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
396
396
  :column => {
397
397
  :wrapper => :centroid
398
398
  }
399
- ).order('id').all.collect(&:id)
399
+ )).to_a.collect(&:id)
400
400
  end
401
401
 
402
402
  assert_equal([1, 2, 3], values)
@@ -406,7 +406,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
406
406
  values = nil
407
407
 
408
408
  assert_sql(/ST_geometryn\("foos"."the_geom", 1\)/) do
409
- values = Foo.
409
+ values = apply_id_order_scope(Foo.
410
410
  st_within(
411
411
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
412
412
  :column => {
@@ -414,7 +414,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
414
414
  :geometryn => 1
415
415
  }
416
416
  }
417
- ).order('id').all.collect(&:id)
417
+ )).to_a.collect(&:id)
418
418
  end
419
419
 
420
420
  assert_equal([1, 2], values)
@@ -424,7 +424,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
424
424
  values = nil
425
425
 
426
426
  assert_sql(/ST_snap\("foos"."the_geom", 'POINT \(0 0\)', 1.0\)/) do
427
- values = Foo.
427
+ values = apply_id_order_scope(Foo.
428
428
  st_within(
429
429
  'POLYGON((-5 -5, 5 10, 20 20, 10 5, -5 -5))',
430
430
  :column => {
@@ -435,7 +435,7 @@ class SpatialScopesTests < ActiveRecordSpatialTestCase
435
435
  ]
436
436
  }
437
437
  }
438
- ).order('id').all.collect(&:id)
438
+ )).to_a.collect(&:id)
439
439
  end
440
440
 
441
441
  assert_equal([1, 2], values)