Verify HTTP method on ProjectsController#create.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4646 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-01-06 20:46:22 +00:00
parent 9fb770ba50
commit 072c4ad14c
2 changed files with 14 additions and 3 deletions

View File

@ -32,9 +32,6 @@ class ProjectsController < ApplicationController
end end
end end
# TODO: convert to PUT only
verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
helper :sort helper :sort
include SortHelper include SortHelper
helper :custom_fields helper :custom_fields
@ -71,6 +68,7 @@ class ProjectsController < ApplicationController
@project = Project.new(params[:project]) @project = Project.new(params[:project])
end end
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
def create def create
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position") @issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
@trackers = Tracker.all @trackers = Tracker.all
@ -183,6 +181,8 @@ class ProjectsController < ApplicationController
def edit def edit
end end
# TODO: convert to PUT only
verify :method => [:post, :put], :only => :update, :render => {:nothing => true, :status => :method_not_allowed }
def update def update
@project.safe_attributes = params[:project] @project.safe_attributes = params[:project]
if validate_parent_id && @project.save if validate_parent_id && @project.save

View File

@ -288,6 +288,17 @@ class ProjectsControllerTest < ActionController::TestCase
end end
end end
context "GET :create" do
setup do
@request.session[:user_id] = 1
end
should "not be allowed" do
get :create
assert_response :method_not_allowed
end
end
def test_show_by_id def test_show_by_id
get :show, :id => 1 get :show, :id => 1
assert_response :success assert_response :success