@@ -1,34 +1,34 | |||||
1 | <% content_for :header_tags do %> |
|
1 | <% content_for :header_tags do %> | |
2 | <%= javascript_include_tag 'repository_navigation' %> |
|
2 | <%= javascript_include_tag 'repository_navigation' %> | |
3 | <% end %> |
|
3 | <% end %> | |
4 |
|
4 | |||
5 | <%= link_to l(:label_statistics), |
|
5 | <%= link_to l(:label_statistics), | |
6 | {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param}, |
|
6 | {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param}, | |
7 | :class => 'icon icon-stats' if @repository.supports_all_revisions? %> |
|
7 | :class => 'icon icon-stats' if @repository.supports_all_revisions? %> | |
8 |
|
8 | |||
9 | <% form_tag({:action => controller.action_name, |
|
9 | <% form_tag({:action => controller.action_name, | |
10 | :id => @project, |
|
10 | :id => @project, | |
11 | :repository_id => @repository.identifier_param, |
|
11 | :repository_id => @repository.identifier_param, | |
12 | :path => to_path_param(@path), |
|
12 | :path => to_path_param(@path), | |
13 |
:rev => |
|
13 | :rev => nil}, | |
14 | {:method => :get, :id => 'revision_selector'}) do -%> |
|
14 | {:method => :get, :id => 'revision_selector'}) do -%> | |
15 | <!-- Branches Dropdown --> |
|
15 | <!-- Branches Dropdown --> | |
16 | <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> |
|
16 | <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> | |
17 | | <%= l(:label_branch) %>: |
|
17 | | <%= l(:label_branch) %>: | |
18 | <%= select_tag :branch, |
|
18 | <%= select_tag :branch, | |
19 | options_for_select([''] + @repository.branches, @rev), |
|
19 | options_for_select([''] + @repository.branches, @rev), | |
20 | :id => 'branch' %> |
|
20 | :id => 'branch' %> | |
21 | <% end -%> |
|
21 | <% end -%> | |
22 |
|
22 | |||
23 | <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> |
|
23 | <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> | |
24 | | <%= l(:label_tag) %>: |
|
24 | | <%= l(:label_tag) %>: | |
25 | <%= select_tag :tag, |
|
25 | <%= select_tag :tag, | |
26 | options_for_select([''] + @repository.tags, @rev), |
|
26 | options_for_select([''] + @repository.tags, @rev), | |
27 | :id => 'tag' %> |
|
27 | :id => 'tag' %> | |
28 | <% end -%> |
|
28 | <% end -%> | |
29 |
|
29 | |||
30 | <% if @repository.supports_all_revisions? %> |
|
30 | <% if @repository.supports_all_revisions? %> | |
31 | | <%= l(:label_revision) %>: |
|
31 | | <%= l(:label_revision) %>: | |
32 | <%= text_field_tag 'rev', @rev, :size => 8 %> |
|
32 | <%= text_field_tag 'rev', @rev, :size => 8 %> | |
33 | <% end %> |
|
33 | <% end %> | |
34 | <% end -%> |
|
34 | <% end -%> |
@@ -1,503 +1,513 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 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__) | |
19 |
|
19 | |||
20 | class RepositoriesMercurialControllerTest < ActionController::TestCase |
|
20 | class RepositoriesMercurialControllerTest < ActionController::TestCase | |
21 | tests RepositoriesController |
|
21 | tests RepositoriesController | |
22 |
|
22 | |||
23 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
24 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
25 |
|
25 | |||
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s | |
27 | CHAR_1_HEX = "\xc3\x9c" |
|
27 | CHAR_1_HEX = "\xc3\x9c" | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
29 | NUM_REV = 32 |
|
29 | NUM_REV = 32 | |
30 |
|
30 | |||
31 | ruby19_non_utf8_pass = |
|
31 | ruby19_non_utf8_pass = | |
32 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
32 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | |
33 |
|
33 | |||
34 | def setup |
|
34 | def setup | |
35 | User.current = nil |
|
35 | User.current = nil | |
36 | @project = Project.find(PRJ_ID) |
|
36 | @project = Project.find(PRJ_ID) | |
37 | @repository = Repository::Mercurial.create( |
|
37 | @repository = Repository::Mercurial.create( | |
38 | :project => @project, |
|
38 | :project => @project, | |
39 | :url => REPOSITORY_PATH, |
|
39 | :url => REPOSITORY_PATH, | |
40 | :path_encoding => 'ISO-8859-1' |
|
40 | :path_encoding => 'ISO-8859-1' | |
41 | ) |
|
41 | ) | |
42 | assert @repository |
|
42 | assert @repository | |
43 | @diff_c_support = true |
|
43 | @diff_c_support = true | |
44 | @char_1 = CHAR_1_HEX.dup |
|
44 | @char_1 = CHAR_1_HEX.dup | |
45 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" |
|
45 | @tag_char_1 = "tag-#{CHAR_1_HEX}-00" | |
46 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" |
|
46 | @branch_char_0 = "branch-#{CHAR_1_HEX}-00" | |
47 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" |
|
47 | @branch_char_1 = "branch-#{CHAR_1_HEX}-01" | |
48 | if @char_1.respond_to?(:force_encoding) |
|
48 | if @char_1.respond_to?(:force_encoding) | |
49 | @char_1.force_encoding('UTF-8') |
|
49 | @char_1.force_encoding('UTF-8') | |
50 | @tag_char_1.force_encoding('UTF-8') |
|
50 | @tag_char_1.force_encoding('UTF-8') | |
51 | @branch_char_0.force_encoding('UTF-8') |
|
51 | @branch_char_0.force_encoding('UTF-8') | |
52 | @branch_char_1.force_encoding('UTF-8') |
|
52 | @branch_char_1.force_encoding('UTF-8') | |
53 | end |
|
53 | end | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | if ruby19_non_utf8_pass |
|
56 | if ruby19_non_utf8_pass | |
57 | puts "TODO: Mercurial functional test fails in Ruby 1.9 " + |
|
57 | puts "TODO: Mercurial functional test fails in Ruby 1.9 " + | |
58 | "and Encoding.default_external is not UTF-8. " + |
|
58 | "and Encoding.default_external is not UTF-8. " + | |
59 | "Current value is '#{Encoding.default_external.to_s}'" |
|
59 | "Current value is '#{Encoding.default_external.to_s}'" | |
60 | def test_fake; assert true end |
|
60 | def test_fake; assert true end | |
61 | elsif File.directory?(REPOSITORY_PATH) |
|
61 | elsif File.directory?(REPOSITORY_PATH) | |
62 |
|
62 | |||
63 | def test_get_new |
|
63 | def test_get_new | |
64 | @request.session[:user_id] = 1 |
|
64 | @request.session[:user_id] = 1 | |
65 | @project.repository.destroy |
|
65 | @project.repository.destroy | |
66 | get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' |
|
66 | get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' | |
67 | assert_response :success |
|
67 | assert_response :success | |
68 | assert_template 'new' |
|
68 | assert_template 'new' | |
69 | assert_kind_of Repository::Mercurial, assigns(:repository) |
|
69 | assert_kind_of Repository::Mercurial, assigns(:repository) | |
70 | assert assigns(:repository).new_record? |
|
70 | assert assigns(:repository).new_record? | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_show_root |
|
73 | def test_show_root | |
74 | assert_equal 0, @repository.changesets.count |
|
74 | assert_equal 0, @repository.changesets.count | |
75 | @repository.fetch_changesets |
|
75 | @repository.fetch_changesets | |
76 | @project.reload |
|
76 | @project.reload | |
77 | assert_equal NUM_REV, @repository.changesets.count |
|
77 | assert_equal NUM_REV, @repository.changesets.count | |
78 | get :show, :id => PRJ_ID |
|
78 | get :show, :id => PRJ_ID | |
79 | assert_response :success |
|
79 | assert_response :success | |
80 | assert_template 'show' |
|
80 | assert_template 'show' | |
81 | assert_not_nil assigns(:entries) |
|
81 | assert_not_nil assigns(:entries) | |
82 | assert_equal 4, assigns(:entries).size |
|
82 | assert_equal 4, assigns(:entries).size | |
83 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
83 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
84 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
84 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
85 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
85 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
86 | assert_not_nil assigns(:changesets) |
|
86 | assert_not_nil assigns(:changesets) | |
87 | assert assigns(:changesets).size > 0 |
|
87 | assert assigns(:changesets).size > 0 | |
88 | end |
|
88 | end | |
89 |
|
89 | |||
90 | def test_show_directory |
|
90 | def test_show_directory | |
91 | assert_equal 0, @repository.changesets.count |
|
91 | assert_equal 0, @repository.changesets.count | |
92 | @repository.fetch_changesets |
|
92 | @repository.fetch_changesets | |
93 | @project.reload |
|
93 | @project.reload | |
94 | assert_equal NUM_REV, @repository.changesets.count |
|
94 | assert_equal NUM_REV, @repository.changesets.count | |
95 | get :show, :id => PRJ_ID, :path => ['images'] |
|
95 | get :show, :id => PRJ_ID, :path => ['images'] | |
96 | assert_response :success |
|
96 | assert_response :success | |
97 | assert_template 'show' |
|
97 | assert_template 'show' | |
98 | assert_not_nil assigns(:entries) |
|
98 | assert_not_nil assigns(:entries) | |
99 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
99 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
100 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
100 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
101 | assert_not_nil entry |
|
101 | assert_not_nil entry | |
102 | assert_equal 'file', entry.kind |
|
102 | assert_equal 'file', entry.kind | |
103 | assert_equal 'images/edit.png', entry.path |
|
103 | assert_equal 'images/edit.png', entry.path | |
104 | assert_not_nil assigns(:changesets) |
|
104 | assert_not_nil assigns(:changesets) | |
105 | assert assigns(:changesets).size > 0 |
|
105 | assert assigns(:changesets).size > 0 | |
106 | end |
|
106 | end | |
107 |
|
107 | |||
108 | def test_show_at_given_revision |
|
108 | def test_show_at_given_revision | |
109 | assert_equal 0, @repository.changesets.count |
|
109 | assert_equal 0, @repository.changesets.count | |
110 | @repository.fetch_changesets |
|
110 | @repository.fetch_changesets | |
111 | @project.reload |
|
111 | @project.reload | |
112 | assert_equal NUM_REV, @repository.changesets.count |
|
112 | assert_equal NUM_REV, @repository.changesets.count | |
113 | [0, '0', '0885933ad4f6'].each do |r1| |
|
113 | [0, '0', '0885933ad4f6'].each do |r1| | |
114 | get :show, :id => PRJ_ID, :path => ['images'], :rev => r1 |
|
114 | get :show, :id => PRJ_ID, :path => ['images'], :rev => r1 | |
115 | assert_response :success |
|
115 | assert_response :success | |
116 | assert_template 'show' |
|
116 | assert_template 'show' | |
117 | assert_not_nil assigns(:entries) |
|
117 | assert_not_nil assigns(:entries) | |
118 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
118 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
119 | assert_not_nil assigns(:changesets) |
|
119 | assert_not_nil assigns(:changesets) | |
120 | assert assigns(:changesets).size > 0 |
|
120 | assert assigns(:changesets).size > 0 | |
121 | end |
|
121 | end | |
122 | end |
|
122 | end | |
123 |
|
123 | |||
124 | def test_show_directory_sql_escape_percent |
|
124 | def test_show_directory_sql_escape_percent | |
125 | assert_equal 0, @repository.changesets.count |
|
125 | assert_equal 0, @repository.changesets.count | |
126 | @repository.fetch_changesets |
|
126 | @repository.fetch_changesets | |
127 | @project.reload |
|
127 | @project.reload | |
128 | assert_equal NUM_REV, @repository.changesets.count |
|
128 | assert_equal NUM_REV, @repository.changesets.count | |
129 | [13, '13', '3a330eb32958'].each do |r1| |
|
129 | [13, '13', '3a330eb32958'].each do |r1| | |
130 | get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], |
|
130 | get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], | |
131 | :rev => r1 |
|
131 | :rev => r1 | |
132 | assert_response :success |
|
132 | assert_response :success | |
133 | assert_template 'show' |
|
133 | assert_template 'show' | |
134 |
|
134 | |||
135 | assert_not_nil assigns(:entries) |
|
135 | assert_not_nil assigns(:entries) | |
136 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], |
|
136 | assert_equal ['percent%file1.txt', 'percentfile1.txt'], | |
137 | assigns(:entries).collect(&:name) |
|
137 | assigns(:entries).collect(&:name) | |
138 | changesets = assigns(:changesets) |
|
138 | changesets = assigns(:changesets) | |
139 | assert_not_nil changesets |
|
139 | assert_not_nil changesets | |
140 | assert assigns(:changesets).size > 0 |
|
140 | assert assigns(:changesets).size > 0 | |
141 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) |
|
141 | assert_equal %w(13 11 10 9), changesets.collect(&:revision) | |
142 | end |
|
142 | end | |
143 | end |
|
143 | end | |
144 |
|
144 | |||
145 | def test_show_directory_latin_1_path |
|
145 | def test_show_directory_latin_1_path | |
146 | assert_equal 0, @repository.changesets.count |
|
146 | assert_equal 0, @repository.changesets.count | |
147 | @repository.fetch_changesets |
|
147 | @repository.fetch_changesets | |
148 | @project.reload |
|
148 | @project.reload | |
149 | assert_equal NUM_REV, @repository.changesets.count |
|
149 | assert_equal NUM_REV, @repository.changesets.count | |
150 | [21, '21', 'adf805632193'].each do |r1| |
|
150 | [21, '21', 'adf805632193'].each do |r1| | |
151 | get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1 |
|
151 | get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1 | |
152 | assert_response :success |
|
152 | assert_response :success | |
153 | assert_template 'show' |
|
153 | assert_template 'show' | |
154 |
|
154 | |||
155 | assert_not_nil assigns(:entries) |
|
155 | assert_not_nil assigns(:entries) | |
156 | assert_equal ["make-latin-1-file.rb", |
|
156 | assert_equal ["make-latin-1-file.rb", | |
157 | "test-#{@char_1}-1.txt", |
|
157 | "test-#{@char_1}-1.txt", | |
158 | "test-#{@char_1}-2.txt", |
|
158 | "test-#{@char_1}-2.txt", | |
159 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) |
|
159 | "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) | |
160 | changesets = assigns(:changesets) |
|
160 | changesets = assigns(:changesets) | |
161 | assert_not_nil changesets |
|
161 | assert_not_nil changesets | |
162 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) |
|
162 | assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) | |
163 | end |
|
163 | end | |
164 | end |
|
164 | end | |
165 |
|
165 | |||
|
166 | def show_should_show_branch_selection_form | |||
|
167 | @repository.fetch_changesets | |||
|
168 | @project.reload | |||
|
169 | get :show, :id => PRJ_ID | |||
|
170 | assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'} | |||
|
171 | assert_tag 'select', :attributes => {:name => 'branch'}, | |||
|
172 | :child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}}, | |||
|
173 | :parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}} | |||
|
174 | end | |||
|
175 | ||||
166 | def test_show_branch |
|
176 | def test_show_branch | |
167 | assert_equal 0, @repository.changesets.count |
|
177 | assert_equal 0, @repository.changesets.count | |
168 | @repository.fetch_changesets |
|
178 | @repository.fetch_changesets | |
169 | @project.reload |
|
179 | @project.reload | |
170 | assert_equal NUM_REV, @repository.changesets.count |
|
180 | assert_equal NUM_REV, @repository.changesets.count | |
171 | [ |
|
181 | [ | |
172 | 'default', |
|
182 | 'default', | |
173 | @branch_char_1, |
|
183 | @branch_char_1, | |
174 | 'branch (1)[2]&,%.-3_4', |
|
184 | 'branch (1)[2]&,%.-3_4', | |
175 | @branch_char_0, |
|
185 | @branch_char_0, | |
176 | 'test_branch.latin-1', |
|
186 | 'test_branch.latin-1', | |
177 | 'test-branch-00', |
|
187 | 'test-branch-00', | |
178 | ].each do |bra| |
|
188 | ].each do |bra| | |
179 | get :show, :id => PRJ_ID, :rev => bra |
|
189 | get :show, :id => PRJ_ID, :rev => bra | |
180 | assert_response :success |
|
190 | assert_response :success | |
181 | assert_template 'show' |
|
191 | assert_template 'show' | |
182 | assert_not_nil assigns(:entries) |
|
192 | assert_not_nil assigns(:entries) | |
183 | assert assigns(:entries).size > 0 |
|
193 | assert assigns(:entries).size > 0 | |
184 | assert_not_nil assigns(:changesets) |
|
194 | assert_not_nil assigns(:changesets) | |
185 | assert assigns(:changesets).size > 0 |
|
195 | assert assigns(:changesets).size > 0 | |
186 | end |
|
196 | end | |
187 | end |
|
197 | end | |
188 |
|
198 | |||
189 | def test_show_tag |
|
199 | def test_show_tag | |
190 | assert_equal 0, @repository.changesets.count |
|
200 | assert_equal 0, @repository.changesets.count | |
191 | @repository.fetch_changesets |
|
201 | @repository.fetch_changesets | |
192 | @project.reload |
|
202 | @project.reload | |
193 | assert_equal NUM_REV, @repository.changesets.count |
|
203 | assert_equal NUM_REV, @repository.changesets.count | |
194 | [ |
|
204 | [ | |
195 | @tag_char_1, |
|
205 | @tag_char_1, | |
196 | 'tag_test.00', |
|
206 | 'tag_test.00', | |
197 | 'tag-init-revision' |
|
207 | 'tag-init-revision' | |
198 | ].each do |tag| |
|
208 | ].each do |tag| | |
199 | get :show, :id => PRJ_ID, :rev => tag |
|
209 | get :show, :id => PRJ_ID, :rev => tag | |
200 | assert_response :success |
|
210 | assert_response :success | |
201 | assert_template 'show' |
|
211 | assert_template 'show' | |
202 | assert_not_nil assigns(:entries) |
|
212 | assert_not_nil assigns(:entries) | |
203 | assert assigns(:entries).size > 0 |
|
213 | assert assigns(:entries).size > 0 | |
204 | assert_not_nil assigns(:changesets) |
|
214 | assert_not_nil assigns(:changesets) | |
205 | assert assigns(:changesets).size > 0 |
|
215 | assert assigns(:changesets).size > 0 | |
206 | end |
|
216 | end | |
207 | end |
|
217 | end | |
208 |
|
218 | |||
209 | def test_changes |
|
219 | def test_changes | |
210 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
220 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
211 | assert_response :success |
|
221 | assert_response :success | |
212 | assert_template 'changes' |
|
222 | assert_template 'changes' | |
213 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
223 | assert_tag :tag => 'h2', :content => 'edit.png' | |
214 | end |
|
224 | end | |
215 |
|
225 | |||
216 | def test_entry_show |
|
226 | def test_entry_show | |
217 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
227 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
218 | assert_response :success |
|
228 | assert_response :success | |
219 | assert_template 'entry' |
|
229 | assert_template 'entry' | |
220 | # Line 10 |
|
230 | # Line 10 | |
221 | assert_tag :tag => 'th', |
|
231 | assert_tag :tag => 'th', | |
222 | :content => '10', |
|
232 | :content => '10', | |
223 | :attributes => { :class => 'line-num' }, |
|
233 | :attributes => { :class => 'line-num' }, | |
224 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
234 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
225 | end |
|
235 | end | |
226 |
|
236 | |||
227 | def test_entry_show_latin_1_path |
|
237 | def test_entry_show_latin_1_path | |
228 | [21, '21', 'adf805632193'].each do |r1| |
|
238 | [21, '21', 'adf805632193'].each do |r1| | |
229 | get :entry, :id => PRJ_ID, |
|
239 | get :entry, :id => PRJ_ID, | |
230 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
240 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 | |
231 | assert_response :success |
|
241 | assert_response :success | |
232 | assert_template 'entry' |
|
242 | assert_template 'entry' | |
233 | assert_tag :tag => 'th', |
|
243 | assert_tag :tag => 'th', | |
234 | :content => '1', |
|
244 | :content => '1', | |
235 | :attributes => { :class => 'line-num' }, |
|
245 | :attributes => { :class => 'line-num' }, | |
236 | :sibling => { :tag => 'td', |
|
246 | :sibling => { :tag => 'td', | |
237 | :content => /Mercurial is a distributed version control system/ } |
|
247 | :content => /Mercurial is a distributed version control system/ } | |
238 | end |
|
248 | end | |
239 | end |
|
249 | end | |
240 |
|
250 | |||
241 | def test_entry_show_latin_1_contents |
|
251 | def test_entry_show_latin_1_contents | |
242 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
252 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
243 | [27, '27', '7bbf4c738e71'].each do |r1| |
|
253 | [27, '27', '7bbf4c738e71'].each do |r1| | |
244 | get :entry, :id => PRJ_ID, |
|
254 | get :entry, :id => PRJ_ID, | |
245 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
255 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
246 | assert_response :success |
|
256 | assert_response :success | |
247 | assert_template 'entry' |
|
257 | assert_template 'entry' | |
248 | assert_tag :tag => 'th', |
|
258 | assert_tag :tag => 'th', | |
249 | :content => '1', |
|
259 | :content => '1', | |
250 | :attributes => { :class => 'line-num' }, |
|
260 | :attributes => { :class => 'line-num' }, | |
251 | :sibling => { :tag => 'td', |
|
261 | :sibling => { :tag => 'td', | |
252 | :content => /test-#{@char_1}.txt/ } |
|
262 | :content => /test-#{@char_1}.txt/ } | |
253 | end |
|
263 | end | |
254 | end |
|
264 | end | |
255 | end |
|
265 | end | |
256 |
|
266 | |||
257 | def test_entry_download |
|
267 | def test_entry_download | |
258 | get :entry, :id => PRJ_ID, |
|
268 | get :entry, :id => PRJ_ID, | |
259 | :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
269 | :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |
260 | assert_response :success |
|
270 | assert_response :success | |
261 | # File content |
|
271 | # File content | |
262 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
272 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
263 | end |
|
273 | end | |
264 |
|
274 | |||
265 | def test_entry_binary_force_download |
|
275 | def test_entry_binary_force_download | |
266 | get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png'] |
|
276 | get :entry, :id => PRJ_ID, :rev => 1, :path => ['images', 'edit.png'] | |
267 | assert_response :success |
|
277 | assert_response :success | |
268 | assert_equal 'image/png', @response.content_type |
|
278 | assert_equal 'image/png', @response.content_type | |
269 | end |
|
279 | end | |
270 |
|
280 | |||
271 | def test_directory_entry |
|
281 | def test_directory_entry | |
272 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
282 | get :entry, :id => PRJ_ID, :path => ['sources'] | |
273 | assert_response :success |
|
283 | assert_response :success | |
274 | assert_template 'show' |
|
284 | assert_template 'show' | |
275 | assert_not_nil assigns(:entry) |
|
285 | assert_not_nil assigns(:entry) | |
276 | assert_equal 'sources', assigns(:entry).name |
|
286 | assert_equal 'sources', assigns(:entry).name | |
277 | end |
|
287 | end | |
278 |
|
288 | |||
279 | def test_diff |
|
289 | def test_diff | |
280 | assert_equal 0, @repository.changesets.count |
|
290 | assert_equal 0, @repository.changesets.count | |
281 | @repository.fetch_changesets |
|
291 | @repository.fetch_changesets | |
282 | @project.reload |
|
292 | @project.reload | |
283 | assert_equal NUM_REV, @repository.changesets.count |
|
293 | assert_equal NUM_REV, @repository.changesets.count | |
284 | [4, '4', 'def6d2f1254a'].each do |r1| |
|
294 | [4, '4', 'def6d2f1254a'].each do |r1| | |
285 | # Full diff of changeset 4 |
|
295 | # Full diff of changeset 4 | |
286 | ['inline', 'sbs'].each do |dt| |
|
296 | ['inline', 'sbs'].each do |dt| | |
287 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
297 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
288 | assert_response :success |
|
298 | assert_response :success | |
289 | assert_template 'diff' |
|
299 | assert_template 'diff' | |
290 | if @diff_c_support |
|
300 | if @diff_c_support | |
291 | # Line 22 removed |
|
301 | # Line 22 removed | |
292 | assert_tag :tag => 'th', |
|
302 | assert_tag :tag => 'th', | |
293 | :content => '22', |
|
303 | :content => '22', | |
294 | :sibling => { :tag => 'td', |
|
304 | :sibling => { :tag => 'td', | |
295 | :attributes => { :class => /diff_out/ }, |
|
305 | :attributes => { :class => /diff_out/ }, | |
296 | :content => /def remove/ } |
|
306 | :content => /def remove/ } | |
297 | assert_tag :tag => 'h2', :content => /4:def6d2f1254a/ |
|
307 | assert_tag :tag => 'h2', :content => /4:def6d2f1254a/ | |
298 | end |
|
308 | end | |
299 | end |
|
309 | end | |
300 | end |
|
310 | end | |
301 | end |
|
311 | end | |
302 |
|
312 | |||
303 | def test_diff_two_revs |
|
313 | def test_diff_two_revs | |
304 | assert_equal 0, @repository.changesets.count |
|
314 | assert_equal 0, @repository.changesets.count | |
305 | @repository.fetch_changesets |
|
315 | @repository.fetch_changesets | |
306 | @project.reload |
|
316 | @project.reload | |
307 | assert_equal NUM_REV, @repository.changesets.count |
|
317 | assert_equal NUM_REV, @repository.changesets.count | |
308 | [2, '400bb8672109', '400', 400].each do |r1| |
|
318 | [2, '400bb8672109', '400', 400].each do |r1| | |
309 | [4, 'def6d2f1254a'].each do |r2| |
|
319 | [4, 'def6d2f1254a'].each do |r2| | |
310 | ['inline', 'sbs'].each do |dt| |
|
320 | ['inline', 'sbs'].each do |dt| | |
311 | get :diff, |
|
321 | get :diff, | |
312 | :id => PRJ_ID, |
|
322 | :id => PRJ_ID, | |
313 | :rev => r1, |
|
323 | :rev => r1, | |
314 | :rev_to => r2, |
|
324 | :rev_to => r2, | |
315 | :type => dt |
|
325 | :type => dt | |
316 | assert_response :success |
|
326 | assert_response :success | |
317 | assert_template 'diff' |
|
327 | assert_template 'diff' | |
318 | diff = assigns(:diff) |
|
328 | diff = assigns(:diff) | |
319 | assert_not_nil diff |
|
329 | assert_not_nil diff | |
320 | assert_tag :tag => 'h2', |
|
330 | assert_tag :tag => 'h2', | |
321 | :content => /4:def6d2f1254a 2:400bb8672109/ |
|
331 | :content => /4:def6d2f1254a 2:400bb8672109/ | |
322 | end |
|
332 | end | |
323 | end |
|
333 | end | |
324 | end |
|
334 | end | |
325 | end |
|
335 | end | |
326 |
|
336 | |||
327 | def test_diff_latin_1_path |
|
337 | def test_diff_latin_1_path | |
328 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
338 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
329 | [21, 'adf805632193'].each do |r1| |
|
339 | [21, 'adf805632193'].each do |r1| | |
330 | ['inline', 'sbs'].each do |dt| |
|
340 | ['inline', 'sbs'].each do |dt| | |
331 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
341 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
332 | assert_response :success |
|
342 | assert_response :success | |
333 | assert_template 'diff' |
|
343 | assert_template 'diff' | |
334 | assert_tag :tag => 'thead', |
|
344 | assert_tag :tag => 'thead', | |
335 | :descendant => { |
|
345 | :descendant => { | |
336 | :tag => 'th', |
|
346 | :tag => 'th', | |
337 | :attributes => { :class => 'filename' } , |
|
347 | :attributes => { :class => 'filename' } , | |
338 | :content => /latin-1-dir\/test-#{@char_1}-2.txt/ , |
|
348 | :content => /latin-1-dir\/test-#{@char_1}-2.txt/ , | |
339 | }, |
|
349 | }, | |
340 | :sibling => { |
|
350 | :sibling => { | |
341 | :tag => 'tbody', |
|
351 | :tag => 'tbody', | |
342 | :descendant => { |
|
352 | :descendant => { | |
343 | :tag => 'td', |
|
353 | :tag => 'td', | |
344 | :attributes => { :class => /diff_in/ }, |
|
354 | :attributes => { :class => /diff_in/ }, | |
345 | :content => /It is written in Python/ |
|
355 | :content => /It is written in Python/ | |
346 | } |
|
356 | } | |
347 | } |
|
357 | } | |
348 | end |
|
358 | end | |
349 | end |
|
359 | end | |
350 | end |
|
360 | end | |
351 | end |
|
361 | end | |
352 |
|
362 | |||
353 | def test_annotate |
|
363 | def test_annotate | |
354 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
364 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
355 | assert_response :success |
|
365 | assert_response :success | |
356 | assert_template 'annotate' |
|
366 | assert_template 'annotate' | |
357 | # Line 23, revision 4:def6d2f1254a |
|
367 | # Line 23, revision 4:def6d2f1254a | |
358 | assert_tag :tag => 'th', |
|
368 | assert_tag :tag => 'th', | |
359 | :content => '23', |
|
369 | :content => '23', | |
360 | :attributes => { :class => 'line-num' }, |
|
370 | :attributes => { :class => 'line-num' }, | |
361 | :sibling => |
|
371 | :sibling => | |
362 | { |
|
372 | { | |
363 | :tag => 'td', |
|
373 | :tag => 'td', | |
364 | :attributes => { :class => 'revision' }, |
|
374 | :attributes => { :class => 'revision' }, | |
365 | :child => { :tag => 'a', :content => '4:def6d2f1254a' } |
|
375 | :child => { :tag => 'a', :content => '4:def6d2f1254a' } | |
366 | } |
|
376 | } | |
367 | assert_tag :tag => 'th', |
|
377 | assert_tag :tag => 'th', | |
368 | :content => '23', |
|
378 | :content => '23', | |
369 | :attributes => { :class => 'line-num' }, |
|
379 | :attributes => { :class => 'line-num' }, | |
370 | :sibling => |
|
380 | :sibling => | |
371 | { |
|
381 | { | |
372 | :tag => 'td' , |
|
382 | :tag => 'td' , | |
373 | :content => 'jsmith' , |
|
383 | :content => 'jsmith' , | |
374 | :attributes => { :class => 'author' }, |
|
384 | :attributes => { :class => 'author' }, | |
375 | } |
|
385 | } | |
376 | assert_tag :tag => 'th', |
|
386 | assert_tag :tag => 'th', | |
377 | :content => '23', |
|
387 | :content => '23', | |
378 | :attributes => { :class => 'line-num' }, |
|
388 | :attributes => { :class => 'line-num' }, | |
379 | :sibling => { :tag => 'td', :content => /watcher =/ } |
|
389 | :sibling => { :tag => 'td', :content => /watcher =/ } | |
380 | end |
|
390 | end | |
381 |
|
391 | |||
382 | def test_annotate_not_in_tip |
|
392 | def test_annotate_not_in_tip | |
383 | assert_equal 0, @repository.changesets.count |
|
393 | assert_equal 0, @repository.changesets.count | |
384 | @repository.fetch_changesets |
|
394 | @repository.fetch_changesets | |
385 | @project.reload |
|
395 | @project.reload | |
386 | assert_equal NUM_REV, @repository.changesets.count |
|
396 | assert_equal NUM_REV, @repository.changesets.count | |
387 |
|
397 | |||
388 | get :annotate, :id => PRJ_ID, |
|
398 | get :annotate, :id => PRJ_ID, | |
389 | :path => ['sources', 'welcome_controller.rb'] |
|
399 | :path => ['sources', 'welcome_controller.rb'] | |
390 | assert_response 404 |
|
400 | assert_response 404 | |
391 | assert_error_tag :content => /was not found/ |
|
401 | assert_error_tag :content => /was not found/ | |
392 | end |
|
402 | end | |
393 |
|
403 | |||
394 | def test_annotate_at_given_revision |
|
404 | def test_annotate_at_given_revision | |
395 | assert_equal 0, @repository.changesets.count |
|
405 | assert_equal 0, @repository.changesets.count | |
396 | @repository.fetch_changesets |
|
406 | @repository.fetch_changesets | |
397 | @project.reload |
|
407 | @project.reload | |
398 | assert_equal NUM_REV, @repository.changesets.count |
|
408 | assert_equal NUM_REV, @repository.changesets.count | |
399 | [2, '400bb8672109', '400', 400].each do |r1| |
|
409 | [2, '400bb8672109', '400', 400].each do |r1| | |
400 | get :annotate, :id => PRJ_ID, :rev => r1, |
|
410 | get :annotate, :id => PRJ_ID, :rev => r1, | |
401 | :path => ['sources', 'watchers_controller.rb'] |
|
411 | :path => ['sources', 'watchers_controller.rb'] | |
402 | assert_response :success |
|
412 | assert_response :success | |
403 | assert_template 'annotate' |
|
413 | assert_template 'annotate' | |
404 | assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ |
|
414 | assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ | |
405 | end |
|
415 | end | |
406 | end |
|
416 | end | |
407 |
|
417 | |||
408 | def test_annotate_latin_1_path |
|
418 | def test_annotate_latin_1_path | |
409 | [21, '21', 'adf805632193'].each do |r1| |
|
419 | [21, '21', 'adf805632193'].each do |r1| | |
410 | get :annotate, :id => PRJ_ID, |
|
420 | get :annotate, :id => PRJ_ID, | |
411 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 |
|
421 | :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1 | |
412 | assert_response :success |
|
422 | assert_response :success | |
413 | assert_template 'annotate' |
|
423 | assert_template 'annotate' | |
414 | assert_tag :tag => 'th', |
|
424 | assert_tag :tag => 'th', | |
415 | :content => '1', |
|
425 | :content => '1', | |
416 | :attributes => { :class => 'line-num' }, |
|
426 | :attributes => { :class => 'line-num' }, | |
417 | :sibling => |
|
427 | :sibling => | |
418 | { |
|
428 | { | |
419 | :tag => 'td', |
|
429 | :tag => 'td', | |
420 | :attributes => { :class => 'revision' }, |
|
430 | :attributes => { :class => 'revision' }, | |
421 | :child => { :tag => 'a', :content => '20:709858aafd1b' } |
|
431 | :child => { :tag => 'a', :content => '20:709858aafd1b' } | |
422 | } |
|
432 | } | |
423 | assert_tag :tag => 'th', |
|
433 | assert_tag :tag => 'th', | |
424 | :content => '1', |
|
434 | :content => '1', | |
425 | :attributes => { :class => 'line-num' }, |
|
435 | :attributes => { :class => 'line-num' }, | |
426 | :sibling => |
|
436 | :sibling => | |
427 | { |
|
437 | { | |
428 | :tag => 'td' , |
|
438 | :tag => 'td' , | |
429 | :content => 'jsmith' , |
|
439 | :content => 'jsmith' , | |
430 | :attributes => { :class => 'author' }, |
|
440 | :attributes => { :class => 'author' }, | |
431 | } |
|
441 | } | |
432 | assert_tag :tag => 'th', |
|
442 | assert_tag :tag => 'th', | |
433 | :content => '1', |
|
443 | :content => '1', | |
434 | :attributes => { :class => 'line-num' }, |
|
444 | :attributes => { :class => 'line-num' }, | |
435 | :sibling => { :tag => 'td', |
|
445 | :sibling => { :tag => 'td', | |
436 | :content => /Mercurial is a distributed version control system/ } |
|
446 | :content => /Mercurial is a distributed version control system/ } | |
437 |
|
447 | |||
438 | end |
|
448 | end | |
439 | end |
|
449 | end | |
440 |
|
450 | |||
441 | def test_annotate_latin_1_contents |
|
451 | def test_annotate_latin_1_contents | |
442 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
452 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
443 | [27, '7bbf4c738e71'].each do |r1| |
|
453 | [27, '7bbf4c738e71'].each do |r1| | |
444 | get :annotate, :id => PRJ_ID, |
|
454 | get :annotate, :id => PRJ_ID, | |
445 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 |
|
455 | :path => ['latin-1-dir', "test-#{@char_1}.txt"], :rev => r1 | |
446 | assert_tag :tag => 'th', |
|
456 | assert_tag :tag => 'th', | |
447 | :content => '1', |
|
457 | :content => '1', | |
448 | :attributes => { :class => 'line-num' }, |
|
458 | :attributes => { :class => 'line-num' }, | |
449 | :sibling => { :tag => 'td', |
|
459 | :sibling => { :tag => 'td', | |
450 | :content => /test-#{@char_1}.txt/ } |
|
460 | :content => /test-#{@char_1}.txt/ } | |
451 | end |
|
461 | end | |
452 | end |
|
462 | end | |
453 | end |
|
463 | end | |
454 |
|
464 | |||
455 | def test_empty_revision |
|
465 | def test_empty_revision | |
456 | assert_equal 0, @repository.changesets.count |
|
466 | assert_equal 0, @repository.changesets.count | |
457 | @repository.fetch_changesets |
|
467 | @repository.fetch_changesets | |
458 | @project.reload |
|
468 | @project.reload | |
459 | assert_equal NUM_REV, @repository.changesets.count |
|
469 | assert_equal NUM_REV, @repository.changesets.count | |
460 | ['', ' ', nil].each do |r| |
|
470 | ['', ' ', nil].each do |r| | |
461 | get :revision, :id => PRJ_ID, :rev => r |
|
471 | get :revision, :id => PRJ_ID, :rev => r | |
462 | assert_response 404 |
|
472 | assert_response 404 | |
463 | assert_error_tag :content => /was not found/ |
|
473 | assert_error_tag :content => /was not found/ | |
464 | end |
|
474 | end | |
465 | end |
|
475 | end | |
466 |
|
476 | |||
467 | def test_destroy_valid_repository |
|
477 | def test_destroy_valid_repository | |
468 | @request.session[:user_id] = 1 # admin |
|
478 | @request.session[:user_id] = 1 # admin | |
469 | assert_equal 0, @repository.changesets.count |
|
479 | assert_equal 0, @repository.changesets.count | |
470 | @repository.fetch_changesets |
|
480 | @repository.fetch_changesets | |
471 | assert_equal NUM_REV, @repository.changesets.count |
|
481 | assert_equal NUM_REV, @repository.changesets.count | |
472 |
|
482 | |||
473 | assert_difference 'Repository.count', -1 do |
|
483 | assert_difference 'Repository.count', -1 do | |
474 | delete :destroy, :id => @repository.id |
|
484 | delete :destroy, :id => @repository.id | |
475 | end |
|
485 | end | |
476 | assert_response 302 |
|
486 | assert_response 302 | |
477 | @project.reload |
|
487 | @project.reload | |
478 | assert_nil @project.repository |
|
488 | assert_nil @project.repository | |
479 | end |
|
489 | end | |
480 |
|
490 | |||
481 | def test_destroy_invalid_repository |
|
491 | def test_destroy_invalid_repository | |
482 | @request.session[:user_id] = 1 # admin |
|
492 | @request.session[:user_id] = 1 # admin | |
483 | @project.repository.destroy |
|
493 | @project.repository.destroy | |
484 | @repository = Repository::Mercurial.create!( |
|
494 | @repository = Repository::Mercurial.create!( | |
485 | :project => Project.find(PRJ_ID), |
|
495 | :project => Project.find(PRJ_ID), | |
486 | :url => "/invalid", |
|
496 | :url => "/invalid", | |
487 | :path_encoding => 'ISO-8859-1' |
|
497 | :path_encoding => 'ISO-8859-1' | |
488 | ) |
|
498 | ) | |
489 | @repository.fetch_changesets |
|
499 | @repository.fetch_changesets | |
490 | assert_equal 0, @repository.changesets.count |
|
500 | assert_equal 0, @repository.changesets.count | |
491 |
|
501 | |||
492 | assert_difference 'Repository.count', -1 do |
|
502 | assert_difference 'Repository.count', -1 do | |
493 | delete :destroy, :id => @repository.id |
|
503 | delete :destroy, :id => @repository.id | |
494 | end |
|
504 | end | |
495 | assert_response 302 |
|
505 | assert_response 302 | |
496 | @project.reload |
|
506 | @project.reload | |
497 | assert_nil @project.repository |
|
507 | assert_nil @project.repository | |
498 | end |
|
508 | end | |
499 | else |
|
509 | else | |
500 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" |
|
510 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" | |
501 | def test_fake; assert true end |
|
511 | def test_fake; assert true end | |
502 | end |
|
512 | end | |
503 | end |
|
513 | end |
General Comments 0
You need to be logged in to leave comments.
Login now