@@ -1,297 +1,235 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, |
|
22 | 22 | :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, |
|
23 | 23 | :attachments, :custom_fields, :custom_values, :time_entries, :issue_categories |
|
24 | 24 | |
|
25 | 25 | def setup |
|
26 | 26 | Setting.rest_api_enabled = '1' |
|
27 | 27 | set_tmp_attachments_directory |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | context "GET /projects" do | |
|
31 | context ".xml" do | |
|
32 | should "return projects" do | |
|
30 | # TODO: A private project is needed because should_allow_api_authentication | |
|
31 | # actually tests that authentication is *required*, not just allowed | |
|
32 | should_allow_api_authentication(:get, "/projects/2.xml") | |
|
33 | should_allow_api_authentication(:get, "/projects/2.json") | |
|
34 | should_allow_api_authentication(:post, | |
|
35 | '/projects.xml', | |
|
36 | {:project => {:name => 'API test', :identifier => 'api-test'}}, | |
|
37 | {:success_code => :created}) | |
|
38 | should_allow_api_authentication(:put, | |
|
39 | '/projects/2.xml', | |
|
40 | {:project => {:name => 'API update'}}, | |
|
41 | {:success_code => :ok}) | |
|
42 | should_allow_api_authentication(:delete, | |
|
43 | '/projects/2.xml', | |
|
44 | {}, | |
|
45 | {:success_code => :ok}) | |
|
46 | ||
|
47 | test "GET /projects.xml should return projects" do | |
|
33 | 48 |
|
|
34 | 49 |
|
|
35 | 50 |
|
|
36 | 51 | |
|
37 | 52 |
|
|
38 | 53 |
|
|
39 | 54 |
|
|
40 | end | |
|
41 | 55 | |
|
42 | context ".json" do | |
|
43 | should "return projects" do | |
|
56 | test "GET /projects.json should return projects" do | |
|
44 | 57 |
|
|
45 | 58 |
|
|
46 | 59 |
|
|
47 | 60 | |
|
48 | 61 |
|
|
49 | 62 |
|
|
50 | 63 |
|
|
51 | 64 |
|
|
52 | 65 |
|
|
53 | 66 |
|
|
54 | end | |
|
55 | end | |
|
56 | ||
|
57 | context "GET /projects/:id" do | |
|
58 | context ".xml" do | |
|
59 | # TODO: A private project is needed because should_allow_api_authentication | |
|
60 | # actually tests that authentication is *required*, not just allowed | |
|
61 | should_allow_api_authentication(:get, "/projects/2.xml") | |
|
62 | 67 | |
|
63 |
|
|
|
68 | test "GET /projects/:id.xml should return the project" do | |
|
64 | 69 |
|
|
65 | 70 |
|
|
66 | 71 |
|
|
67 | 72 | |
|
68 | 73 |
|
|
69 | 74 |
|
|
70 | 75 |
|
|
71 | 76 |
|
|
72 | 77 | |
|
73 | 78 |
|
|
74 | 79 |
|
|
75 | 80 |
|
|
76 | 81 | |
|
77 | context "with hidden custom fields" do | |
|
78 | setup do | |
|
79 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false | |
|
82 | test "GET /projects/:id.json should return the project" do | |
|
83 | get '/projects/1.json' | |
|
84 | ||
|
85 | json = ActiveSupport::JSON.decode(response.body) | |
|
86 | assert_kind_of Hash, json | |
|
87 | assert_kind_of Hash, json['project'] | |
|
88 | assert_equal 1, json['project']['id'] | |
|
80 | 89 |
|
|
81 | 90 | |
|
82 |
|
|
|
91 | test "GET /projects/:id.xml with hidden custom fields should not display hidden custom fields" do | |
|
92 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false | |
|
93 | ||
|
83 | 94 |
|
|
84 | 95 |
|
|
85 | 96 |
|
|
86 | 97 | |
|
87 | 98 |
|
|
88 | 99 |
|
|
89 | 100 |
|
|
90 | end | |
|
91 | 101 | |
|
92 | should "return categories with include=issue_categories" do | |
|
102 | test "GET /projects/:id.xml with include=issue_categories should return categories" do | |
|
93 | 103 |
|
|
94 | 104 |
|
|
95 | 105 |
|
|
96 | 106 | |
|
97 | 107 |
|
|
98 | 108 |
|
|
99 | 109 |
|
|
100 | 110 |
|
|
101 | 111 |
|
|
102 | 112 |
|
|
103 | 113 |
|
|
104 | 114 |
|
|
105 | 115 |
|
|
106 | 116 |
|
|
107 | 117 | |
|
108 | should "return trackers with include=trackers" do | |
|
118 | test "GET /projects/:id.xml with include=trackers should return trackers" do | |
|
109 | 119 |
|
|
110 | 120 |
|
|
111 | 121 |
|
|
112 | 122 | |
|
113 | 123 |
|
|
114 | 124 |
|
|
115 | 125 |
|
|
116 | 126 |
|
|
117 | 127 |
|
|
118 | 128 |
|
|
119 | 129 |
|
|
120 | 130 |
|
|
121 | 131 |
|
|
122 | 132 |
|
|
123 | end | |
|
124 | ||
|
125 | context ".json" do | |
|
126 | should_allow_api_authentication(:get, "/projects/2.json") | |
|
127 | ||
|
128 | should "return requested project" do | |
|
129 | get '/projects/1.json' | |
|
130 | 133 | |
|
131 | json = ActiveSupport::JSON.decode(response.body) | |
|
132 | assert_kind_of Hash, json | |
|
133 | assert_kind_of Hash, json['project'] | |
|
134 | assert_equal 1, json['project']['id'] | |
|
135 | end | |
|
136 | end | |
|
137 | end | |
|
138 | ||
|
139 | context "POST /projects" do | |
|
140 | context "with valid parameters" do | |
|
141 | setup do | |
|
134 | test "POST /projects.xml with valid parameters should create the project" do | |
|
142 | 135 |
|
|
143 | @parameters = {:project => {:name => 'API test', :identifier => 'api-test'}} | |
|
144 | end | |
|
145 | 136 | |
|
146 | context ".xml" do | |
|
147 | should_allow_api_authentication(:post, | |
|
148 | '/projects.xml', | |
|
149 | {:project => {:name => 'API test', :identifier => 'api-test'}}, | |
|
150 | {:success_code => :created}) | |
|
151 | ||
|
152 | ||
|
153 | should "create a project with the attributes" do | |
|
154 | 137 |
|
|
155 | post '/projects.xml', @parameters, credentials('admin') | |
|
138 | post '/projects.xml', | |
|
139 | {:project => {:name => 'API test', :identifier => 'api-test'}}, | |
|
140 | credentials('admin') | |
|
156 | 141 |
|
|
157 | 142 | |
|
158 | 143 |
|
|
159 | 144 |
|
|
160 | 145 |
|
|
161 | 146 |
|
|
162 | 147 |
|
|
163 | 148 | |
|
164 | 149 |
|
|
165 | 150 |
|
|
166 | 151 |
|
|
167 | 152 |
|
|
168 | 153 | |
|
169 |
|
|
|
170 | @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) | |
|
171 | ||
|
154 | test "POST /projects.xml should accept enabled_module_names attribute" do | |
|
172 | 155 |
|
|
173 | post '/projects.xml', @parameters, credentials('admin') | |
|
156 | post '/projects.xml', | |
|
157 | {:project => {:name => 'API test', :identifier => 'api-test', :enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}}, | |
|
158 | credentials('admin') | |
|
174 | 159 |
|
|
175 | 160 | |
|
176 | 161 |
|
|
177 | 162 |
|
|
178 | 163 |
|
|
179 | 164 | |
|
180 |
|
|
|
181 | @parameters[:project].merge!({:tracker_ids => [1, 3]}) | |
|
182 | ||
|
165 | test "POST /projects.xml should accept tracker_ids attribute" do | |
|
183 | 166 |
|
|
184 | post '/projects.xml', @parameters, credentials('admin') | |
|
167 | post '/projects.xml', | |
|
168 | {:project => {:name => 'API test', :identifier => 'api-test', :tracker_ids => [1, 3]}}, | |
|
169 | credentials('admin') | |
|
185 | 170 |
|
|
186 | 171 | |
|
187 | 172 |
|
|
188 | 173 |
|
|
189 | 174 |
|
|
190 | end | |
|
191 | end | |
|
192 | ||
|
193 | context "with invalid parameters" do | |
|
194 | setup do | |
|
195 | @parameters = {:project => {:name => 'API test'}} | |
|
196 | end | |
|
197 | 175 | |
|
198 | context ".xml" do | |
|
199 | should "return errors" do | |
|
176 | test "POST /projects.xml with invalid parameters should return errors" do | |
|
200 | 177 |
|
|
201 |
|
|
|
178 | post '/projects.xml', {:project => {:name => 'API test'}}, credentials('admin') | |
|
202 | 179 |
|
|
203 | 180 | |
|
204 | 181 |
|
|
205 | 182 |
|
|
206 | 183 |
|
|
207 | 184 |
|
|
208 | end | |
|
209 | end | |
|
210 | end | |
|
211 | ||
|
212 | context "PUT /projects/:id" do | |
|
213 | context "with valid parameters" do | |
|
214 | setup do | |
|
215 | @parameters = {:project => {:name => 'API update'}} | |
|
216 | end | |
|
217 | 185 | |
|
218 | context ".xml" do | |
|
219 | should_allow_api_authentication(:put, | |
|
220 | '/projects/2.xml', | |
|
221 | {:project => {:name => 'API update'}}, | |
|
222 | {:success_code => :ok}) | |
|
223 | ||
|
224 | should "update the project" do | |
|
186 | test "PUT /projects/:id.xml with valid parameters should update the project" do | |
|
225 | 187 |
|
|
226 |
|
|
|
188 | put '/projects/2.xml', {:project => {:name => 'API update'}}, credentials('jsmith') | |
|
227 | 189 |
|
|
228 | 190 |
|
|
229 | 191 |
|
|
230 | 192 |
|
|
231 | 193 |
|
|
232 | 194 |
|
|
233 | 195 |
|
|
234 | 196 | |
|
235 |
|
|
|
236 | @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) | |
|
237 | ||
|
197 | test "PUT /projects/:id.xml should accept enabled_module_names attribute" do | |
|
238 | 198 |
|
|
239 | put '/projects/2.xml', @parameters, credentials('admin') | |
|
199 | put '/projects/2.xml', {:project => {:name => 'API update', :enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}}, credentials('admin') | |
|
240 | 200 |
|
|
241 | 201 |
|
|
242 | 202 |
|
|
243 | 203 |
|
|
244 | 204 |
|
|
245 | 205 |
|
|
246 | 206 | |
|
247 |
|
|
|
248 | @parameters[:project].merge!({:tracker_ids => [1, 3]}) | |
|
249 | ||
|
207 | test "PUT /projects/:id.xml should accept tracker_ids attribute" do | |
|
250 | 208 |
|
|
251 |
|
|
|
209 | put '/projects/2.xml', {:project => {:name => 'API update', :tracker_ids => [1, 3]}}, credentials('admin') | |
|
252 | 210 |
|
|
253 | 211 |
|
|
254 | 212 |
|
|
255 | 213 |
|
|
256 | 214 |
|
|
257 | 215 |
|
|
258 | end | |
|
259 | end | |
|
260 | ||
|
261 | context "with invalid parameters" do | |
|
262 | setup do | |
|
263 | @parameters = {:project => {:name => ''}} | |
|
264 | end | |
|
265 | 216 | |
|
266 | context ".xml" do | |
|
267 | should "return errors" do | |
|
217 | test "PUT /projects/:id.xml with invalid parameters should return errors" do | |
|
268 | 218 |
|
|
269 |
|
|
|
219 | put '/projects/2.xml', {:project => {:name => ''}}, credentials('admin') | |
|
270 | 220 |
|
|
271 | 221 | |
|
272 | 222 |
|
|
273 | 223 |
|
|
274 | 224 |
|
|
275 | 225 |
|
|
276 | end | |
|
277 | end | |
|
278 | end | |
|
279 | ||
|
280 | context "DELETE /projects/:id" do | |
|
281 | context ".xml" do | |
|
282 | should_allow_api_authentication(:delete, | |
|
283 | '/projects/2.xml', | |
|
284 | {}, | |
|
285 | {:success_code => :ok}) | |
|
286 | 226 | |
|
287 |
|
|
|
227 | test "DELETE /projects/:id.xml should delete the project" do | |
|
288 | 228 |
|
|
289 | 229 |
|
|
290 | 230 |
|
|
291 | 231 |
|
|
292 | 232 |
|
|
293 | 233 |
|
|
294 | 234 |
|
|
295 | 235 |
|
|
296 | end | |
|
297 | end |
@@ -1,58 +1,53 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
22 | 22 | :enumerations, :users, :issue_categories, |
|
23 | 23 | :projects_trackers, |
|
24 | 24 | :roles, |
|
25 | 25 | :member_roles, |
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules, |
|
28 | 28 | :queries |
|
29 | 29 | |
|
30 | 30 | def setup |
|
31 | 31 | Setting.rest_api_enabled = '1' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | context "/queries" do | |
|
35 | context "GET" do | |
|
36 | ||
|
37 | should "return queries" do | |
|
34 | test "GET /queries.xml should return queries" do | |
|
38 | 35 |
|
|
39 | 36 | |
|
40 | 37 |
|
|
41 | 38 |
|
|
42 | 39 |
|
|
43 | 40 |
|
|
44 | 41 |
|
|
45 | 42 |
|
|
46 | 43 |
|
|
47 | 44 |
|
|
48 | 45 |
|
|
49 | 46 |
|
|
50 | 47 |
|
|
51 | 48 |
|
|
52 | 49 |
|
|
53 | 50 |
|
|
54 | 51 |
|
|
55 | 52 |
|
|
56 | 53 |
|
|
57 | end | |
|
58 | end |
@@ -1,90 +1,76 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :roles |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | Setting.rest_api_enabled = '1' |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | context "/roles" do | |
|
28 | context "GET" do | |
|
29 | context "xml" do | |
|
30 | should "return the roles" do | |
|
27 | test "GET /roles.xml should return the roles" do | |
|
31 | 28 |
|
|
32 | 29 | |
|
33 | 30 |
|
|
34 | 31 |
|
|
35 | 32 |
|
|
36 | 33 | |
|
37 | 34 |
|
|
38 | 35 |
|
|
39 | 36 |
|
|
40 | 37 |
|
|
41 | 38 |
|
|
42 | 39 |
|
|
43 | 40 |
|
|
44 | 41 |
|
|
45 | 42 |
|
|
46 | 43 |
|
|
47 | 44 |
|
|
48 | 45 |
|
|
49 | 46 |
|
|
50 | 47 |
|
|
51 | end | |
|
52 | 48 | |
|
53 | context "json" do | |
|
54 | should "return the roles" do | |
|
49 | test "GET /roles.json should return the roles" do | |
|
55 | 50 |
|
|
56 | 51 | |
|
57 | 52 |
|
|
58 | 53 |
|
|
59 | 54 |
|
|
60 | 55 | |
|
61 | 56 |
|
|
62 | 57 |
|
|
63 | 58 |
|
|
64 | 59 |
|
|
65 | 60 |
|
|
66 | end | |
|
67 | end | |
|
68 | end | |
|
69 | 61 | |
|
70 | context "/roles/:id" do | |
|
71 | context "GET" do | |
|
72 | context "xml" do | |
|
73 | should "return the role" do | |
|
62 | test "GET /roles/:id.xml should return the role" do | |
|
74 | 63 |
|
|
75 | 64 | |
|
76 | 65 |
|
|
77 | 66 |
|
|
78 | 67 | |
|
79 | 68 |
|
|
80 | 69 |
|
|
81 | 70 |
|
|
82 | 71 |
|
|
83 | 72 |
|
|
84 | 73 |
|
|
85 | 74 |
|
|
86 | 75 |
|
|
87 | 76 | end |
|
88 | end | |
|
89 | end | |
|
90 | end |
@@ -1,164 +1,142 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
22 | 22 | :enumerations, :users, :issue_categories, |
|
23 | 23 | :projects_trackers, |
|
24 | 24 | :roles, |
|
25 | 25 | :member_roles, |
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules, |
|
28 | 28 | :time_entries |
|
29 | 29 | |
|
30 | 30 | def setup |
|
31 | 31 | Setting.rest_api_enabled = '1' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 |
|
|
|
35 | should "return time entries" do | |
|
34 | test "GET /time_entries.xml should return time entries" do | |
|
36 | 35 |
|
|
37 | 36 |
|
|
38 | 37 |
|
|
39 | 38 |
|
|
40 | 39 |
|
|
41 | 40 |
|
|
42 | 41 | |
|
43 | context "with limit" do | |
|
44 | should "return limited results" do | |
|
42 | test "GET /time_entries.xml with limit should return limited results" do | |
|
45 | 43 |
|
|
46 | 44 |
|
|
47 | 45 |
|
|
48 | 46 |
|
|
49 | 47 |
|
|
50 | 48 |
|
|
51 | end | |
|
52 | end | |
|
53 | 49 | |
|
54 |
|
|
|
55 | should "return requested time entry" do | |
|
50 | test "GET /time_entries/:id.xml should return the time entry" do | |
|
56 | 51 |
|
|
57 | 52 |
|
|
58 | 53 |
|
|
59 | 54 |
|
|
60 | 55 |
|
|
61 | 56 |
|
|
62 | end | |
|
63 | 57 | |
|
64 |
|
|
|
65 | context "with issue_id" do | |
|
66 | should "return create time entry" do | |
|
58 | test "POST /time_entries.xml with issue_id should create time entry" do | |
|
67 | 59 |
|
|
68 | 60 |
|
|
69 | 61 |
|
|
70 | 62 |
|
|
71 | 63 |
|
|
72 | 64 | |
|
73 | 65 |
|
|
74 | 66 |
|
|
75 | 67 |
|
|
76 | 68 |
|
|
77 | 69 |
|
|
78 | 70 |
|
|
79 | 71 |
|
|
80 | 72 |
|
|
81 | 73 | |
|
82 |
|
|
|
74 | test "POST /time_entries.xml with issue_id should accept custom fields" do | |
|
83 | 75 |
|
|
84 | 76 | |
|
85 | 77 |
|
|
86 | 78 |
|
|
87 | 79 |
|
|
88 | 80 |
|
|
89 | 81 |
|
|
90 | 82 |
|
|
91 | 83 |
|
|
92 | 84 | |
|
93 | 85 |
|
|
94 | 86 |
|
|
95 | 87 |
|
|
96 | end | |
|
97 | 88 | |
|
98 | context "with project_id" do | |
|
99 | should "return create time entry" do | |
|
89 | test "POST /time_entries.xml with project_id should create time entry" do | |
|
100 | 90 |
|
|
101 | 91 |
|
|
102 | 92 |
|
|
103 | 93 |
|
|
104 | 94 |
|
|
105 | 95 | |
|
106 | 96 |
|
|
107 | 97 |
|
|
108 | 98 |
|
|
109 | 99 |
|
|
110 | 100 |
|
|
111 | 101 |
|
|
112 | 102 |
|
|
113 | 103 |
|
|
114 | end | |
|
115 | 104 | |
|
116 | context "with invalid parameters" do | |
|
117 | should "return errors" do | |
|
105 | test "POST /time_entries.xml with invalid parameters should return errors" do | |
|
118 | 106 |
|
|
119 | 107 |
|
|
120 | 108 |
|
|
121 | 109 |
|
|
122 | 110 |
|
|
123 | 111 | |
|
124 | 112 |
|
|
125 | 113 |
|
|
126 | end | |
|
127 | end | |
|
128 | 114 | |
|
129 | context "PUT /time_entries/2.xml" do | |
|
130 | context "with valid parameters" do | |
|
131 | should "update time entry" do | |
|
115 | test "PUT /time_entries/:id.xml with valid parameters should update time entry" do | |
|
132 | 116 |
|
|
133 | 117 |
|
|
134 | 118 |
|
|
135 | 119 |
|
|
136 | 120 |
|
|
137 | 121 |
|
|
138 | 122 |
|
|
139 | end | |
|
140 | 123 | |
|
141 | context "with invalid parameters" do | |
|
142 | should "return errors" do | |
|
124 | test "PUT /time_entries/:id.xml with invalid parameters should return errors" do | |
|
143 | 125 |
|
|
144 | 126 |
|
|
145 | 127 |
|
|
146 | 128 |
|
|
147 | 129 |
|
|
148 | 130 | |
|
149 | 131 |
|
|
150 | 132 |
|
|
151 | end | |
|
152 | end | |
|
153 | 133 | |
|
154 |
|
|
|
155 | should "destroy time entry" do | |
|
134 | test "DELETE /time_entries/:id.xml should destroy time entry" do | |
|
156 | 135 |
|
|
157 | 136 |
|
|
158 | 137 |
|
|
159 | 138 |
|
|
160 | 139 |
|
|
161 | 140 |
|
|
162 | 141 |
|
|
163 | 142 |
|
|
164 | end |
@@ -1,49 +1,42 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::TokenAuthenticationTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
22 | 22 | :enumerations, :users, :issue_categories, |
|
23 | 23 | :projects_trackers, |
|
24 | 24 | :roles, |
|
25 | 25 | :member_roles, |
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules |
|
28 | 28 | |
|
29 | 29 | def setup |
|
30 | 30 | Setting.rest_api_enabled = '1' |
|
31 | 31 | Setting.login_required = '1' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def teardown |
|
35 | 35 | Setting.rest_api_enabled = '0' |
|
36 | 36 | Setting.login_required = '0' |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | # Using the NewsController because it's a simple API. |
|
40 | context "get /news" do | |
|
41 | context "in :xml format" do | |
|
42 | 40 |
|
|
43 | end | |
|
44 | ||
|
45 | context "in :json format" do | |
|
46 | 41 |
|
|
47 | 42 |
|
|
48 | end | |
|
49 | end |
@@ -1,51 +1,46 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :trackers |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | Setting.rest_api_enabled = '1' |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | context "/trackers" do | |
|
28 | context "GET" do | |
|
29 | ||
|
30 | should "return trackers" do | |
|
27 | test "GET /trackers.xml should return trackers" do | |
|
31 | 28 |
|
|
32 | 29 | |
|
33 | 30 |
|
|
34 | 31 |
|
|
35 | 32 |
|
|
36 | 33 |
|
|
37 | 34 |
|
|
38 | 35 |
|
|
39 | 36 |
|
|
40 | 37 |
|
|
41 | 38 |
|
|
42 | 39 |
|
|
43 | 40 |
|
|
44 | 41 |
|
|
45 | 42 |
|
|
46 | 43 |
|
|
47 | 44 |
|
|
48 | 45 |
|
|
49 | 46 |
|
|
50 | end | |
|
51 | end |
@@ -1,383 +1,327 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :users, :members, :member_roles, :roles, :projects |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | Setting.rest_api_enabled = '1' |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | context "GET /users" do | |
|
28 | 27 |
|
|
29 | 28 |
|
|
30 | end | |
|
29 | should_allow_api_authentication(:post, | |
|
30 | '/users.xml', | |
|
31 | {:user => { | |
|
32 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |
|
33 | :mail => 'foo@example.net', :password => 'secret123' | |
|
34 | }}, | |
|
35 | {:success_code => :created}) | |
|
36 | should_allow_api_authentication(:post, | |
|
37 | '/users.json', | |
|
38 | {:user => { | |
|
39 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |
|
40 | :mail => 'foo@example.net' | |
|
41 | }}, | |
|
42 | {:success_code => :created}) | |
|
43 | should_allow_api_authentication(:put, | |
|
44 | '/users/2.xml', | |
|
45 | {:user => { | |
|
46 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |
|
47 | :mail => 'jsmith@somenet.foo' | |
|
48 | }}, | |
|
49 | {:success_code => :ok}) | |
|
50 | should_allow_api_authentication(:put, | |
|
51 | '/users/2.json', | |
|
52 | {:user => { | |
|
53 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |
|
54 | :mail => 'jsmith@somenet.foo' | |
|
55 | }}, | |
|
56 | {:success_code => :ok}) | |
|
57 | should_allow_api_authentication(:delete, | |
|
58 | '/users/2.xml', | |
|
59 | {}, | |
|
60 | {:success_code => :ok}) | |
|
61 | should_allow_api_authentication(:delete, | |
|
62 | '/users/2.xml', | |
|
63 | {}, | |
|
64 | {:success_code => :ok}) | |
|
31 | 65 | |
|
32 | context "GET /users/2" do | |
|
33 | context ".xml" do | |
|
34 | should "return requested user" do | |
|
66 | test "GET /users/:id.xml should return the user" do | |
|
35 | 67 |
|
|
36 | 68 | |
|
37 | 69 |
|
|
38 | 70 |
|
|
39 | 71 |
|
|
40 | 72 |
|
|
41 | 73 | |
|
42 | context "with include=memberships" do | |
|
43 | should "include memberships" do | |
|
44 | get '/users/2.xml?include=memberships' | |
|
45 | ||
|
46 | assert_response :success | |
|
47 | assert_tag :tag => 'memberships', | |
|
48 | :parent => {:tag => 'user'}, | |
|
49 | :children => {:count => 1} | |
|
50 | end | |
|
51 | end | |
|
52 | end | |
|
53 | ||
|
54 | context ".json" do | |
|
55 | should "return requested user" do | |
|
74 | test "GET /users/:id.json should return the user" do | |
|
56 | 75 |
|
|
57 | 76 | |
|
58 | 77 |
|
|
59 | 78 |
|
|
60 | 79 |
|
|
61 | 80 |
|
|
62 | 81 |
|
|
63 | 82 |
|
|
64 | 83 | |
|
65 | context "with include=memberships" do | |
|
66 |
|
|
|
84 | test "GET /users/:id.xml with include=memberships should include memberships" do | |
|
85 | get '/users/2.xml?include=memberships' | |
|
86 | ||
|
87 | assert_response :success | |
|
88 | assert_tag :tag => 'memberships', | |
|
89 | :parent => {:tag => 'user'}, | |
|
90 | :children => {:count => 1} | |
|
91 | end | |
|
92 | ||
|
93 | test "GET /users/:id.json with include=memberships should include memberships" do | |
|
67 | 94 |
|
|
68 | 95 | |
|
69 | 96 |
|
|
70 | 97 |
|
|
71 | 98 |
|
|
72 | 99 |
|
|
73 | 100 |
|
|
74 | 101 |
|
|
75 | 102 |
|
|
76 | 103 |
|
|
77 | 104 |
|
|
78 | end | |
|
79 | end | |
|
80 | end | |
|
81 | 105 | |
|
82 | context "GET /users/current" do | |
|
83 | context ".xml" do | |
|
84 | should "require authentication" do | |
|
106 | test "GET /users/current.xml should require authentication" do | |
|
85 | 107 |
|
|
86 | 108 | |
|
87 | 109 |
|
|
88 | 110 |
|
|
89 | 111 | |
|
90 |
|
|
|
112 | test "GET /users/current.xml should return current user" do | |
|
91 | 113 |
|
|
92 | 114 | |
|
93 | 115 |
|
|
94 | 116 |
|
|
95 | 117 |
|
|
96 | end | |
|
97 | end | |
|
98 | 118 | |
|
99 | 119 | test "GET /users/:id should not return login for other user" do |
|
100 | 120 | get '/users/3.xml', {}, credentials('jsmith') |
|
101 | 121 | assert_response :success |
|
102 | 122 | assert_no_tag 'user', :child => {:tag => 'login'} |
|
103 | 123 | end |
|
104 | 124 | |
|
105 | 125 | test "GET /users/:id should return login for current user" do |
|
106 | 126 | get '/users/2.xml', {}, credentials('jsmith') |
|
107 | 127 | assert_response :success |
|
108 | 128 | assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'} |
|
109 | 129 | end |
|
110 | 130 | |
|
111 | 131 | test "GET /users/:id should not return api_key for other user" do |
|
112 | 132 | get '/users/3.xml', {}, credentials('jsmith') |
|
113 | 133 | assert_response :success |
|
114 | 134 | assert_no_tag 'user', :child => {:tag => 'api_key'} |
|
115 | 135 | end |
|
116 | 136 | |
|
117 | 137 | test "GET /users/:id should return api_key for current user" do |
|
118 | 138 | get '/users/2.xml', {}, credentials('jsmith') |
|
119 | 139 | assert_response :success |
|
120 | 140 | assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key} |
|
121 | 141 | end |
|
122 | 142 | |
|
123 | 143 | test "GET /users/:id should not return status for standard user" do |
|
124 | 144 | get '/users/3.xml', {}, credentials('jsmith') |
|
125 | 145 | assert_response :success |
|
126 | 146 | assert_no_tag 'user', :child => {:tag => 'status'} |
|
127 | 147 | end |
|
128 | 148 | |
|
129 | 149 | test "GET /users/:id should return status for administrators" do |
|
130 | 150 | get '/users/2.xml', {}, credentials('admin') |
|
131 | 151 | assert_response :success |
|
132 | 152 | assert_tag 'user', :child => {:tag => 'status', :content => User.find(1).status.to_s} |
|
133 | 153 | end |
|
134 | 154 | |
|
135 | context "POST /users" do | |
|
136 | context "with valid parameters" do | |
|
137 | setup do | |
|
138 | @parameters = { | |
|
155 | test "POST /users.xml with valid parameters should create the user" do | |
|
156 | assert_difference('User.count') do | |
|
157 | post '/users.xml', { | |
|
139 | 158 |
|
|
140 | 159 |
|
|
141 | 160 |
|
|
142 |
|
|
|
143 |
|
|
|
144 | } | |
|
145 | end | |
|
146 | ||
|
147 | context ".xml" do | |
|
148 | should_allow_api_authentication(:post, | |
|
149 | '/users.xml', | |
|
150 | {:user => { | |
|
151 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |
|
152 | :mail => 'foo@example.net', :password => 'secret123' | |
|
153 | }}, | |
|
154 | {:success_code => :created}) | |
|
155 | ||
|
156 | should "create a user with the attributes" do | |
|
157 | assert_difference('User.count') do | |
|
158 | post '/users.xml', @parameters, credentials('admin') | |
|
161 | :mail_notification => 'only_assigned'} | |
|
162 | }, | |
|
163 | credentials('admin') | |
|
159 | 164 |
|
|
160 | 165 | |
|
161 | 166 |
|
|
162 | 167 |
|
|
163 | 168 |
|
|
164 | 169 |
|
|
165 | 170 |
|
|
166 | 171 |
|
|
167 | 172 |
|
|
168 | 173 |
|
|
169 | 174 | |
|
170 | 175 |
|
|
171 | 176 |
|
|
172 | 177 |
|
|
173 | 178 |
|
|
174 | end | |
|
175 | ||
|
176 | context ".json" do | |
|
177 | should_allow_api_authentication(:post, | |
|
178 | '/users.json', | |
|
179 | {:user => { | |
|
180 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |
|
181 | :mail => 'foo@example.net' | |
|
182 | }}, | |
|
183 | {:success_code => :created}) | |
|
184 | 179 | |
|
185 | should "create a user with the attributes" do | |
|
180 | test "POST /users.json with valid parameters should create the user" do | |
|
186 | 181 |
|
|
187 | post '/users.json', @parameters, credentials('admin') | |
|
182 | post '/users.json', { | |
|
183 | :user => { | |
|
184 | :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname', | |
|
185 | :mail => 'foo@example.net', :password => 'secret123', | |
|
186 | :mail_notification => 'only_assigned'} | |
|
187 | }, | |
|
188 | credentials('admin') | |
|
188 | 189 |
|
|
189 | 190 | |
|
190 | 191 |
|
|
191 | 192 |
|
|
192 | 193 |
|
|
193 | 194 |
|
|
194 | 195 |
|
|
195 | 196 |
|
|
196 | 197 | |
|
197 | 198 |
|
|
198 | 199 |
|
|
199 | 200 |
|
|
200 | 201 |
|
|
201 | 202 |
|
|
202 | 203 |
|
|
203 | 204 |
|
|
204 | end | |
|
205 | end | |
|
206 | 205 | |
|
207 | context "with invalid parameters" do | |
|
208 | setup do | |
|
209 | @parameters = {:user => {:login => 'foo', :lastname => 'Lastname', :mail => 'foo'}} | |
|
210 | end | |
|
211 | ||
|
212 | context ".xml" do | |
|
213 | should "return errors" do | |
|
206 | test "POST /users.xml with with invalid parameters should return errors" do | |
|
214 | 207 |
|
|
215 | post '/users.xml', @parameters, credentials('admin') | |
|
208 | post '/users.xml', {:user => {:login => 'foo', :lastname => 'Lastname', :mail => 'foo'}}, credentials('admin') | |
|
216 | 209 |
|
|
217 | 210 | |
|
218 | 211 |
|
|
219 | 212 |
|
|
220 | 213 |
|
|
221 | 214 |
|
|
222 | 215 |
|
|
223 | 216 |
|
|
224 | 217 |
|
|
225 | end | |
|
226 | 218 | |
|
227 | context ".json" do | |
|
228 | should "return errors" do | |
|
219 | test "POST /users.json with with invalid parameters should return errors" do | |
|
229 | 220 |
|
|
230 | post '/users.json', @parameters, credentials('admin') | |
|
221 | post '/users.json', {:user => {:login => 'foo', :lastname => 'Lastname', :mail => 'foo'}}, credentials('admin') | |
|
231 | 222 |
|
|
232 | 223 | |
|
233 | 224 |
|
|
234 | 225 |
|
|
235 | 226 |
|
|
236 | 227 |
|
|
237 | 228 |
|
|
238 | 229 |
|
|
239 | 230 |
|
|
240 | end | |
|
241 | end | |
|
242 | end | |
|
243 | 231 | |
|
244 | context "PUT /users/2" do | |
|
245 | context "with valid parameters" do | |
|
246 | setup do | |
|
247 | @parameters = { | |
|
232 | test "PUT /users/:id.xml with valid parameters should update the user" do | |
|
233 | assert_no_difference('User.count') do | |
|
234 | put '/users/2.xml', { | |
|
248 | 235 |
|
|
249 | 236 |
|
|
250 |
|
|
|
251 |
|
|
|
252 | } | |
|
253 | end | |
|
254 | ||
|
255 | context ".xml" do | |
|
256 | should_allow_api_authentication(:put, | |
|
257 | '/users/2.xml', | |
|
258 | {:user => { | |
|
259 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |
|
260 | :mail => 'jsmith@somenet.foo' | |
|
261 | }}, | |
|
262 | {:success_code => :ok}) | |
|
263 | ||
|
264 | should "update user with the attributes" do | |
|
265 | assert_no_difference('User.count') do | |
|
266 | put '/users/2.xml', @parameters, credentials('admin') | |
|
237 | :mail => 'jsmith@somenet.foo'} | |
|
238 | }, | |
|
239 | credentials('admin') | |
|
267 | 240 |
|
|
268 | 241 | |
|
269 | 242 |
|
|
270 | 243 |
|
|
271 | 244 |
|
|
272 | 245 |
|
|
273 | 246 |
|
|
274 | 247 |
|
|
275 | 248 | |
|
276 | 249 |
|
|
277 | 250 |
|
|
278 | 251 |
|
|
279 | end | |
|
280 | 252 | |
|
281 | context ".json" do | |
|
282 | should_allow_api_authentication(:put, | |
|
283 | '/users/2.json', | |
|
284 | {:user => { | |
|
285 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |
|
286 | :mail => 'jsmith@somenet.foo' | |
|
287 | }}, | |
|
288 | {:success_code => :ok}) | |
|
289 | ||
|
290 | should "update user with the attributes" do | |
|
253 | test "PUT /users/:id.json with valid parameters should update the user" do | |
|
291 | 254 |
|
|
292 | put '/users/2.json', @parameters, credentials('admin') | |
|
255 | put '/users/2.json', { | |
|
256 | :user => { | |
|
257 | :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed', | |
|
258 | :mail => 'jsmith@somenet.foo'} | |
|
259 | }, | |
|
260 | credentials('admin') | |
|
293 | 261 |
|
|
294 | 262 | |
|
295 | 263 |
|
|
296 | 264 |
|
|
297 | 265 |
|
|
298 | 266 |
|
|
299 | 267 |
|
|
300 | 268 |
|
|
301 | 269 | |
|
302 | 270 |
|
|
303 | 271 |
|
|
304 | 272 |
|
|
305 | end | |
|
306 | end | |
|
307 | 273 | |
|
308 |
|
|
|
309 | setup do | |
|
310 | @parameters = { | |
|
274 | test "PUT /users/:id.xml with invalid parameters" do | |
|
275 | assert_no_difference('User.count') do | |
|
276 | put '/users/2.xml', { | |
|
311 | 277 |
|
|
312 | 278 |
|
|
313 |
|
|
|
314 |
|
|
|
315 | } | |
|
316 | end | |
|
317 | ||
|
318 | context ".xml" do | |
|
319 | should "return errors" do | |
|
320 | assert_no_difference('User.count') do | |
|
321 | put '/users/2.xml', @parameters, credentials('admin') | |
|
279 | :mail => 'foo'} | |
|
280 | }, | |
|
281 | credentials('admin') | |
|
322 | 282 |
|
|
323 | 283 | |
|
324 | 284 |
|
|
325 | 285 |
|
|
326 | 286 |
|
|
327 | 287 |
|
|
328 | 288 |
|
|
329 | 289 |
|
|
330 | 290 |
|
|
331 | end | |
|
332 | 291 | |
|
333 | context ".json" do | |
|
334 | should "return errors" do | |
|
292 | test "PUT /users/:id.json with invalid parameters" do | |
|
335 | 293 |
|
|
336 | put '/users/2.json', @parameters, credentials('admin') | |
|
294 | put '/users/2.json', { | |
|
295 | :user => { | |
|
296 | :login => 'jsmith', :firstname => '', :lastname => 'Lastname', | |
|
297 | :mail => 'foo'} | |
|
298 | }, | |
|
299 | credentials('admin') | |
|
337 | 300 |
|
|
338 | 301 | |
|
339 | 302 |
|
|
340 | 303 |
|
|
341 | 304 |
|
|
342 | 305 |
|
|
343 | 306 |
|
|
344 | 307 |
|
|
345 | 308 |
|
|
346 | end | |
|
347 | end | |
|
348 | end | |
|
349 | ||
|
350 | context "DELETE /users/2" do | |
|
351 | context ".xml" do | |
|
352 | should_allow_api_authentication(:delete, | |
|
353 | '/users/2.xml', | |
|
354 | {}, | |
|
355 | {:success_code => :ok}) | |
|
356 | 309 | |
|
357 |
|
|
|
310 | test "DELETE /users/:id.xml should delete the user" do | |
|
358 | 311 |
|
|
359 | 312 |
|
|
360 | 313 |
|
|
361 | 314 | |
|
362 | 315 |
|
|
363 | 316 |
|
|
364 | 317 |
|
|
365 | end | |
|
366 | 318 | |
|
367 | context ".json" do | |
|
368 | should_allow_api_authentication(:delete, | |
|
369 | '/users/2.xml', | |
|
370 | {}, | |
|
371 | {:success_code => :ok}) | |
|
372 | ||
|
373 | should "delete user" do | |
|
319 | test "DELETE /users/:id.json should delete the user" do | |
|
374 | 320 |
|
|
375 | 321 |
|
|
376 | 322 |
|
|
377 | 323 | |
|
378 | 324 |
|
|
379 | 325 |
|
|
380 | 326 |
|
|
381 | 327 |
|
|
382 | end | |
|
383 | end |
@@ -1,158 +1,142 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base |
|
21 | 21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
22 | 22 | :enumerations, :users, :issue_categories, |
|
23 | 23 | :projects_trackers, |
|
24 | 24 | :roles, |
|
25 | 25 | :member_roles, |
|
26 | 26 | :members, |
|
27 | 27 | :enabled_modules, |
|
28 | 28 | :versions |
|
29 | 29 | |
|
30 | 30 | def setup |
|
31 | 31 | Setting.rest_api_enabled = '1' |
|
32 | 32 | end |
|
33 | 33 | |
|
34 |
|
|
|
35 | context "GET" do | |
|
36 | should "return project versions" do | |
|
34 | test "GET /projects/:project_id/versions.xml should return project versions" do | |
|
37 | 35 |
|
|
38 | 36 | |
|
39 | 37 |
|
|
40 | 38 |
|
|
41 | 39 |
|
|
42 | 40 |
|
|
43 | 41 |
|
|
44 | 42 |
|
|
45 | 43 |
|
|
46 | 44 |
|
|
47 | 45 |
|
|
48 | 46 |
|
|
49 | 47 |
|
|
50 | 48 |
|
|
51 | 49 |
|
|
52 | 50 |
|
|
53 | 51 |
|
|
54 | 52 |
|
|
55 | end | |
|
56 | 53 | |
|
57 | context "POST" do | |
|
58 | should "create the version" do | |
|
54 | test "POST /projects/:project_id/versions.xml should create the version" do | |
|
59 | 55 |
|
|
60 | 56 |
|
|
61 | 57 |
|
|
62 | 58 | |
|
63 | 59 |
|
|
64 | 60 |
|
|
65 | 61 | |
|
66 | 62 |
|
|
67 | 63 |
|
|
68 | 64 |
|
|
69 | 65 |
|
|
70 | 66 | |
|
71 |
|
|
|
67 | test "POST /projects/:project_id/versions.xml should create the version with due date" do | |
|
72 | 68 |
|
|
73 | 69 |
|
|
74 | 70 |
|
|
75 | 71 | |
|
76 | 72 |
|
|
77 | 73 |
|
|
78 | 74 |
|
|
79 | 75 | |
|
80 | 76 |
|
|
81 | 77 |
|
|
82 | 78 |
|
|
83 | 79 |
|
|
84 | 80 | |
|
85 |
|
|
|
81 | test "POST /projects/:project_id/versions.xml should create the version with custom fields" do | |
|
86 | 82 |
|
|
87 | 83 | |
|
88 | 84 |
|
|
89 | 85 |
|
|
90 | 86 |
|
|
91 | 87 |
|
|
92 | 88 |
|
|
93 | 89 |
|
|
94 | 90 |
|
|
95 | 91 |
|
|
96 | 92 |
|
|
97 | 93 |
|
|
98 | 94 | |
|
99 | 95 |
|
|
100 | 96 |
|
|
101 | 97 |
|
|
102 | 98 | |
|
103 | 99 |
|
|
104 | 100 |
|
|
105 | 101 |
|
|
106 | 102 |
|
|
107 | 103 | |
|
108 | context "with failure" do | |
|
109 | should "return the errors" do | |
|
104 | test "POST /projects/:project_id/versions.xml with failure should return the errors" do | |
|
110 | 105 |
|
|
111 | 106 |
|
|
112 | 107 |
|
|
113 | 108 | |
|
114 | 109 |
|
|
115 | 110 |
|
|
116 | 111 |
|
|
117 | end | |
|
118 | end | |
|
119 | end | |
|
120 | 112 | |
|
121 | context "/versions/:id" do | |
|
122 | context "GET" do | |
|
123 | should "return the version" do | |
|
113 | test "GET /versions/:id.xml should return the version" do | |
|
124 | 114 |
|
|
125 | 115 | |
|
126 | 116 |
|
|
127 | 117 |
|
|
128 | 118 |
|
|
129 | 119 |
|
|
130 | 120 |
|
|
131 | 121 |
|
|
132 | 122 |
|
|
133 | 123 |
|
|
134 | end | |
|
135 | 124 | |
|
136 | context "PUT" do | |
|
137 | should "update the version" do | |
|
125 | test "PUT /versions/:id.xml should update the version" do | |
|
138 | 126 |
|
|
139 | 127 | |
|
140 | 128 |
|
|
141 | 129 |
|
|
142 | 130 |
|
|
143 | 131 |
|
|
144 | end | |
|
145 | 132 | |
|
146 | context "DELETE" do | |
|
147 | should "destroy the version" do | |
|
133 | test "DELETE /versions/:id.xml should destroy the version" do | |
|
148 | 134 |
|
|
149 | 135 |
|
|
150 | 136 |
|
|
151 | 137 | |
|
152 | 138 |
|
|
153 | 139 |
|
|
154 | 140 |
|
|
155 | 141 |
|
|
156 | 142 |
|
|
157 | end | |
|
158 | end |
General Comments 0
You need to be logged in to leave comments.
Login now