##// END OF EJS Templates
Accept key auth for ProjectsController#create (#6841)....
Jean-Philippe Lang -
r4327:8458faed1111
parent child
Show More
@@ -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
27 accept_key_auth :index, :create
28 28
29 29 after_filter :only => [:create, :edit, :update, :archive, :unarchive, :destroy] do |controller|
30 30 if controller.request.post?
@@ -47,21 +47,26 class ApiTest::ProjectsTest < ActionController::IntegrationTest
47 47 assert_no_tag 'custom_field', :attributes => {:name => 'Development status'}
48 48 end
49 49
50 def test_create
51 attributes = {:name => 'API test', :identifier => 'api-test'}
52 assert_difference 'Project.count' do
53 post '/projects.xml', {:project => attributes}, :authorization => credentials('admin')
50 context "POST /projects.xml" do
51 should_allow_api_authentication(:post,
52 '/projects.xml',
53 {:project => {:name => 'API test', :identifier => 'api-test'}},
54 {:success_code => :created})
55
56 should "create a project with the attributes" do
57 assert_difference('Project.count') do
58 post '/projects.xml', {:project => {:name => 'API test', :identifier => 'api-test'}}, :authorization => credentials('admin')
54 59 end
55 60
56 61 project = Project.first(:order => 'id DESC')
57 attributes.each do |attribute, value|
58 assert_equal value, project.send(attribute)
59 end
62 assert_equal 'API test', project.name
63 assert_equal 'api-test', project.identifier
60 64
61 65 assert_response :created
62 66 assert_equal 'application/xml', @response.content_type
63 67 assert_tag 'project', :child => {:tag => 'id', :content => project.id.to_s}
64 68 end
69 end
65 70
66 71 def test_create_failure
67 72 attributes = {:name => 'API test'}
General Comments 0
You need to be logged in to leave comments. Login now