##// END OF EJS Templates
Fixes a test failure with svn < 1.5 (#2455)....
Jean-Philippe Lang -
r2247:15996c348d5a
parent child
Show More
@@ -1,179 +1,181
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
19 19 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
25 25 fixtures :projects, :users, :roles, :members, :enabled_modules,
26 26 :repositories, :issues, :issue_statuses, :changesets, :changes,
27 27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
28 28
29 29 # No '..' in the repository path for svn
30 30 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
31 31
32 32 def setup
33 33 @controller = RepositoriesController.new
34 34 @request = ActionController::TestRequest.new
35 35 @response = ActionController::TestResponse.new
36 36 Setting.default_language = 'en'
37 37 User.current = nil
38 38 end
39 39
40 40 if File.directory?(REPOSITORY_PATH)
41 41 def test_show
42 42 get :show, :id => 1
43 43 assert_response :success
44 44 assert_template 'show'
45 45 assert_not_nil assigns(:entries)
46 46 assert_not_nil assigns(:changesets)
47 47 end
48 48
49 49 def test_browse_root
50 50 get :browse, :id => 1
51 51 assert_response :success
52 52 assert_template 'browse'
53 53 assert_not_nil assigns(:entries)
54 54 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
55 55 assert_equal 'dir', entry.kind
56 56 end
57 57
58 58 def test_browse_directory
59 59 get :browse, :id => 1, :path => ['subversion_test']
60 60 assert_response :success
61 61 assert_template 'browse'
62 62 assert_not_nil assigns(:entries)
63 63 assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name)
64 64 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
65 65 assert_equal 'file', entry.kind
66 66 assert_equal 'subversion_test/helloworld.c', entry.path
67 67 end
68 68
69 69 def test_browse_at_given_revision
70 70 get :browse, :id => 1, :path => ['subversion_test'], :rev => 4
71 71 assert_response :success
72 72 assert_template 'browse'
73 73 assert_not_nil assigns(:entries)
74 74 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name)
75 75 end
76 76
77 77 def test_changes
78 78 get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
79 79 assert_response :success
80 80 assert_template 'changes'
81 # svn properties
82 assert_not_nil assigns(:properties)
83 assert_equal 'native', assigns(:properties)['svn:eol-style']
84 assert_tag :ul,
85 :child => { :tag => 'li',
86 :child => { :tag => 'b', :content => 'svn:eol-style' },
87 :child => { :tag => 'span', :content => 'native' } }
81 # svn properties displayed with svn >= 1.5 only
82 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
83 assert_not_nil assigns(:properties)
84 assert_equal 'native', assigns(:properties)['svn:eol-style']
85 assert_tag :ul,
86 :child => { :tag => 'li',
87 :child => { :tag => 'b', :content => 'svn:eol-style' },
88 :child => { :tag => 'span', :content => 'native' } }
89 end
88 90 end
89 91
90 92 def test_entry
91 93 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
92 94 assert_response :success
93 95 assert_template 'entry'
94 96 end
95 97
96 98 def test_entry_at_given_revision
97 99 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
98 100 assert_response :success
99 101 assert_template 'entry'
100 102 # this line was removed in r3 and file was moved in r6
101 103 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
102 104 :content => /Here's the code/
103 105 end
104 106
105 107 def test_entry_not_found
106 108 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
107 109 assert_tag :tag => 'div', :attributes => { :class => /error/ },
108 110 :content => /The entry or revision was not found in the repository/
109 111 end
110 112
111 113 def test_entry_download
112 114 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
113 115 assert_response :success
114 116 end
115 117
116 118 def test_directory_entry
117 119 get :entry, :id => 1, :path => ['subversion_test', 'folder']
118 120 assert_response :success
119 121 assert_template 'browse'
120 122 assert_not_nil assigns(:entry)
121 123 assert_equal 'folder', assigns(:entry).name
122 124 end
123 125
124 126 def test_revision
125 127 get :revision, :id => 1, :rev => 2
126 128 assert_response :success
127 129 assert_template 'revision'
128 130 assert_tag :tag => 'ul',
129 131 :child => { :tag => 'li',
130 132 # link to the entry at rev 2
131 133 :child => { :tag => 'a',
132 134 :attributes => {:href => '/repositories/entry/ecookbook/test/some/path/in/the/repo?rev=2'},
133 135 :content => 'repo',
134 136 # link to partial diff
135 137 :sibling => { :tag => 'a',
136 138 :attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' }
137 139 }
138 140 }
139 141 }
140 142 end
141 143
142 144 def test_revision_with_repository_pointing_to_a_subdirectory
143 145 r = Project.find(1).repository
144 146 # Changes repository url to a subdirectory
145 147 r.update_attribute :url, (r.url + '/test/some')
146 148
147 149 get :revision, :id => 1, :rev => 2
148 150 assert_response :success
149 151 assert_template 'revision'
150 152 assert_tag :tag => 'ul',
151 153 :child => { :tag => 'li',
152 154 # link to the entry at rev 2
153 155 :child => { :tag => 'a',
154 156 :attributes => {:href => '/repositories/entry/ecookbook/path/in/the/repo?rev=2'},
155 157 :content => 'repo',
156 158 # link to partial diff
157 159 :sibling => { :tag => 'a',
158 160 :attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' }
159 161 }
160 162 }
161 163 }
162 164 end
163 165
164 166 def test_diff
165 167 get :diff, :id => 1, :rev => 3
166 168 assert_response :success
167 169 assert_template 'diff'
168 170 end
169 171
170 172 def test_annotate
171 173 get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
172 174 assert_response :success
173 175 assert_template 'annotate'
174 176 end
175 177 else
176 178 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
177 179 def test_fake; assert true end
178 180 end
179 181 end
General Comments 0
You need to be logged in to leave comments. Login now