summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-14 08:13:55 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-14 08:13:55 +0000
commit18f693f9f7c1ff0a32ddda9b6ea43a4bb1fe28e1 (patch)
tree7b5be61fb040bb64bdaff1726a746fe82e149810 /app
parent6bf60e8c206b3c75d18c824cb8b98b10a6d6a69c (diff)
downloadredmine-18f693f9f7c1ff0a32ddda9b6ea43a4bb1fe28e1.tar.gz
redmine-18f693f9f7c1ff0a32ddda9b6ea43a4bb1fe28e1.zip
Fixed that 200 API responses have a body containing one space (#11388).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9975 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/groups_controller.rb8
-rw-r--r--app/controllers/issue_categories_controller.rb4
-rw-r--r--app/controllers/issue_relations_controller.rb2
-rw-r--r--app/controllers/issues_controller.rb4
-rw-r--r--app/controllers/members_controller.rb4
-rw-r--r--app/controllers/projects_controller.rb4
-rw-r--r--app/controllers/timelog_controller.rb4
-rw-r--r--app/controllers/users_controller.rb4
-rw-r--r--app/controllers/versions_controller.rb4
10 files changed, 25 insertions, 19 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 645e8389b..98a52a834 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -520,6 +520,12 @@ class ApplicationController < ActionController::Base
render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
end
+ # Renders a 200 response for successfull updates or deletions via the API
+ def render_api_ok
+ # head :ok would return a response body with one space
+ render :text => '', :status => :ok, :layout => nil
+ end
+
# Renders API response on validation failure
def render_validation_errors(objects)
if objects.is_a?(Array)
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 244fa57b2..e4613b5e3 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -72,7 +72,7 @@ class GroupsController < ApplicationController
if @group.save
flash[:notice] = l(:notice_successful_update)
format.html { redirect_to(groups_path) }
- format.api { head :ok }
+ format.api { render_api_ok }
else
format.html { render :action => "edit" }
format.api { render_validation_errors(@group) }
@@ -85,7 +85,7 @@ class GroupsController < ApplicationController
respond_to do |format|
format.html { redirect_to(groups_url) }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
@@ -100,7 +100,7 @@ class GroupsController < ApplicationController
users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
}
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
@@ -109,7 +109,7 @@ class GroupsController < ApplicationController
respond_to do |format|
format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb
index 36a22b324..ecb4bc906 100644
--- a/app/controllers/issue_categories_controller.rb
+++ b/app/controllers/issue_categories_controller.rb
@@ -98,7 +98,7 @@ class IssueCategoriesController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|
@@ -118,7 +118,7 @@ class IssueCategoriesController < ApplicationController
@category.destroy(reassign_to)
respond_to do |format|
format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
- format.api { head :ok }
+ format.api { render_api_ok }
end
return
end
diff --git a/app/controllers/issue_relations_controller.rb b/app/controllers/issue_relations_controller.rb
index 7a529592c..0de78c366 100644
--- a/app/controllers/issue_relations_controller.rb
+++ b/app/controllers/issue_relations_controller.rb
@@ -76,7 +76,7 @@ class IssueRelationsController < ApplicationController
respond_to do |format|
format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to?
format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index d836c7f29..a6365531b 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -197,7 +197,7 @@ class IssuesController < ApplicationController
respond_to do |format|
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|
@@ -307,7 +307,7 @@ class IssuesController < ApplicationController
end
respond_to do |format|
format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index db065131a..49aaa2555 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -107,7 +107,7 @@ class MembersController < ApplicationController
}
format.api {
if saved
- head :ok
+ render_api_ok
else
render_validation_errors(@member)
end
@@ -128,7 +128,7 @@ class MembersController < ApplicationController
}
format.api {
if @member.destroyed?
- head :ok
+ render_api_ok
else
head :unprocessable_entity
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ffb932f34..628b1a12c 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -191,7 +191,7 @@ class ProjectsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'settings', :id => @project
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|
@@ -241,7 +241,7 @@ class ProjectsController < ApplicationController
@project_to_destroy.destroy
respond_to do |format|
format.html { redirect_to :controller => 'admin', :action => 'projects' }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
# hide project in layout
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb
index 30d6cc28a..7aae12b5c 100644
--- a/app/controllers/timelog_controller.rb
+++ b/app/controllers/timelog_controller.rb
@@ -171,7 +171,7 @@ class TimelogController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :action => 'index', :project_id => @time_entry.project
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|
@@ -223,7 +223,7 @@ class TimelogController < ApplicationController
}
format.api {
if destroyed
- head :ok
+ render_api_ok
else
render_validation_errors(@time_entries)
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index de334246f..4f112fd8c 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -156,7 +156,7 @@ class UsersController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to_referer_or edit_user_path(@user)
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
@auth_sources = AuthSource.find(:all)
@@ -175,7 +175,7 @@ class UsersController < ApplicationController
@user.destroy
respond_to do |format|
format.html { redirect_to_referer_or(users_url) }
- format.api { head :ok }
+ format.api { render_api_ok }
end
end
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb
index cd7e03339..dcee97c85 100644
--- a/app/controllers/versions_controller.rb
+++ b/app/controllers/versions_controller.rb
@@ -144,7 +144,7 @@ class VersionsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
}
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|
@@ -167,7 +167,7 @@ class VersionsController < ApplicationController
@version.destroy
respond_to do |format|
format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project }
- format.api { head :ok }
+ format.api { render_api_ok }
end
else
respond_to do |format|