@@ -27,6 +27,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
27 | # No '..' in the repository path |
|
27 | # No '..' in the repository path | |
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
|
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' | |
29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
|
30 | PRJ_ID = 3 | |||
30 |
|
31 | |||
31 | def setup |
|
32 | def setup | |
32 | @controller = RepositoriesController.new |
|
33 | @controller = RepositoriesController.new | |
@@ -45,7 +46,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
45 | def test_browse_root |
|
46 | def test_browse_root | |
46 | @repository.fetch_changesets |
|
47 | @repository.fetch_changesets | |
47 | @repository.reload |
|
48 | @repository.reload | |
48 |
get :show, :id => |
|
49 | get :show, :id => PRJ_ID | |
49 | assert_response :success |
|
50 | assert_response :success | |
50 | assert_template 'show' |
|
51 | assert_template 'show' | |
51 | assert_not_nil assigns(:entries) |
|
52 | assert_not_nil assigns(:entries) | |
@@ -66,7 +67,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
66 | def test_browse_branch |
|
67 | def test_browse_branch | |
67 | @repository.fetch_changesets |
|
68 | @repository.fetch_changesets | |
68 | @repository.reload |
|
69 | @repository.reload | |
69 |
get :show, :id => |
|
70 | get :show, :id => PRJ_ID, :rev => 'test_branch' | |
70 | assert_response :success |
|
71 | assert_response :success | |
71 | assert_template 'show' |
|
72 | assert_template 'show' | |
72 | assert_not_nil assigns(:entries) |
|
73 | assert_not_nil assigns(:entries) | |
@@ -86,7 +87,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
86 | "tag00.lightweight", |
|
87 | "tag00.lightweight", | |
87 | "tag01.annotated", |
|
88 | "tag01.annotated", | |
88 | ].each do |t1| |
|
89 | ].each do |t1| | |
89 |
get :show, :id => |
|
90 | get :show, :id => PRJ_ID, :rev => t1 | |
90 | assert_response :success |
|
91 | assert_response :success | |
91 | assert_template 'show' |
|
92 | assert_template 'show' | |
92 | assert_not_nil assigns(:entries) |
|
93 | assert_not_nil assigns(:entries) | |
@@ -99,7 +100,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
99 | def test_browse_directory |
|
100 | def test_browse_directory | |
100 | @repository.fetch_changesets |
|
101 | @repository.fetch_changesets | |
101 | @repository.reload |
|
102 | @repository.reload | |
102 |
get :show, :id => |
|
103 | get :show, :id => PRJ_ID, :path => ['images'] | |
103 | assert_response :success |
|
104 | assert_response :success | |
104 | assert_template 'show' |
|
105 | assert_template 'show' | |
105 | assert_not_nil assigns(:entries) |
|
106 | assert_not_nil assigns(:entries) | |
@@ -115,7 +116,8 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
115 | def test_browse_at_given_revision |
|
116 | def test_browse_at_given_revision | |
116 | @repository.fetch_changesets |
|
117 | @repository.fetch_changesets | |
117 | @repository.reload |
|
118 | @repository.reload | |
118 |
get :show, :id => |
|
119 | get :show, :id => PRJ_ID, :path => ['images'], | |
|
120 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |||
119 | assert_response :success |
|
121 | assert_response :success | |
120 | assert_template 'show' |
|
122 | assert_template 'show' | |
121 | assert_not_nil assigns(:entries) |
|
123 | assert_not_nil assigns(:entries) | |
@@ -125,14 +127,14 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
125 | end |
|
127 | end | |
126 |
|
128 | |||
127 | def test_changes |
|
129 | def test_changes | |
128 |
get :changes, :id => |
|
130 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
129 | assert_response :success |
|
131 | assert_response :success | |
130 | assert_template 'changes' |
|
132 | assert_template 'changes' | |
131 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
133 | assert_tag :tag => 'h2', :content => 'edit.png' | |
132 | end |
|
134 | end | |
133 |
|
135 | |||
134 | def test_entry_show |
|
136 | def test_entry_show | |
135 |
get :entry, :id => |
|
137 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
136 | assert_response :success |
|
138 | assert_response :success | |
137 | assert_template 'entry' |
|
139 | assert_template 'entry' | |
138 | # Line 19 |
|
140 | # Line 19 | |
@@ -143,14 +145,15 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
143 | end |
|
145 | end | |
144 |
|
146 | |||
145 | def test_entry_download |
|
147 | def test_entry_download | |
146 |
get :entry, :id => |
|
148 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], | |
|
149 | :format => 'raw' | |||
147 | assert_response :success |
|
150 | assert_response :success | |
148 | # File content |
|
151 | # File content | |
149 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
152 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
150 | end |
|
153 | end | |
151 |
|
154 | |||
152 | def test_directory_entry |
|
155 | def test_directory_entry | |
153 |
get :entry, :id => |
|
156 | get :entry, :id => PRJ_ID, :path => ['sources'] | |
154 | assert_response :success |
|
157 | assert_response :success | |
155 | assert_template 'show' |
|
158 | assert_template 'show' | |
156 | assert_not_nil assigns(:entry) |
|
159 | assert_not_nil assigns(:entry) | |
@@ -160,9 +163,8 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
160 | def test_diff |
|
163 | def test_diff | |
161 | @repository.fetch_changesets |
|
164 | @repository.fetch_changesets | |
162 | @repository.reload |
|
165 | @repository.reload | |
163 |
|
||||
164 | # Full diff of changeset 2f9c0091 |
|
166 | # Full diff of changeset 2f9c0091 | |
165 |
get :diff, :id => |
|
167 | get :diff, :id => PRJ_ID, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
166 | assert_response :success |
|
168 | assert_response :success | |
167 | assert_template 'diff' |
|
169 | assert_template 'diff' | |
168 | # Line 22 removed |
|
170 | # Line 22 removed | |
@@ -177,19 +179,18 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
177 | def test_diff_two_revs |
|
179 | def test_diff_two_revs | |
178 | @repository.fetch_changesets |
|
180 | @repository.fetch_changesets | |
179 | @repository.reload |
|
181 | @repository.reload | |
180 |
|
182 | get :diff, :id => PRJ_ID, | ||
181 |
|
|
183 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
182 |
|
|
184 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
183 | assert_response :success |
|
185 | assert_response :success | |
184 | assert_template 'diff' |
|
186 | assert_template 'diff' | |
185 |
|
||||
186 | diff = assigns(:diff) |
|
187 | diff = assigns(:diff) | |
187 | assert_not_nil diff |
|
188 | assert_not_nil diff | |
188 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ |
|
189 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
189 | end |
|
190 | end | |
190 |
|
191 | |||
191 | def test_annotate |
|
192 | def test_annotate | |
192 |
get :annotate, :id => |
|
193 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
193 | assert_response :success |
|
194 | assert_response :success | |
194 | assert_template 'annotate' |
|
195 | assert_template 'annotate' | |
195 | # Line 23, changeset 2f9c0091 |
|
196 | # Line 23, changeset 2f9c0091 | |
@@ -216,14 +217,15 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
216 | def test_annotate_at_given_revision |
|
217 | def test_annotate_at_given_revision | |
217 | @repository.fetch_changesets |
|
218 | @repository.fetch_changesets | |
218 | @repository.reload |
|
219 | @repository.reload | |
219 |
get :annotate, :id => |
|
220 | get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
|
221 | :path => ['sources', 'watchers_controller.rb'] | |||
220 | assert_response :success |
|
222 | assert_response :success | |
221 | assert_template 'annotate' |
|
223 | assert_template 'annotate' | |
222 | assert_tag :tag => 'h2', :content => /@ deff712f/ |
|
224 | assert_tag :tag => 'h2', :content => /@ deff712f/ | |
223 | end |
|
225 | end | |
224 |
|
226 | |||
225 | def test_annotate_binary_file |
|
227 | def test_annotate_binary_file | |
226 |
get :annotate, :id => |
|
228 | get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
227 | assert_response 500 |
|
229 | assert_response 500 | |
228 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
230 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
229 | :content => /cannot be annotated/ |
|
231 | :content => /cannot be annotated/ | |
@@ -233,7 +235,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
233 | @repository.fetch_changesets |
|
235 | @repository.fetch_changesets | |
234 | @repository.reload |
|
236 | @repository.reload | |
235 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
|
237 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
236 |
get :revision, :id => |
|
238 | get :revision, :id => PRJ_ID, :rev => r | |
237 | assert_response :success |
|
239 | assert_response :success | |
238 | assert_template 'revision' |
|
240 | assert_template 'revision' | |
239 | end |
|
241 | end | |
@@ -243,7 +245,7 class RepositoriesGitControllerTest < ActionController::TestCase | |||||
243 | @repository.fetch_changesets |
|
245 | @repository.fetch_changesets | |
244 | @repository.reload |
|
246 | @repository.reload | |
245 | ['', ' ', nil].each do |r| |
|
247 | ['', ' ', nil].each do |r| | |
246 |
get :revision, :id => |
|
248 | get :revision, :id => PRJ_ID, :rev => r | |
247 | assert_response 404 |
|
249 | assert_response 404 | |
248 | assert_error_tag :content => /was not found/ |
|
250 | assert_error_tag :content => /was not found/ | |
249 | end |
|
251 | end |
General Comments 0
You need to be logged in to leave comments.
Login now