Accept key auth for ProjectsController#destroy (#6841).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4443 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
054b7d28f1
commit
3d6cb1435c
@ -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, :update
|
accept_key_auth :index, :create, :update, :destroy
|
||||||
|
|
||||||
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?
|
||||||
|
@ -31,7 +31,7 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show
|
def test_show
|
||||||
get '/projects/1.xml'
|
get '/projects/1.xml'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
@ -104,14 +104,20 @@ class ApiTest::ProjectsTest < ActionController::IntegrationTest
|
|||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
|
assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_destroy
|
context "DELETE /projects/2.xml" do
|
||||||
assert_difference 'Project.count', -1 do
|
should_allow_api_authentication(:delete,
|
||||||
delete '/projects/2.xml', {}, :authorization => credentials('admin')
|
'/projects/2.xml',
|
||||||
|
{},
|
||||||
|
{:success_code => :ok})
|
||||||
|
|
||||||
|
should "delete the project" do
|
||||||
|
assert_difference('Project.count',-1) do
|
||||||
|
delete '/projects/2.xml', {}, :authorization => credentials('admin')
|
||||||
|
end
|
||||||
|
assert_response :ok
|
||||||
|
assert_nil Project.find_by_id(2)
|
||||||
end
|
end
|
||||||
assert_response :ok
|
|
||||||
assert_equal 'application/xml', @response.content_type
|
|
||||||
assert_nil Project.find_by_id(2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def credentials(user, password=nil)
|
def credentials(user, password=nil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user