@@ -24,7 +24,7 class ProjectsController < ApplicationController | |||
|
24 | 24 | before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] |
|
25 | 25 | before_filter :authorize_global, :only => [:new, :create] |
|
26 | 26 | before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] |
|
27 | accept_key_auth :index, :create, :update | |
|
27 | accept_key_auth :index, :create, :update, :destroy | |
|
28 | 28 | |
|
29 | 29 | after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller| |
|
30 | 30 | if controller.request.post? |
@@ -105,14 +105,20 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
105 | 105 | assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"} |
|
106 | 106 | end |
|
107 | 107 |
|
|
108 | def test_destroy | |
|
109 | assert_difference 'Project.count', -1 do | |
|
108 | context "DELETE /projects/2.xml" do | |
|
109 | should_allow_api_authentication(:delete, | |
|
110 | '/projects/2.xml', | |
|
111 | {}, | |
|
112 | {:success_code => :ok}) | |
|
113 | ||
|
114 | should "delete the project" do | |
|
115 | assert_difference('Project.count',-1) do | |
|
110 | 116 | delete '/projects/2.xml', {}, :authorization => credentials('admin') |
|
111 | 117 | end |
|
112 | 118 | assert_response :ok |
|
113 | assert_equal 'application/xml', @response.content_type | |
|
114 | 119 | assert_nil Project.find_by_id(2) |
|
115 | 120 | end |
|
121 | end | |
|
116 | 122 | |
|
117 | 123 | def credentials(user, password=nil) |
|
118 | 124 | ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) |
General Comments 0
You need to be logged in to leave comments.
Login now