@@ -520,6 +520,12 class ApplicationController < ActionController::Base | |||
|
520 | 520 | render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator." |
|
521 | 521 | end |
|
522 | 522 | |
|
523 | # Renders a 200 response for successfull updates or deletions via the API | |
|
524 | def render_api_ok | |
|
525 | # head :ok would return a response body with one space | |
|
526 | render :text => '', :status => :ok, :layout => nil | |
|
527 | end | |
|
528 | ||
|
523 | 529 | # Renders API response on validation failure |
|
524 | 530 | def render_validation_errors(objects) |
|
525 | 531 | if objects.is_a?(Array) |
@@ -72,7 +72,7 class GroupsController < ApplicationController | |||
|
72 | 72 | if @group.save |
|
73 | 73 | flash[:notice] = l(:notice_successful_update) |
|
74 | 74 | format.html { redirect_to(groups_path) } |
|
75 |
format.api { |
|
|
75 | format.api { render_api_ok } | |
|
76 | 76 | else |
|
77 | 77 | format.html { render :action => "edit" } |
|
78 | 78 | format.api { render_validation_errors(@group) } |
@@ -85,7 +85,7 class GroupsController < ApplicationController | |||
|
85 | 85 | |
|
86 | 86 | respond_to do |format| |
|
87 | 87 | format.html { redirect_to(groups_url) } |
|
88 |
format.api { |
|
|
88 | format.api { render_api_ok } | |
|
89 | 89 | end |
|
90 | 90 | end |
|
91 | 91 | |
@@ -100,7 +100,7 class GroupsController < ApplicationController | |||
|
100 | 100 | users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") } |
|
101 | 101 | } |
|
102 | 102 | } |
|
103 |
format.api { |
|
|
103 | format.api { render_api_ok } | |
|
104 | 104 | end |
|
105 | 105 | end |
|
106 | 106 | |
@@ -109,7 +109,7 class GroupsController < ApplicationController | |||
|
109 | 109 | respond_to do |format| |
|
110 | 110 | format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' } |
|
111 | 111 | format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} } |
|
112 |
format.api { |
|
|
112 | format.api { render_api_ok } | |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | 115 |
@@ -98,7 +98,7 class IssueCategoriesController < ApplicationController | |||
|
98 | 98 | flash[:notice] = l(:notice_successful_update) |
|
99 | 99 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project |
|
100 | 100 | } |
|
101 |
format.api { |
|
|
101 | format.api { render_api_ok } | |
|
102 | 102 | end |
|
103 | 103 | else |
|
104 | 104 | respond_to do |format| |
@@ -118,7 +118,7 class IssueCategoriesController < ApplicationController | |||
|
118 | 118 | @category.destroy(reassign_to) |
|
119 | 119 | respond_to do |format| |
|
120 | 120 | format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' } |
|
121 |
format.api { |
|
|
121 | format.api { render_api_ok } | |
|
122 | 122 | end |
|
123 | 123 | return |
|
124 | 124 | end |
@@ -76,7 +76,7 class IssueRelationsController < ApplicationController | |||
|
76 | 76 | respond_to do |format| |
|
77 | 77 | format.html { redirect_to issue_path } # TODO : does this really work since @issue is always nil? What is it useful to? |
|
78 | 78 | format.js { render(:update) {|page| page.remove "relation-#{@relation.id}"} } |
|
79 |
format.api { |
|
|
79 | format.api { render_api_ok } | |
|
80 | 80 | end |
|
81 | 81 | end |
|
82 | 82 |
@@ -197,7 +197,7 class IssuesController < ApplicationController | |||
|
197 | 197 | |
|
198 | 198 | respond_to do |format| |
|
199 | 199 | format.html { redirect_back_or_default({:action => 'show', :id => @issue}) } |
|
200 |
format.api { |
|
|
200 | format.api { render_api_ok } | |
|
201 | 201 | end |
|
202 | 202 | else |
|
203 | 203 | respond_to do |format| |
@@ -307,7 +307,7 class IssuesController < ApplicationController | |||
|
307 | 307 | end |
|
308 | 308 | respond_to do |format| |
|
309 | 309 | format.html { redirect_back_or_default(:action => 'index', :project_id => @project) } |
|
310 |
format.api { |
|
|
310 | format.api { render_api_ok } | |
|
311 | 311 | end |
|
312 | 312 | end |
|
313 | 313 |
@@ -107,7 +107,7 class MembersController < ApplicationController | |||
|
107 | 107 | } |
|
108 | 108 | format.api { |
|
109 | 109 | if saved |
|
110 |
|
|
|
110 | render_api_ok | |
|
111 | 111 | else |
|
112 | 112 | render_validation_errors(@member) |
|
113 | 113 | end |
@@ -128,7 +128,7 class MembersController < ApplicationController | |||
|
128 | 128 | } |
|
129 | 129 | format.api { |
|
130 | 130 | if @member.destroyed? |
|
131 |
|
|
|
131 | render_api_ok | |
|
132 | 132 | else |
|
133 | 133 | head :unprocessable_entity |
|
134 | 134 | end |
@@ -191,7 +191,7 class ProjectsController < ApplicationController | |||
|
191 | 191 | flash[:notice] = l(:notice_successful_update) |
|
192 | 192 | redirect_to :action => 'settings', :id => @project |
|
193 | 193 | } |
|
194 |
format.api { |
|
|
194 | format.api { render_api_ok } | |
|
195 | 195 | end |
|
196 | 196 | else |
|
197 | 197 | respond_to do |format| |
@@ -241,7 +241,7 class ProjectsController < ApplicationController | |||
|
241 | 241 | @project_to_destroy.destroy |
|
242 | 242 | respond_to do |format| |
|
243 | 243 | format.html { redirect_to :controller => 'admin', :action => 'projects' } |
|
244 |
format.api { |
|
|
244 | format.api { render_api_ok } | |
|
245 | 245 | end |
|
246 | 246 | end |
|
247 | 247 | # hide project in layout |
@@ -171,7 +171,7 class TimelogController < ApplicationController | |||
|
171 | 171 | flash[:notice] = l(:notice_successful_update) |
|
172 | 172 | redirect_back_or_default :action => 'index', :project_id => @time_entry.project |
|
173 | 173 | } |
|
174 |
format.api { |
|
|
174 | format.api { render_api_ok } | |
|
175 | 175 | end |
|
176 | 176 | else |
|
177 | 177 | respond_to do |format| |
@@ -223,7 +223,7 class TimelogController < ApplicationController | |||
|
223 | 223 | } |
|
224 | 224 | format.api { |
|
225 | 225 | if destroyed |
|
226 |
|
|
|
226 | render_api_ok | |
|
227 | 227 | else |
|
228 | 228 | render_validation_errors(@time_entries) |
|
229 | 229 | end |
@@ -156,7 +156,7 class UsersController < ApplicationController | |||
|
156 | 156 | flash[:notice] = l(:notice_successful_update) |
|
157 | 157 | redirect_to_referer_or edit_user_path(@user) |
|
158 | 158 | } |
|
159 |
format.api { |
|
|
159 | format.api { render_api_ok } | |
|
160 | 160 | end |
|
161 | 161 | else |
|
162 | 162 | @auth_sources = AuthSource.find(:all) |
@@ -175,7 +175,7 class UsersController < ApplicationController | |||
|
175 | 175 | @user.destroy |
|
176 | 176 | respond_to do |format| |
|
177 | 177 | format.html { redirect_to_referer_or(users_url) } |
|
178 |
format.api { |
|
|
178 | format.api { render_api_ok } | |
|
179 | 179 | end |
|
180 | 180 | end |
|
181 | 181 |
@@ -144,7 +144,7 class VersionsController < ApplicationController | |||
|
144 | 144 | flash[:notice] = l(:notice_successful_update) |
|
145 | 145 | redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project |
|
146 | 146 | } |
|
147 |
format.api { |
|
|
147 | format.api { render_api_ok } | |
|
148 | 148 | end |
|
149 | 149 | else |
|
150 | 150 | respond_to do |format| |
@@ -167,7 +167,7 class VersionsController < ApplicationController | |||
|
167 | 167 | @version.destroy |
|
168 | 168 | respond_to do |format| |
|
169 | 169 | format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project } |
|
170 |
format.api { |
|
|
170 | format.api { render_api_ok } | |
|
171 | 171 | end |
|
172 | 172 | else |
|
173 | 173 | respond_to do |format| |
@@ -148,6 +148,7 class ApiTest::GroupsTest < ActionController::IntegrationTest | |||
|
148 | 148 | should "update the group" do |
|
149 | 149 | put '/groups/10.xml', {:group => {:name => 'New name', :user_ids => [2, 3]}}, credentials('admin') |
|
150 | 150 | assert_response :ok |
|
151 | assert_equal '', @response.body | |
|
151 | 152 | |
|
152 | 153 | group = Group.find(10) |
|
153 | 154 | assert_equal 'New name', group.name |
@@ -177,6 +178,7 class ApiTest::GroupsTest < ActionController::IntegrationTest | |||
|
177 | 178 | assert_difference 'Group.count', -1 do |
|
178 | 179 | delete '/groups/10.xml', {}, credentials('admin') |
|
179 | 180 | assert_response :ok |
|
181 | assert_equal '', @response.body | |
|
180 | 182 | end |
|
181 | 183 | end |
|
182 | 184 | end |
@@ -188,6 +190,7 class ApiTest::GroupsTest < ActionController::IntegrationTest | |||
|
188 | 190 | assert_difference 'Group.find(10).users.count' do |
|
189 | 191 | post '/groups/10/users.xml', {:user_id => 5}, credentials('admin') |
|
190 | 192 | assert_response :ok |
|
193 | assert_equal '', @response.body | |
|
191 | 194 | end |
|
192 | 195 | assert_include User.find(5), Group.find(10).users |
|
193 | 196 | end |
@@ -200,6 +203,7 class ApiTest::GroupsTest < ActionController::IntegrationTest | |||
|
200 | 203 | assert_difference 'Group.find(10).users.count', -1 do |
|
201 | 204 | delete '/groups/10/users/8.xml', {}, credentials('admin') |
|
202 | 205 | assert_response :ok |
|
206 | assert_equal '', @response.body | |
|
203 | 207 | end |
|
204 | 208 | assert_not_include User.find(8), Group.find(10).users |
|
205 | 209 | end |
@@ -81,6 +81,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
81 | 81 | put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith') |
|
82 | 82 | end |
|
83 | 83 | assert_response :ok |
|
84 | assert_equal '', @response.body | |
|
84 | 85 | assert_equal 'API Update', IssueCategory.find(2).name |
|
85 | 86 | end |
|
86 | 87 | end |
@@ -104,6 +105,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
104 | 105 | delete '/issue_categories/1.xml', {}, credentials('jsmith') |
|
105 | 106 | end |
|
106 | 107 | assert_response :ok |
|
108 | assert_equal '', @response.body | |
|
107 | 109 | assert_nil IssueCategory.find_by_id(1) |
|
108 | 110 | end |
|
109 | 111 | |
@@ -117,6 +119,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
117 | 119 | end |
|
118 | 120 | end |
|
119 | 121 | assert_response :ok |
|
122 | assert_equal '', @response.body | |
|
120 | 123 | assert_nil IssueCategory.find_by_id(1) |
|
121 | 124 | end |
|
122 | 125 | end |
@@ -99,6 +99,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
99 | 99 | end |
|
100 | 100 | |
|
101 | 101 | assert_response :ok |
|
102 | assert_equal '', @response.body | |
|
102 | 103 | assert_nil IssueRelation.find_by_id(2) |
|
103 | 104 | end |
|
104 | 105 | end |
@@ -770,6 +770,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
770 | 770 | {:issue => {:notes => 'Attachment added', :uploads => [{:token => token, :filename => 'test.txt', :content_type => 'text/plain'}]}}, |
|
771 | 771 | credentials('jsmith') |
|
772 | 772 | assert_response :ok |
|
773 | assert_equal '', @response.body | |
|
773 | 774 | end |
|
774 | 775 | |
|
775 | 776 | issue = Issue.find(1) |
@@ -157,6 +157,7 class ApiTest::MembershipsTest < ActionController::IntegrationTest | |||
|
157 | 157 | put '/memberships/2.xml', {:membership => {:user_id => 3, :role_ids => [1,2]}}, credentials('jsmith') |
|
158 | 158 | |
|
159 | 159 | assert_response :ok |
|
160 | assert_equal '', @response.body | |
|
160 | 161 | end |
|
161 | 162 | member = Member.find(2) |
|
162 | 163 | assert_equal [1,2], member.role_ids.sort |
@@ -179,6 +180,7 class ApiTest::MembershipsTest < ActionController::IntegrationTest | |||
|
179 | 180 | delete '/memberships/2.xml', {}, credentials('jsmith') |
|
180 | 181 | |
|
181 | 182 | assert_response :ok |
|
183 | assert_equal '', @response.body | |
|
182 | 184 | end |
|
183 | 185 | assert_nil Member.find_by_id(2) |
|
184 | 186 | end |
@@ -226,6 +226,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
226 | 226 | put '/projects/2.xml', @parameters, credentials('jsmith') |
|
227 | 227 | end |
|
228 | 228 | assert_response :ok |
|
229 | assert_equal '', @response.body | |
|
229 | 230 | assert_equal 'application/xml', @response.content_type |
|
230 | 231 | project = Project.find(2) |
|
231 | 232 | assert_equal 'API update', project.name |
@@ -238,6 +239,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
238 | 239 | put '/projects/2.xml', @parameters, credentials('admin') |
|
239 | 240 | end |
|
240 | 241 | assert_response :ok |
|
242 | assert_equal '', @response.body | |
|
241 | 243 | project = Project.find(2) |
|
242 | 244 | assert_equal ['issue_tracking', 'news', 'time_tracking'], project.enabled_module_names.sort |
|
243 | 245 | end |
@@ -249,6 +251,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
249 | 251 | put '/projects/2.xml', @parameters, credentials('admin') |
|
250 | 252 | end |
|
251 | 253 | assert_response :ok |
|
254 | assert_equal '', @response.body | |
|
252 | 255 | project = Project.find(2) |
|
253 | 256 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
254 | 257 | end |
@@ -286,6 +289,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
286 | 289 | delete '/projects/2.xml', {}, credentials('admin') |
|
287 | 290 | end |
|
288 | 291 | assert_response :ok |
|
292 | assert_equal '', @response.body | |
|
289 | 293 | assert_nil Project.find_by_id(2) |
|
290 | 294 | end |
|
291 | 295 | end |
@@ -134,6 +134,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
134 | 134 | put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, credentials('jsmith') |
|
135 | 135 | end |
|
136 | 136 | assert_response :ok |
|
137 | assert_equal '', @response.body | |
|
137 | 138 | assert_equal 'API Update', TimeEntry.find(2).comments |
|
138 | 139 | end |
|
139 | 140 | end |
@@ -157,6 +158,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
157 | 158 | delete '/time_entries/2.xml', {}, credentials('jsmith') |
|
158 | 159 | end |
|
159 | 160 | assert_response :ok |
|
161 | assert_equal '', @response.body | |
|
160 | 162 | assert_nil TimeEntry.find_by_id(2) |
|
161 | 163 | end |
|
162 | 164 | end |
@@ -238,6 +238,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
238 | 238 | assert !user.admin? |
|
239 | 239 | |
|
240 | 240 | assert_response :ok |
|
241 | assert_equal '', @response.body | |
|
241 | 242 | end |
|
242 | 243 | end |
|
243 | 244 | |
@@ -263,6 +264,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
263 | 264 | assert !user.admin? |
|
264 | 265 | |
|
265 | 266 | assert_response :ok |
|
267 | assert_equal '', @response.body | |
|
266 | 268 | end |
|
267 | 269 | end |
|
268 | 270 | end |
@@ -322,6 +324,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
322 | 324 | end |
|
323 | 325 | |
|
324 | 326 | assert_response :ok |
|
327 | assert_equal '', @response.body | |
|
325 | 328 | end |
|
326 | 329 | end |
|
327 | 330 | |
@@ -337,6 +340,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
337 | 340 | end |
|
338 | 341 | |
|
339 | 342 | assert_response :ok |
|
343 | assert_equal '', @response.body | |
|
340 | 344 | end |
|
341 | 345 | end |
|
342 | 346 | end |
@@ -120,6 +120,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
120 | 120 | put '/versions/2.xml', {:version => {:name => 'API update'}}, credentials('jsmith') |
|
121 | 121 | |
|
122 | 122 | assert_response :ok |
|
123 | assert_equal '', @response.body | |
|
123 | 124 | assert_equal 'API update', Version.find(2).name |
|
124 | 125 | end |
|
125 | 126 | end |
@@ -131,6 +132,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
131 | 132 | end |
|
132 | 133 | |
|
133 | 134 | assert_response :ok |
|
135 | assert_equal '', @response.body | |
|
134 | 136 | assert_nil Version.find_by_id(3) |
|
135 | 137 | end |
|
136 | 138 | end |
General Comments 0
You need to be logged in to leave comments.
Login now