]> source.dussan.org Git - redmine.git/commitdiff
Accept key auth for ProjectsController#update (#6841).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Nov 2010 16:32:48 +0000 (16:32 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 Nov 2010 16:32:48 +0000 (16:32 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4442 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
test/integration/api_test/projects_test.rb

index 1e4affb26c14126906d8052e3c9da5589f1aed80..3bedd2c78054043babf5ca8cbde2092668972fe9 100644 (file)
@@ -24,7 +24,7 @@ class ProjectsController < ApplicationController
   before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
   before_filter :authorize_global, :only => [:new, :create]
   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|
     if controller.request.post?
index d898b42ac8bd80b8379870f28272837dad62dfd3..c2ffa69208d2d19f59ad32c8e0a896e7fb153c39 100644 (file)
@@ -78,16 +78,20 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
     assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"}
   end
     
-  def test_update
-    attributes = {:name => 'API update'}
-    assert_no_difference 'Project.count' do
-      put '/projects/1.xml', {:project => attributes}, :authorization => credentials('jsmith')
-    end
-    assert_response :ok
-    assert_equal 'application/xml', @response.content_type
-    project = Project.find(1)
-    attributes.each do |attribute, value|
-      assert_equal value, project.send(attribute)
+  context "PUT /projects/2.xml" do
+    should_allow_api_authentication(:put,
+                                    '/projects/2.xml',
+                                    {:project => {:name => 'API test'}},
+                                    {:success_code => :ok})
+    
+    should "update the project" do
+      assert_no_difference 'Project.count' do
+        put '/projects/2.xml', {:project => {:name => 'API update'}}, :authorization => credentials('jsmith')
+      end
+      assert_response :ok
+      assert_equal 'application/xml', @response.content_type
+      project = Project.find(2)
+      assert_equal 'API update', project.name
     end
   end