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