@@ -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 |
|
27 | accept_key_auth :index, :create, :update | |
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? |
@@ -78,16 +78,20 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||||
78 | assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"} |
|
78 | assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"} | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def test_update |
|
81 | context "PUT /projects/2.xml" do | |
82 | attributes = {:name => 'API update'} |
|
82 | should_allow_api_authentication(:put, | |
83 | assert_no_difference 'Project.count' do |
|
83 | '/projects/2.xml', | |
84 | put '/projects/1.xml', {:project => attributes}, :authorization => credentials('jsmith') |
|
84 | {:project => {:name => 'API test'}}, | |
85 | end |
|
85 | {:success_code => :ok}) | |
86 | assert_response :ok |
|
86 | ||
87 | assert_equal 'application/xml', @response.content_type |
|
87 | should "update the project" do | |
88 | project = Project.find(1) |
|
88 | assert_no_difference 'Project.count' do | |
89 | attributes.each do |attribute, value| |
|
89 | put '/projects/2.xml', {:project => {:name => 'API update'}}, :authorization => credentials('jsmith') | |
90 | assert_equal value, project.send(attribute) |
|
90 | end | |
|
91 | assert_response :ok | |||
|
92 | assert_equal 'application/xml', @response.content_type | |||
|
93 | project = Project.find(2) | |||
|
94 | assert_equal 'API update', project.name | |||
91 | end |
|
95 | end | |
92 | end |
|
96 | end | |
93 |
|
97 |
General Comments 0
You need to be logged in to leave comments.
Login now