Mercurial > hg > soundsoftware-site
comparison .svn/pristine/2d/2d90db0331b1140b778e4338d292ab96881523cf.svn-base @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2014 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 test "GET /projects/:project_id/issue_categories.xml should return the issue categories" do | |
32 get '/projects/1/issue_categories.xml', {}, credentials('jsmith') | |
33 assert_response :success | |
34 assert_equal 'application/xml', @response.content_type | |
35 assert_tag :tag => 'issue_categories', | |
36 :child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}} | |
37 end | |
38 | |
39 test "GET /issue_categories/:id.xml should return the issue category" do | |
40 get '/issue_categories/2.xml', {}, credentials('jsmith') | |
41 assert_response :success | |
42 assert_equal 'application/xml', @response.content_type | |
43 assert_tag :tag => 'issue_category', | |
44 :child => {:tag => 'id', :content => '2'} | |
45 end | |
46 | |
47 test "POST /projects/:project_id/issue_categories.xml should return create issue category" do | |
48 assert_difference 'IssueCategory.count' do | |
49 post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith') | |
50 end | |
51 assert_response :created | |
52 assert_equal 'application/xml', @response.content_type | |
53 | |
54 category = IssueCategory.order('id DESC').first | |
55 assert_equal 'API', category.name | |
56 assert_equal 1, category.project_id | |
57 end | |
58 | |
59 test "POST /projects/:project_id/issue_categories.xml with invalid parameters should return errors" do | |
60 assert_no_difference 'IssueCategory.count' do | |
61 post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
62 end | |
63 assert_response :unprocessable_entity | |
64 assert_equal 'application/xml', @response.content_type | |
65 | |
66 assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"} | |
67 end | |
68 | |
69 test "PUT /issue_categories/:id.xml with valid parameters should update the issue category" do | |
70 assert_no_difference 'IssueCategory.count' do | |
71 put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith') | |
72 end | |
73 assert_response :ok | |
74 assert_equal '', @response.body | |
75 assert_equal 'API Update', IssueCategory.find(2).name | |
76 end | |
77 | |
78 test "PUT /issue_categories/:id.xml with invalid parameters should return errors" do | |
79 assert_no_difference 'IssueCategory.count' do | |
80 put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
81 end | |
82 assert_response :unprocessable_entity | |
83 assert_equal 'application/xml', @response.content_type | |
84 | |
85 assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"} | |
86 end | |
87 | |
88 test "DELETE /issue_categories/:id.xml should destroy the issue category" do | |
89 assert_difference 'IssueCategory.count', -1 do | |
90 delete '/issue_categories/1.xml', {}, credentials('jsmith') | |
91 end | |
92 assert_response :ok | |
93 assert_equal '', @response.body | |
94 assert_nil IssueCategory.find_by_id(1) | |
95 end | |
96 | |
97 test "DELETE /issue_categories/:id.xml should reassign issues with :reassign_to_id param" do | |
98 issue_count = Issue.where(:category_id => 1).count | |
99 assert issue_count > 0 | |
100 | |
101 assert_difference 'IssueCategory.count', -1 do | |
102 assert_difference 'Issue.where(:category_id => 2).count', 3 do | |
103 delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith') | |
104 end | |
105 end | |
106 assert_response :ok | |
107 assert_equal '', @response.body | |
108 assert_nil IssueCategory.find_by_id(1) | |
109 end | |
110 end |