Feature #35507 ยป 35507.patch
app/controllers/projects_controller.rb | ||
---|---|---|
30 | 30 |
before_action :authorize_global, :only => [:new, :create] |
31 | 31 |
before_action :require_admin, :only => [:copy, :archive, :unarchive] |
32 | 32 |
accept_rss_auth :index |
33 |
accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive |
|
33 |
accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive, :close, :reopen
|
|
34 | 34 |
require_sudo_mode :destroy |
35 | 35 | |
36 | 36 |
helper :custom_fields |
... | ... | |
275 | 275 | |
276 | 276 |
def close |
277 | 277 |
@project.close |
278 |
redirect_to project_path(@project) |
|
278 |
respond_to do |format| |
|
279 |
format.html { redirect_to project_path(@project) } |
|
280 |
format.api { render_api_ok } |
|
281 |
end |
|
279 | 282 |
end |
280 | 283 | |
281 | 284 |
def reopen |
282 | 285 |
@project.reopen |
283 |
redirect_to project_path(@project) |
|
286 |
respond_to do |format| |
|
287 |
format.html { redirect_to project_path(@project) } |
|
288 |
format.api { render_api_ok } |
|
289 |
end |
|
284 | 290 |
end |
285 | 291 | |
286 | 292 |
# Delete @project |
config/routes.rb | ||
---|---|---|
133 | 133 |
get 'settings(/:tab)', :action => 'settings', :as => 'settings' |
134 | 134 |
match 'archive', :via => [:post, :put] |
135 | 135 |
match 'unarchive', :via => [:post, :put] |
136 |
post 'close'
|
|
137 |
post 'reopen'
|
|
136 |
match 'close', :via => [:post, :put]
|
|
137 |
match 'reopen', :via => [:post, :put]
|
|
138 | 138 |
match 'copy', :via => [:get, :post] |
139 | 139 |
match 'bookmark', :via => [:delete, :post] |
140 | 140 |
end |
test/integration/api_test/projects_test.rb | ||
---|---|---|
373 | 373 |
assert p = Project.find_by_id(2) |
374 | 374 |
assert p.active? |
375 | 375 |
end |
376 | ||
377 |
test "PUT /projects/:id/close.xml should close project" do |
|
378 |
put '/projects/1/close.xml', :headers => credentials('admin') |
|
379 |
assert_response :no_content |
|
380 |
assert_equal '', @response.body |
|
381 |
assert p = Project.find(1) |
|
382 |
assert p.closed? |
|
383 |
end |
|
384 | ||
385 |
test "PUT /projects/:id/reopen.xml should reopen project" do |
|
386 |
Project.find(1).update_column :status, Project::STATUS_CLOSED |
|
387 |
put '/projects/1/reopen.xml', :headers => credentials('admin') |
|
388 |
assert_response :no_content |
|
389 |
assert_equal '', @response.body |
|
390 |
assert p = Project.find(1) |
|
391 |
assert p.active? |
|
392 |
end |
|
376 | 393 |
end |