Mercurial > hg > soundsoftware-site
comparison .svn/pristine/cb/cbe1dce477834bd2a42f82303d5614d786dd17e7.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::IssueRelationsTest < 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 :issue_relations | |
29 | |
30 def setup | |
31 Setting.rest_api_enabled = '1' | |
32 end | |
33 | |
34 test "GET /issues/:issue_id/relations.xml should return issue relations" do | |
35 get '/issues/9/relations.xml', {}, credentials('jsmith') | |
36 | |
37 assert_response :success | |
38 assert_equal 'application/xml', @response.content_type | |
39 | |
40 assert_tag :tag => 'relations', | |
41 :attributes => { :type => 'array' }, | |
42 :child => { | |
43 :tag => 'relation', | |
44 :child => { | |
45 :tag => 'id', | |
46 :content => '1' | |
47 } | |
48 } | |
49 end | |
50 | |
51 test "POST /issues/:issue_id/relations.xml should create the relation" do | |
52 assert_difference('IssueRelation.count') do | |
53 post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, credentials('jsmith') | |
54 end | |
55 | |
56 relation = IssueRelation.order('id DESC').first | |
57 assert_equal 2, relation.issue_from_id | |
58 assert_equal 7, relation.issue_to_id | |
59 assert_equal 'relates', relation.relation_type | |
60 | |
61 assert_response :created | |
62 assert_equal 'application/xml', @response.content_type | |
63 assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s} | |
64 end | |
65 | |
66 test "POST /issues/:issue_id/relations.xml with failure should return errors" do | |
67 assert_no_difference('IssueRelation.count') do | |
68 post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, credentials('jsmith') | |
69 end | |
70 | |
71 assert_response :unprocessable_entity | |
72 assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/} | |
73 end | |
74 | |
75 test "GET /relations/:id.xml should return the relation" do | |
76 get '/relations/2.xml', {}, credentials('jsmith') | |
77 | |
78 assert_response :success | |
79 assert_equal 'application/xml', @response.content_type | |
80 assert_tag 'relation', :child => {:tag => 'id', :content => '2'} | |
81 end | |
82 | |
83 test "DELETE /relations/:id.xml should delete the relation" do | |
84 assert_difference('IssueRelation.count', -1) do | |
85 delete '/relations/2.xml', {}, credentials('jsmith') | |
86 end | |
87 | |
88 assert_response :ok | |
89 assert_equal '', @response.body | |
90 assert_nil IssueRelation.find_by_id(2) | |
91 end | |
92 end |