Skip to content

Commit 845f096

Browse files
sanakdkastl
authored andcommitted
Fix projects index/show api to return json object (for json format) and string (for xml format)
1 parent 348737c commit 845f096

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

app/views/projects/index.api.rsb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
1111

1212
if @include_geometry
1313
if project.geom
14-
api.geojson project.geojson.to_json
14+
api.geojson (params[:format] == "json") ? project.geojson : project.geojson.to_json
1515
else
16-
api.geojson ""
16+
api.geojson nil
1717
end
1818
end
1919

app/views/projects/show.api.rsb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ api.project do
99
api.is_public @project.is_public?
1010

1111
if @project.geom
12-
api.geojson @project.geojson.to_json
12+
api.geojson (params[:format] == "json") ? @project.geojson : @project.geojson.to_json
1313
else
14-
api.geojson ""
14+
api.geojson nil
1515
end
1616

1717
render_api_custom_values @project.visible_custom_field_values, api

test/integration/projects_api_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ProjectsApiTest < Redmine::IntegrationTest
8282
get '/projects.json?include=geometry'
8383
assert_response :success
8484
assert json = JSON.parse(@response.body)
85-
hsh = JSON.parse json['projects'].detect{|p|p['id'] == @project.id}['geojson']
85+
hsh = json['projects'].detect{|p|p['id'] == @project.id}['geojson']
8686
assert_equal geo['geometry'], hsh['geometry']
8787
end
8888

0 commit comments

Comments
 (0)