@@ -167,11 +167,13 @@ class ProjectsApiTest < Redmine::IntegrationTest
167
167
test 'GET /projects.xml with include=layers should return layers' do
168
168
ts = RedmineGtt ::Actions ::CreateTileSource . ( type : 'ol.source.OSM' , name : 'default' , default : true ) . tile_source
169
169
@project . gtt_tile_sources = [ ts ]
170
+ @subproject1 . gtt_tile_sources = [ ts ]
170
171
get '/projects.xml?include=layers'
171
172
assert_response :success
172
173
xml = xml_data
173
174
assert projects = xml . xpath ( '/projects/project' )
174
175
assert layer = projects . xpath ( 'layers/layer' ) . first
176
+ assert layer . present?
175
177
assert_equal 'ol.source.OSM' , layer [ 'type' ]
176
178
end
177
179
@@ -183,12 +185,69 @@ class ProjectsApiTest < Redmine::IntegrationTest
183
185
xml = xml_data
184
186
assert project = xml . xpath ( '/project' )
185
187
assert layer = project . xpath ( 'layers/layer' ) . first
188
+ assert layer . present?
189
+ assert_equal 'ol.source.OSM' , layer [ 'type' ]
190
+ end
191
+
192
+ test 'GET /projects.xml with include=geometry,layers should return both geojson and layers' do
193
+ ts = RedmineGtt ::Actions ::CreateTileSource . ( type : 'ol.source.OSM' , name : 'default' , default : true ) . tile_source
194
+ @project . gtt_tile_sources = [ ts ]
195
+ @subproject1 . gtt_tile_sources = [ ts ]
196
+ geo = {
197
+ 'type' => 'Feature' ,
198
+ 'geometry' => {
199
+ 'type' => 'Polygon' ,
200
+ 'coordinates' => [
201
+ [ [ 123.269691 , 9.305099 ] , [ 123.279691 , 9.305099 ] , [ 123.279691 , 9.405099 ] , [ 123.269691 , 9.405099 ] , [ 123.269691 , 9.305099 ] ]
202
+ ]
203
+ }
204
+ }
205
+ geojson = geo . to_json
206
+
207
+ @project . update_attribute :geojson , geojson
208
+ @subproject1 . update_attribute :geojson , geojson
209
+
210
+ get '/projects.xml?include=geometry,layers'
211
+ assert_response :success
212
+ xml = xml_data
213
+ assert projects = xml . xpath ( '/projects/project' )
214
+ assert json = projects . xpath ( 'geojson' ) . first . text
215
+ assert json . present?
216
+ assert_equal geo [ 'geometry' ] , JSON . parse ( json ) [ 'geometry' ] , json
217
+ assert layer = projects . xpath ( 'layers/layer' ) . first
218
+ assert layer . present?
219
+ assert_equal 'ol.source.OSM' , layer [ 'type' ]
220
+ end
221
+
222
+ test 'GET /projects/1.xml with include=geometry,layers should return both geojson and layers' do
223
+ ts = RedmineGtt ::Actions ::CreateTileSource . ( type : 'ol.source.OSM' , name : 'default' , default : true ) . tile_source
224
+ @project . gtt_tile_sources = [ ts ]
225
+ geo = {
226
+ 'type' => 'Feature' ,
227
+ 'geometry' => {
228
+ 'type' => 'Polygon' ,
229
+ 'coordinates' => [
230
+ [ [ 123.269691 , 9.305099 ] , [ 123.279691 , 9.305099 ] , [ 123.279691 , 9.405099 ] , [ 123.269691 , 9.405099 ] , [ 123.269691 , 9.305099 ] ]
231
+ ]
232
+ }
233
+ }
234
+ geojson = geo . to_json
235
+
236
+ @project . update_attribute :geojson , geojson
237
+
238
+ get '/projects/1.xml?include=geometry,layers'
239
+ assert_response :success
240
+ xml = xml_data
241
+ assert project = xml . xpath ( '/project' )
242
+ assert json = project . xpath ( 'geojson' ) . first . text
243
+ assert json . present?
244
+ assert_equal geo [ 'geometry' ] , JSON . parse ( json ) [ 'geometry' ] , json
245
+ assert layer = project . xpath ( 'layers/layer' ) . first
246
+ assert layer . present?
186
247
assert_equal 'ol.source.OSM' , layer [ 'type' ]
187
248
end
188
249
189
250
def xml_data
190
251
Nokogiri ::XML ( @response . body )
191
252
end
192
253
end
193
-
194
-
0 commit comments