Mercurial > hg > soundsoftware-site
comparison test/functional/repositories_cvs_controller_test.rb @ 442:753f1380d6bc cannam
Merge from branch "redmine-1.2"
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:41:04 +0100 |
parents | cbce1fd3b1b7 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
252:adc8466df404 | 442:753f1380d6bc |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 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.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
37 @response = ActionController::TestResponse.new | 37 @response = ActionController::TestResponse.new |
38 Setting.default_language = 'en' | 38 Setting.default_language = 'en' |
39 User.current = nil | 39 User.current = nil |
40 | 40 |
41 @project = Project.find(PRJ_ID) | 41 @project = Project.find(PRJ_ID) |
42 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID), | 42 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID), |
43 :root_url => REPOSITORY_PATH, | 43 :root_url => REPOSITORY_PATH, |
44 :url => MODULE_NAME, | 44 :url => MODULE_NAME, |
45 :log_encoding => 'UTF-8') | 45 :log_encoding => 'UTF-8') |
46 assert @repository | 46 assert @repository |
47 end | 47 end |
48 | 48 |
49 if File.directory?(REPOSITORY_PATH) | 49 if File.directory?(REPOSITORY_PATH) |
50 def test_show | |
51 @repository.fetch_changesets | |
52 @repository.reload | |
53 get :show, :id => PRJ_ID | |
54 assert_response :success | |
55 assert_template 'show' | |
56 assert_not_nil assigns(:entries) | |
57 assert_not_nil assigns(:changesets) | |
58 end | |
59 | |
60 def test_browse_root | 50 def test_browse_root |
61 @repository.fetch_changesets | 51 @repository.fetch_changesets |
62 @repository.reload | 52 @repository.reload |
63 get :show, :id => PRJ_ID | 53 get :show, :id => PRJ_ID |
64 assert_response :success | 54 assert_response :success |
65 assert_template 'show' | 55 assert_template 'show' |
66 assert_not_nil assigns(:entries) | 56 assert_not_nil assigns(:entries) |
67 assert_equal 3, assigns(:entries).size | 57 assert_equal 3, assigns(:entries).size |
68 | 58 |
69 entry = assigns(:entries).detect {|e| e.name == 'images'} | 59 entry = assigns(:entries).detect {|e| e.name == 'images'} |
70 assert_equal 'dir', entry.kind | 60 assert_equal 'dir', entry.kind |
71 | 61 |
72 entry = assigns(:entries).detect {|e| e.name == 'README'} | 62 entry = assigns(:entries).detect {|e| e.name == 'README'} |
73 assert_equal 'file', entry.kind | 63 assert_equal 'file', entry.kind |
74 end | 64 |
75 | 65 assert_not_nil assigns(:changesets) |
66 assigns(:changesets).size > 0 | |
67 end | |
68 | |
76 def test_browse_directory | 69 def test_browse_directory |
77 @repository.fetch_changesets | 70 @repository.fetch_changesets |
78 @repository.reload | 71 @repository.reload |
79 get :show, :id => PRJ_ID, :path => ['images'] | 72 get :show, :id => PRJ_ID, :path => ['images'] |
80 assert_response :success | 73 assert_response :success |
84 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | 77 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
85 assert_not_nil entry | 78 assert_not_nil entry |
86 assert_equal 'file', entry.kind | 79 assert_equal 'file', entry.kind |
87 assert_equal 'images/edit.png', entry.path | 80 assert_equal 'images/edit.png', entry.path |
88 end | 81 end |
89 | 82 |
90 def test_browse_at_given_revision | 83 def test_browse_at_given_revision |
91 @repository.fetch_changesets | 84 @repository.fetch_changesets |
92 @repository.reload | 85 @repository.reload |
93 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | 86 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 |
94 assert_response :success | 87 assert_response :success |
95 assert_template 'show' | 88 assert_template 'show' |
96 assert_not_nil assigns(:entries) | 89 assert_not_nil assigns(:entries) |
97 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | 90 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
98 end | 91 end |
99 | 92 |
100 def test_entry | 93 def test_entry |
101 @repository.fetch_changesets | 94 @repository.fetch_changesets |
102 @repository.reload | 95 @repository.reload |
103 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | 96 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
104 assert_response :success | 97 assert_response :success |
105 assert_template 'entry' | 98 assert_template 'entry' |
106 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/}, | 99 assert_no_tag :tag => 'td', |
107 :content => /before_filter/ | 100 :attributes => { :class => /line-code/}, |
108 end | 101 :content => /before_filter/ |
109 | 102 end |
103 | |
110 def test_entry_at_given_revision | 104 def test_entry_at_given_revision |
111 # changesets must be loaded | 105 # changesets must be loaded |
112 @repository.fetch_changesets | 106 @repository.fetch_changesets |
113 @repository.reload | 107 @repository.reload |
114 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | 108 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 |
115 assert_response :success | 109 assert_response :success |
116 assert_template 'entry' | 110 assert_template 'entry' |
117 # this line was removed in r3 | 111 # this line was removed in r3 |
118 assert_tag :tag => 'td', :attributes => { :class => /line-code/}, | 112 assert_tag :tag => 'td', |
119 :content => /before_filter/ | 113 :attributes => { :class => /line-code/}, |
120 end | 114 :content => /before_filter/ |
121 | 115 end |
116 | |
122 def test_entry_not_found | 117 def test_entry_not_found |
123 @repository.fetch_changesets | 118 @repository.fetch_changesets |
124 @repository.reload | 119 @repository.reload |
125 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] | 120 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] |
126 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | 121 assert_tag :tag => 'p', |
127 :content => /The entry or revision was not found in the repository/ | 122 :attributes => { :id => /errorExplanation/ }, |
128 end | 123 :content => /The entry or revision was not found in the repository/ |
129 | 124 end |
125 | |
130 def test_entry_download | 126 def test_entry_download |
131 @repository.fetch_changesets | 127 @repository.fetch_changesets |
132 @repository.reload | 128 @repository.reload |
133 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | 129 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
134 assert_response :success | 130 assert_response :success |
141 assert_response :success | 137 assert_response :success |
142 assert_template 'show' | 138 assert_template 'show' |
143 assert_not_nil assigns(:entry) | 139 assert_not_nil assigns(:entry) |
144 assert_equal 'sources', assigns(:entry).name | 140 assert_equal 'sources', assigns(:entry).name |
145 end | 141 end |
146 | 142 |
147 def test_diff | 143 def test_diff |
148 @repository.fetch_changesets | 144 @repository.fetch_changesets |
149 @repository.reload | 145 @repository.reload |
150 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline' | 146 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline' |
151 assert_response :success | 147 assert_response :success |
152 assert_template 'diff' | 148 assert_template 'diff' |
153 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, | 149 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, |
154 :content => /watched.remove_watcher/ | 150 :content => /before_filter :require_login/ |
155 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | 151 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, |
156 :content => /watched.remove_all_watcher/ | 152 :content => /with one change/ |
157 end | 153 end |
158 | 154 |
159 def test_diff_new_files | 155 def test_diff_new_files |
160 @repository.fetch_changesets | 156 @repository.fetch_changesets |
161 @repository.reload | 157 @repository.reload |
162 get :diff, :id => PRJ_ID, :rev => 1, :type => 'inline' | 158 get :diff, :id => PRJ_ID, :rev => 1, :type => 'inline' |
163 assert_response :success | 159 assert_response :success |
169 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | 165 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
170 :content => /test\/images\/delete.png / | 166 :content => /test\/images\/delete.png / |
171 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | 167 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
172 :content => /test\/images\/edit.png/ | 168 :content => /test\/images\/edit.png/ |
173 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | 169 assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
174 :content => /test\/sources\/watchers_controller.rb/ | 170 :content => /test\/sources\/watchers_controller.rb/ |
175 end | 171 end |
176 | 172 |
177 def test_annotate | 173 def test_annotate |
178 @repository.fetch_changesets | 174 @repository.fetch_changesets |
179 @repository.reload | 175 @repository.reload |
180 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | 176 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
181 assert_response :success | 177 assert_response :success |
182 assert_template 'annotate' | 178 assert_template 'annotate' |
183 # 1.1 line | 179 # 1.1 line |
184 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | 180 assert_tag :tag => 'th', |
185 :content => '18', | 181 :attributes => { :class => 'line-num' }, |
186 :sibling => { :tag => 'td', :attributes => { :class => 'revision' }, | 182 :content => '18', |
187 :content => /1.1/, | 183 :sibling => { |
188 :sibling => { :tag => 'td', :attributes => { :class => 'author' }, | 184 :tag => 'td', |
189 :content => /LANG/ | 185 :attributes => { :class => 'revision' }, |
190 } | 186 :content => /1.1/, |
191 } | 187 :sibling => { |
188 :tag => 'td', | |
189 :attributes => { :class => 'author' }, | |
190 :content => /LANG/ | |
191 } | |
192 } | |
192 # 1.2 line | 193 # 1.2 line |
193 assert_tag :tag => 'th', :attributes => { :class => 'line-num' }, | 194 assert_tag :tag => 'th', |
194 :content => '32', | 195 :attributes => { :class => 'line-num' }, |
195 :sibling => { :tag => 'td', :attributes => { :class => 'revision' }, | 196 :content => '32', |
196 :content => /1.2/, | 197 :sibling => { |
197 :sibling => { :tag => 'td', :attributes => { :class => 'author' }, | 198 :tag => 'td', |
198 :content => /LANG/ | 199 :attributes => { :class => 'revision' }, |
199 } | 200 :content => /1.2/, |
200 } | 201 :sibling => { |
202 :tag => 'td', | |
203 :attributes => { :class => 'author' }, | |
204 :content => /LANG/ | |
205 } | |
206 } | |
201 end | 207 end |
202 else | 208 else |
203 puts "CVS test repository NOT FOUND. Skipping functional tests !!!" | 209 puts "CVS test repository NOT FOUND. Skipping functional tests !!!" |
204 def test_fake; assert true end | 210 def test_fake; assert true end |
205 end | 211 end |