##// END OF EJS Templates
remove trailing white-spaces from test/integration/api_test/issue_relations_test.rb....
Toshi MARUYAMA -
r6811:e103d11178e5
parent child
Show More
@@ -1,102 +1,102
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 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 ApiTest::IssueRelationsTest < ActionController::IntegrationTest
21 21 fixtures :all
22 22
23 23 def setup
24 24 Setting.rest_api_enabled = '1'
25 25 end
26 26
27 27 context "/issues/:issue_id/relations" do
28 28 context "GET" do
29 29 should "return issue relations" do
30 30 get '/issues/9/relations.xml', {}, :authorization => credentials('jsmith')
31
31
32 32 assert_response :success
33 33 assert_equal 'application/xml', @response.content_type
34
34
35 35 assert_tag :tag => 'relations',
36 36 :attributes => { :type => 'array' },
37 37 :child => {
38 38 :tag => 'relation',
39 39 :child => {
40 40 :tag => 'id',
41 41 :content => '1'
42 42 }
43 43 }
44 44 end
45 45 end
46
46
47 47 context "POST" do
48 48 should "create a relation" do
49 49 assert_difference('IssueRelation.count') do
50 50 post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, :authorization => credentials('jsmith')
51 51 end
52
52
53 53 relation = IssueRelation.first(:order => 'id DESC')
54 54 assert_equal 2, relation.issue_from_id
55 55 assert_equal 7, relation.issue_to_id
56 56 assert_equal 'relates', relation.relation_type
57
57
58 58 assert_response :created
59 59 assert_equal 'application/xml', @response.content_type
60 60 assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
61 61 end
62
62
63 63 context "with failure" do
64 64 should "return the errors" do
65 65 assert_no_difference('IssueRelation.count') do
66 66 post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, :authorization => credentials('jsmith')
67 67 end
68 68
69 69 assert_response :unprocessable_entity
70 70 assert_tag :errors, :child => {:tag => 'error', :content => 'relation_type is not included in the list'}
71 71 end
72 72 end
73 73 end
74 74 end
75
75
76 76 context "/relations/:id" do
77 77 context "GET" do
78 78 should "return the relation" do
79 79 get '/relations/2.xml', {}, :authorization => credentials('jsmith')
80
80
81 81 assert_response :success
82 82 assert_equal 'application/xml', @response.content_type
83 83 assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
84 84 end
85 85 end
86
86
87 87 context "DELETE" do
88 88 should "delete the relation" do
89 89 assert_difference('IssueRelation.count', -1) do
90 90 delete '/relations/2.xml', {}, :authorization => credentials('jsmith')
91 91 end
92
92
93 93 assert_response :ok
94 94 assert_nil IssueRelation.find_by_id(2)
95 95 end
96 96 end
97 97 end
98 98
99 99 def credentials(user, password=nil)
100 100 ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)
101 101 end
102 102 end
General Comments 0
You need to be logged in to leave comments. Login now