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