Feature #35507 ยป 35507.patch
| app/controllers/projects_controller.rb | ||
|---|---|---|
|
before_action :authorize_global, :only => [:new, :create]
|
||
|
before_action :require_admin, :only => [:copy, :archive, :unarchive]
|
||
|
accept_rss_auth :index
|
||
|
accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive
|
||
|
accept_api_auth :index, :show, :create, :update, :destroy, :archive, :unarchive, :close, :reopen
|
||
|
require_sudo_mode :destroy
|
||
|
helper :custom_fields
|
||
| ... | ... | |
|
def close
|
||
|
@project.close
|
||
|
redirect_to project_path(@project)
|
||
|
respond_to do |format|
|
||
|
format.html { redirect_to project_path(@project) }
|
||
|
format.api { render_api_ok }
|
||
|
end
|
||
|
end
|
||
|
def reopen
|
||
|
@project.reopen
|
||
|
redirect_to project_path(@project)
|
||
|
respond_to do |format|
|
||
|
format.html { redirect_to project_path(@project) }
|
||
|
format.api { render_api_ok }
|
||
|
end
|
||
|
end
|
||
|
# Delete @project
|
||
| config/routes.rb | ||
|---|---|---|
|
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||
|
match 'archive', :via => [:post, :put]
|
||
|
match 'unarchive', :via => [:post, :put]
|
||
|
post 'close'
|
||
|
post 'reopen'
|
||
|
match 'close', :via => [:post, :put]
|
||
|
match 'reopen', :via => [:post, :put]
|
||
|
match 'copy', :via => [:get, :post]
|
||
|
match 'bookmark', :via => [:delete, :post]
|
||
|
end
|
||
| test/integration/api_test/projects_test.rb | ||
|---|---|---|
|
assert p = Project.find_by_id(2)
|
||
|
assert p.active?
|
||
|
end
|
||
|
test "PUT /projects/:id/close.xml should close project" do
|
||
|
put '/projects/1/close.xml', :headers => credentials('admin')
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert p = Project.find(1)
|
||
|
assert p.closed?
|
||
|
end
|
||
|
test "PUT /projects/:id/reopen.xml should reopen project" do
|
||
|
Project.find(1).update_column :status, Project::STATUS_CLOSED
|
||
|
put '/projects/1/reopen.xml', :headers => credentials('admin')
|
||
|
assert_response :no_content
|
||
|
assert_equal '', @response.body
|
||
|
assert p = Project.find(1)
|
||
|
assert p.active?
|
||
|
end
|
||
|
end
|
||