Mercurial > hg > soundsoftware-site
comparison .svn/pristine/a3/a318a613036ecdc928e6114a6b45909cbfd08415.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::VersionsTest < Redmine::ApiTest::Base | |
21 fixtures :projects, :trackers, :issue_statuses, :issues, | |
22 :enumerations, :users, :issue_categories, | |
23 :projects_trackers, | |
24 :roles, | |
25 :member_roles, | |
26 :members, | |
27 :enabled_modules, | |
28 :versions | |
29 | |
30 def setup | |
31 Setting.rest_api_enabled = '1' | |
32 end | |
33 | |
34 test "GET /projects/:project_id/versions.xml should return project versions" do | |
35 get '/projects/1/versions.xml' | |
36 | |
37 assert_response :success | |
38 assert_equal 'application/xml', @response.content_type | |
39 assert_tag :tag => 'versions', | |
40 :attributes => {:type => 'array'}, | |
41 :child => { | |
42 :tag => 'version', | |
43 :child => { | |
44 :tag => 'id', | |
45 :content => '2', | |
46 :sibling => { | |
47 :tag => 'name', | |
48 :content => '1.0' | |
49 } | |
50 } | |
51 } | |
52 end | |
53 | |
54 test "POST /projects/:project_id/versions.xml should create the version" do | |
55 assert_difference 'Version.count' do | |
56 post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, credentials('jsmith') | |
57 end | |
58 | |
59 version = Version.order('id DESC').first | |
60 assert_equal 'API test', version.name | |
61 | |
62 assert_response :created | |
63 assert_equal 'application/xml', @response.content_type | |
64 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} | |
65 end | |
66 | |
67 test "POST /projects/:project_id/versions.xml should create the version with due date" do | |
68 assert_difference 'Version.count' do | |
69 post '/projects/1/versions.xml', {:version => {:name => 'API test', :due_date => '2012-01-24'}}, credentials('jsmith') | |
70 end | |
71 | |
72 version = Version.order('id DESC').first | |
73 assert_equal 'API test', version.name | |
74 assert_equal Date.parse('2012-01-24'), version.due_date | |
75 | |
76 assert_response :created | |
77 assert_equal 'application/xml', @response.content_type | |
78 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s} | |
79 end | |
80 | |
81 test "POST /projects/:project_id/versions.xml should create the version with custom fields" do | |
82 field = VersionCustomField.generate! | |
83 | |
84 assert_difference 'Version.count' do | |
85 post '/projects/1/versions.xml', { | |
86 :version => { | |
87 :name => 'API test', | |
88 :custom_fields => [ | |
89 {'id' => field.id.to_s, 'value' => 'Some value'} | |
90 ] | |
91 } | |
92 }, credentials('jsmith') | |
93 end | |
94 | |
95 version = Version.order('id DESC').first | |
96 assert_equal 'API test', version.name | |
97 assert_equal 'Some value', version.custom_field_value(field) | |
98 | |
99 assert_response :created | |
100 assert_equal 'application/xml', @response.content_type | |
101 assert_select 'version>custom_fields>custom_field[id=?]>value', field.id.to_s, 'Some value' | |
102 end | |
103 | |
104 test "POST /projects/:project_id/versions.xml with failure should return the errors" do | |
105 assert_no_difference('Version.count') do | |
106 post '/projects/1/versions.xml', {:version => {:name => ''}}, credentials('jsmith') | |
107 end | |
108 | |
109 assert_response :unprocessable_entity | |
110 assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"} | |
111 end | |
112 | |
113 test "GET /versions/:id.xml should return the version" do | |
114 get '/versions/2.xml' | |
115 | |
116 assert_response :success | |
117 assert_equal 'application/xml', @response.content_type | |
118 assert_select 'version' do | |
119 assert_select 'id', :text => '2' | |
120 assert_select 'name', :text => '1.0' | |
121 assert_select 'sharing', :text => 'none' | |
122 end | |
123 end | |
124 | |
125 test "PUT /versions/:id.xml should update the version" do | |
126 put '/versions/2.xml', {:version => {:name => 'API update'}}, credentials('jsmith') | |
127 | |
128 assert_response :ok | |
129 assert_equal '', @response.body | |
130 assert_equal 'API update', Version.find(2).name | |
131 end | |
132 | |
133 test "DELETE /versions/:id.xml should destroy the version" do | |
134 assert_difference 'Version.count', -1 do | |
135 delete '/versions/3.xml', {}, credentials('jsmith') | |
136 end | |
137 | |
138 assert_response :ok | |
139 assert_equal '', @response.body | |
140 assert_nil Version.find_by_id(3) | |
141 end | |
142 end |