File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,6 @@ api.project do
14
14
api.geojson ""
15
15
end
16
16
17
- if @project.gtt_tile_sources.present?
18
- api.gttLayer @project.gtt_tile_sources
19
- end
20
-
21
17
render_api_custom_values @project.visible_custom_field_values, api
22
18
render_api_includes(@project, api)
23
19
Original file line number Diff line number Diff line change @@ -8,11 +8,30 @@ module Patches
8
8
module ProjectsHelperPatch
9
9
10
10
def self . apply
11
+ ProjectsHelper . prepend self unless ProjectsHelper < self
11
12
ProjectsController . class_eval do
12
13
helper SettingsMenuItem
13
14
end
14
15
end
15
16
17
+ def render_api_includes ( project , api )
18
+ super
19
+ api . array :layers do
20
+ project . gtt_tile_sources . each do |gtt_tile_source |
21
+ api . layer (
22
+ :id => gtt_tile_source . id ,
23
+ :name => gtt_tile_source . name ,
24
+ :type => gtt_tile_source . type ,
25
+ :options => gtt_tile_source . options ,
26
+ :global => gtt_tile_source . global ,
27
+ :default => gtt_tile_source . default ,
28
+ :position => gtt_tile_source . position ,
29
+ :baselayer => gtt_tile_source . baselayer
30
+ )
31
+ end
32
+ end if include_in_api_response? ( 'layers' )
33
+ end
34
+
16
35
module SettingsMenuItem
17
36
def project_settings_tabs
18
37
super . tap do |tabs |
Original file line number Diff line number Diff line change @@ -164,6 +164,28 @@ class ProjectsApiTest < Redmine::IntegrationTest
164
164
assert_equal 1 , projects . xpath ( 'geojson' ) . size , projects . to_s
165
165
end
166
166
167
+ test 'GET /projects.xml with include=layers should return layers' do
168
+ ts = RedmineGtt ::Actions ::CreateTileSource . ( type : 'ol.source.OSM' , name : 'default' , default : true ) . tile_source
169
+ @project . gtt_tile_sources = [ ts ]
170
+ get '/projects.xml?include=layers'
171
+ assert_response :success
172
+ xml = xml_data
173
+ assert projects = xml . xpath ( '/projects/project' )
174
+ assert layer = projects . xpath ( 'layers/layer' ) . first
175
+ assert_equal 'ol.source.OSM' , layer [ 'type' ]
176
+ end
177
+
178
+ test 'GET /projects/1.xml with include=layers should return layers' do
179
+ ts = RedmineGtt ::Actions ::CreateTileSource . ( type : 'ol.source.OSM' , name : 'default' , default : true ) . tile_source
180
+ @project . gtt_tile_sources = [ ts ]
181
+ get '/projects/1.xml?include=layers'
182
+ assert_response :success
183
+ xml = xml_data
184
+ assert project = xml . xpath ( '/project' )
185
+ assert layer = project . xpath ( 'layers/layer' ) . first
186
+ assert_equal 'ol.source.OSM' , layer [ 'type' ]
187
+ end
188
+
167
189
def xml_data
168
190
Nokogiri ::XML ( @response . body )
169
191
end
You can’t perform that action at this time.
0 commit comments