Mercurial > hg > soundsoftware-site
comparison .svn/pristine/65/65e9a6c068b35b0498ff2c94d67db3241b91f5be.svn-base @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../../test_helper', __FILE__) | |
19 | |
20 class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base | |
21 fixtures :projects, :users, :issue_categories, :issues, | |
22 :roles, | |
23 :member_roles, | |
24 :members, | |
25 :enabled_modules | |
26 | |
27 def setup | |
28 Setting.rest_api_enabled = '1' | |
29 end | |
30 | |
31 context "GET /projects/:project_id/issue_categories.xml" do | |
32 should "return issue categories" do | |
33 get '/projects/1/issue_categories.xml', {}, credentials('jsmith') | |
34 assert_response :success | |
35 assert_equal 'application/xml', @response.content_type | |
36 assert_tag :tag => 'issue_categories', | |
37 :child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}} | |
38 end | |
39 end | |
40 | |
41 context "GET /issue_categories/2.xml" do | |
42 should "return requested issue category" do | |
43 get '/issue_categories/2.xml', {}, credentials('jsmith') | |
44 assert_response :success | |
45 assert_equal 'application/xml', @response.content_type | |
46 assert_tag :tag => 'issue_category', | |
47 :child => {:tag => 'id', :content => '2'} | |
48 end | |
49 end | |
50 | |
51 context "POST /projects/:project_id/issue_categories.xml" do | |
52 should "return create issue category" do | |
53 assert_difference 'IssueCategory.count' do | |
54 post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith') | |
55 end | |
56 assert_response :created | |
57 assert_equal 'application/xml', @response.content_type | |
58 | |
59 category = IssueCategory.first(:order => 'id DESC') | |
60 assert_equal 'API', category.name | |
61 assert_equal 1, category.project_id | |
62 end | |
63 | |
64 context "with invalid parameters" do | |
65 should "return errors" do | |
66 assert_no_difference 'IssueCategory.count' do | |
67 post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
68 end | |
69 assert_response :unprocessable_entity | |
70 assert_equal 'application/xml', @response.content_type | |
71 | |
72 assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"} | |
73 end | |
74 end | |
75 end | |
76 | |
77 context "PUT /issue_categories/2.xml" do | |
78 context "with valid parameters" do | |
79 should "update issue category" do | |
80 assert_no_difference 'IssueCategory.count' do | |
81 put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith') | |
82 end | |
83 assert_response :ok | |
84 assert_equal '', @response.body | |
85 assert_equal 'API Update', IssueCategory.find(2).name | |
86 end | |
87 end | |
88 | |
89 context "with invalid parameters" do | |
90 should "return errors" do | |
91 assert_no_difference 'IssueCategory.count' do | |
92 put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
93 end | |
94 assert_response :unprocessable_entity | |
95 assert_equal 'application/xml', @response.content_type | |
96 | |
97 assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"} | |
98 end | |
99 end | |
100 end | |
101 | |
102 context "DELETE /issue_categories/1.xml" do | |
103 should "destroy issue categories" do | |
104 assert_difference 'IssueCategory.count', -1 do | |
105 delete '/issue_categories/1.xml', {}, credentials('jsmith') | |
106 end | |
107 assert_response :ok | |
108 assert_equal '', @response.body | |
109 assert_nil IssueCategory.find_by_id(1) | |
110 end | |
111 | |
112 should "reassign issues with :reassign_to_id param" do | |
113 issue_count = Issue.count(:conditions => {:category_id => 1}) | |
114 assert issue_count > 0 | |
115 | |
116 assert_difference 'IssueCategory.count', -1 do | |
117 assert_difference 'Issue.count(:conditions => {:category_id => 2})', 3 do | |
118 delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith') | |
119 end | |
120 end | |
121 assert_response :ok | |
122 assert_equal '', @response.body | |
123 assert_nil IssueCategory.find_by_id(1) | |
124 end | |
125 end | |
126 end |