@@ -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? |
@@ -31,7 +31,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||||
31 | assert_response :success |
|
31 | assert_response :success | |
32 | assert_equal 'application/xml', @response.content_type |
|
32 | assert_equal 'application/xml', @response.content_type | |
33 | end |
|
33 | end | |
34 |
|
|
34 | ||
35 | def test_show |
|
35 | def test_show | |
36 | get '/projects/1.xml' |
|
36 | get '/projects/1.xml' | |
37 | assert_response :success |
|
37 | assert_response :success | |
@@ -104,14 +104,20 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||||
104 | assert_equal 'application/xml', @response.content_type |
|
104 | assert_equal 'application/xml', @response.content_type | |
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 | delete '/projects/2.xml', {}, :authorization => credentials('admin') |
|
110 | '/projects/2.xml', | |
|
111 | {}, | |||
|
112 | {:success_code => :ok}) | |||
|
113 | ||||
|
114 | should "delete the project" do | |||
|
115 | assert_difference('Project.count',-1) do | |||
|
116 | delete '/projects/2.xml', {}, :authorization => credentials('admin') | |||
|
117 | end | |||
|
118 | assert_response :ok | |||
|
119 | assert_nil Project.find_by_id(2) | |||
111 | end |
|
120 | end | |
112 | assert_response :ok |
|
|||
113 | assert_equal 'application/xml', @response.content_type |
|
|||
114 | assert_nil Project.find_by_id(2) |
|
|||
115 | end |
|
121 | end | |
116 |
|
122 | |||
117 | def credentials(user, password=nil) |
|
123 | def credentials(user, password=nil) |
General Comments 0
You need to be logged in to leave comments.
Login now