Accept key auth for ProjectsController#update (#6841).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4442 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-11-27 16:32:48 +00:00
parent 8458faed11
commit 054b7d28f1
2 changed files with 15 additions and 11 deletions

View File

@ -24,7 +24,7 @@ class ProjectsController < ApplicationController
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
before_filter :authorize_global, :only => [:new, :create] before_filter :authorize_global, :only => [:new, :create]
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
accept_key_auth :index, :create accept_key_auth :index, :create, :update
after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
if controller.request.post? if controller.request.post?

View File

@ -78,16 +78,20 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"} assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"}
end end
def test_update context "PUT /projects/2.xml" do
attributes = {:name => 'API update'} should_allow_api_authentication(:put,
assert_no_difference 'Project.count' do '/projects/2.xml',
put '/projects/1.xml', {:project => attributes}, :authorization => credentials('jsmith') {:project => {:name => 'API test'}},
end {:success_code => :ok})
assert_response :ok
assert_equal 'application/xml', @response.content_type should "update the project" do
project = Project.find(1) assert_no_difference 'Project.count' do
attributes.each do |attribute, value| put '/projects/2.xml', {:project => {:name => 'API update'}}, :authorization => credentials('jsmith')
assert_equal value, project.send(attribute) end
assert_response :ok
assert_equal 'application/xml', @response.content_type
project = Project.find(2)
assert_equal 'API update', project.name
end end
end end