@@ -1,44 +1,46 | |||||
1 | <%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> |
|
1 | <%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> | |
2 |
|
2 | |||
3 | <div class="contextual"> |
|
3 | <div class="contextual"> | |
4 | <%= render :partial => 'navigation' %> |
|
4 | <%= render :partial => 'navigation' %> | |
5 | </div> |
|
5 | </div> | |
6 |
|
6 | |||
7 | <h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2> |
|
7 | <h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2> | |
8 |
|
8 | |||
9 | <%= render :partial => 'link_to_functions' %> |
|
9 | <%= render :partial => 'link_to_functions' %> | |
10 |
|
10 | |||
11 | <% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %> |
|
11 | <% colors = Hash.new {|k,v| k[v] = (k.size % 12) } %> | |
12 |
|
12 | |||
13 | <div class="autoscroll"> |
|
13 | <div class="autoscroll"> | |
14 | <table class="filecontent annotate syntaxhl"> |
|
14 | <table class="filecontent annotate syntaxhl"> | |
15 | <tbody> |
|
15 | <tbody> | |
16 | <% line_num = 1; previous_revision = nil %> |
|
16 | <% line_num = 1; previous_revision = nil %> | |
17 | <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> |
|
17 | <% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %> | |
18 | <% revision = @annotate.revisions[line_num - 1] %> |
|
18 | <% revision = @annotate.revisions[line_num - 1] %> | |
19 | <tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>"> |
|
19 | <tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>"> | |
20 | <th class="line-num"><a href="#L<%= line_num %>"><%= line_num %></a></th> |
|
20 | <th class="line-num"><a href="#L<%= line_num %>"><%= line_num %></a></th> | |
21 | <td class="revision"> |
|
21 | <td class="revision"> | |
22 | <% if revision && revision != previous_revision %> |
|
22 | <% if revision && revision != previous_revision %> | |
23 | <%= revision.identifier ? |
|
23 | <%= revision.identifier ? | |
24 | link_to_revision(revision, @repository) : format_revision(revision) %> |
|
24 | link_to_revision(revision, @repository) : format_revision(revision) %> | |
25 | <% end %> |
|
25 | <% end %> | |
26 | </td> |
|
26 | </td> | |
27 | <td class="author"> |
|
27 | <td class="author"> | |
28 | <% if revision && revision != previous_revision %> |
|
28 | <% if revision && revision != previous_revision %> | |
29 | <%= revision.author.to_s.split('<').first %> |
|
29 | <% author = Redmine::CodesetUtil.to_utf8(revision.author.to_s, | |
|
30 | @repository.repo_log_encoding) %> | |||
|
31 | <%= author.split('<').first %> | |||
30 | <% end %> |
|
32 | <% end %> | |
31 | </td> |
|
33 | </td> | |
32 | <td class="line-code"><pre><%= line.html_safe %></pre></td> |
|
34 | <td class="line-code"><pre><%= line.html_safe %></pre></td> | |
33 | </tr> |
|
35 | </tr> | |
34 | <% line_num += 1; previous_revision = revision %> |
|
36 | <% line_num += 1; previous_revision = revision %> | |
35 | <% end %> |
|
37 | <% end %> | |
36 | </tbody> |
|
38 | </tbody> | |
37 | </table> |
|
39 | </table> | |
38 | </div> |
|
40 | </div> | |
39 |
|
41 | |||
40 | <% html_title(l(:button_annotate)) -%> |
|
42 | <% html_title(l(:button_annotate)) -%> | |
41 |
|
43 | |||
42 | <% content_for :header_tags do %> |
|
44 | <% content_for :header_tags do %> | |
43 | <%= stylesheet_link_tag 'scm' %> |
|
45 | <%= stylesheet_link_tag 'scm' %> | |
44 | <% end %> |
|
46 | <% end %> |
@@ -1,210 +1,246 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2013 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 RepositoriesBazaarControllerTest < ActionController::TestCase |
|
20 | class RepositoriesBazaarControllerTest < 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/bazaar_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s | |
27 | REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") |
|
27 | REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
|
29 | CHAR_1_UTF8_HEX = "\xc3\x9c" | |||
29 |
|
30 | |||
30 | def setup |
|
31 | def setup | |
31 | User.current = nil |
|
32 | User.current = nil | |
32 | @project = Project.find(PRJ_ID) |
|
33 | @project = Project.find(PRJ_ID) | |
33 | @repository = Repository::Bazaar.create( |
|
34 | @repository = Repository::Bazaar.create( | |
34 | :project => @project, |
|
35 | :project => @project, | |
35 | :url => REPOSITORY_PATH_TRUNK, |
|
36 | :url => REPOSITORY_PATH_TRUNK, | |
36 | :log_encoding => 'UTF-8') |
|
37 | :log_encoding => 'UTF-8') | |
37 | assert @repository |
|
38 | assert @repository | |
|
39 | @char_1_utf8 = CHAR_1_UTF8_HEX.dup | |||
|
40 | if @char_1_utf8.respond_to?(:force_encoding) | |||
|
41 | @char_1_utf8.force_encoding('UTF-8') | |||
|
42 | end | |||
38 | end |
|
43 | end | |
39 |
|
44 | |||
40 | if File.directory?(REPOSITORY_PATH) |
|
45 | if File.directory?(REPOSITORY_PATH) | |
41 | def test_get_new |
|
46 | def test_get_new | |
42 | @request.session[:user_id] = 1 |
|
47 | @request.session[:user_id] = 1 | |
43 | @project.repository.destroy |
|
48 | @project.repository.destroy | |
44 | get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar' |
|
49 | get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar' | |
45 | assert_response :success |
|
50 | assert_response :success | |
46 | assert_template 'new' |
|
51 | assert_template 'new' | |
47 | assert_kind_of Repository::Bazaar, assigns(:repository) |
|
52 | assert_kind_of Repository::Bazaar, assigns(:repository) | |
48 | assert assigns(:repository).new_record? |
|
53 | assert assigns(:repository).new_record? | |
49 | end |
|
54 | end | |
50 |
|
55 | |||
51 | def test_browse_root |
|
56 | def test_browse_root | |
52 | get :show, :id => PRJ_ID |
|
57 | get :show, :id => PRJ_ID | |
53 | assert_response :success |
|
58 | assert_response :success | |
54 | assert_template 'show' |
|
59 | assert_template 'show' | |
55 | assert_not_nil assigns(:entries) |
|
60 | assert_not_nil assigns(:entries) | |
56 | assert_equal 2, assigns(:entries).size |
|
61 | assert_equal 2, assigns(:entries).size | |
57 | assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'} |
|
62 | assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'} | |
58 | assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'} |
|
63 | assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'} | |
59 | end |
|
64 | end | |
60 |
|
65 | |||
61 | def test_browse_directory |
|
66 | def test_browse_directory | |
62 | get :show, :id => PRJ_ID, :path => repository_path_hash(['directory'])[:param] |
|
67 | get :show, :id => PRJ_ID, :path => repository_path_hash(['directory'])[:param] | |
63 | assert_response :success |
|
68 | assert_response :success | |
64 | assert_template 'show' |
|
69 | assert_template 'show' | |
65 | assert_not_nil assigns(:entries) |
|
70 | assert_not_nil assigns(:entries) | |
66 | assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) |
|
71 | assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) | |
67 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
72 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
68 | assert_not_nil entry |
|
73 | assert_not_nil entry | |
69 | assert_equal 'file', entry.kind |
|
74 | assert_equal 'file', entry.kind | |
70 | assert_equal 'directory/edit.png', entry.path |
|
75 | assert_equal 'directory/edit.png', entry.path | |
71 | end |
|
76 | end | |
72 |
|
77 | |||
73 | def test_browse_at_given_revision |
|
78 | def test_browse_at_given_revision | |
74 | get :show, :id => PRJ_ID, :path => repository_path_hash([])[:param], |
|
79 | get :show, :id => PRJ_ID, :path => repository_path_hash([])[:param], | |
75 | :rev => 3 |
|
80 | :rev => 3 | |
76 | assert_response :success |
|
81 | assert_response :success | |
77 | assert_template 'show' |
|
82 | assert_template 'show' | |
78 | assert_not_nil assigns(:entries) |
|
83 | assert_not_nil assigns(:entries) | |
79 | assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], |
|
84 | assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], | |
80 | assigns(:entries).collect(&:name) |
|
85 | assigns(:entries).collect(&:name) | |
81 | end |
|
86 | end | |
82 |
|
87 | |||
83 | def test_changes |
|
88 | def test_changes | |
84 | get :changes, :id => PRJ_ID, |
|
89 | get :changes, :id => PRJ_ID, | |
85 | :path => repository_path_hash(['doc-mkdir.txt'])[:param] |
|
90 | :path => repository_path_hash(['doc-mkdir.txt'])[:param] | |
86 | assert_response :success |
|
91 | assert_response :success | |
87 | assert_template 'changes' |
|
92 | assert_template 'changes' | |
88 | assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' |
|
93 | assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' | |
89 | end |
|
94 | end | |
90 |
|
95 | |||
91 | def test_entry_show |
|
96 | def test_entry_show | |
92 | get :entry, :id => PRJ_ID, |
|
97 | get :entry, :id => PRJ_ID, | |
93 | :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param] |
|
98 | :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param] | |
94 | assert_response :success |
|
99 | assert_response :success | |
95 | assert_template 'entry' |
|
100 | assert_template 'entry' | |
96 | # Line 19 |
|
101 | # Line 19 | |
97 | assert_tag :tag => 'th', |
|
102 | assert_tag :tag => 'th', | |
98 | :content => /29/, |
|
103 | :content => /29/, | |
99 | :attributes => { :class => /line-num/ }, |
|
104 | :attributes => { :class => /line-num/ }, | |
100 | :sibling => { :tag => 'td', :content => /Show help message/ } |
|
105 | :sibling => { :tag => 'td', :content => /Show help message/ } | |
101 | end |
|
106 | end | |
102 |
|
107 | |||
103 | def test_entry_download |
|
108 | def test_entry_download | |
104 | get :entry, :id => PRJ_ID, |
|
109 | get :entry, :id => PRJ_ID, | |
105 | :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param], |
|
110 | :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param], | |
106 | :format => 'raw' |
|
111 | :format => 'raw' | |
107 | assert_response :success |
|
112 | assert_response :success | |
108 | # File content |
|
113 | # File content | |
109 | assert @response.body.include?('Show help message') |
|
114 | assert @response.body.include?('Show help message') | |
110 | end |
|
115 | end | |
111 |
|
116 | |||
112 | def test_directory_entry |
|
117 | def test_directory_entry | |
113 | get :entry, :id => PRJ_ID, |
|
118 | get :entry, :id => PRJ_ID, | |
114 | :path => repository_path_hash(['directory'])[:param] |
|
119 | :path => repository_path_hash(['directory'])[:param] | |
115 | assert_response :success |
|
120 | assert_response :success | |
116 | assert_template 'show' |
|
121 | assert_template 'show' | |
117 | assert_not_nil assigns(:entry) |
|
122 | assert_not_nil assigns(:entry) | |
118 | assert_equal 'directory', assigns(:entry).name |
|
123 | assert_equal 'directory', assigns(:entry).name | |
119 | end |
|
124 | end | |
120 |
|
125 | |||
121 | def test_diff |
|
126 | def test_diff | |
122 | # Full diff of changeset 3 |
|
127 | # Full diff of changeset 3 | |
123 | ['inline', 'sbs'].each do |dt| |
|
128 | ['inline', 'sbs'].each do |dt| | |
124 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
129 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
125 | assert_response :success |
|
130 | assert_response :success | |
126 | assert_template 'diff' |
|
131 | assert_template 'diff' | |
127 | # Line 11 removed |
|
132 | # Line 11 removed | |
128 | assert_tag :tag => 'th', |
|
133 | assert_tag :tag => 'th', | |
129 | :content => '11', |
|
134 | :content => '11', | |
130 | :sibling => { :tag => 'td', |
|
135 | :sibling => { :tag => 'td', | |
131 | :attributes => { :class => /diff_out/ }, |
|
136 | :attributes => { :class => /diff_out/ }, | |
132 | :content => /Display more information/ } |
|
137 | :content => /Display more information/ } | |
133 | end |
|
138 | end | |
134 | end |
|
139 | end | |
135 |
|
140 | |||
136 | def test_annotate |
|
141 | def test_annotate | |
137 | get :annotate, :id => PRJ_ID, |
|
142 | get :annotate, :id => PRJ_ID, | |
138 | :path => repository_path_hash(['doc-mkdir.txt'])[:param] |
|
143 | :path => repository_path_hash(['doc-mkdir.txt'])[:param] | |
139 | assert_response :success |
|
144 | assert_response :success | |
140 | assert_template 'annotate' |
|
145 | assert_template 'annotate' | |
141 | assert_select "th.line-num", :text => '2' do |
|
146 | assert_select "th.line-num", :text => '2' do | |
142 | assert_select "+ td.revision" do |
|
147 | assert_select "+ td.revision" do | |
143 | assert_select "a", :text => '3' |
|
148 | assert_select "a", :text => '3' | |
144 | assert_select "+ td.author", :text => "jsmith@" do |
|
149 | assert_select "+ td.author", :text => "jsmith@" do | |
145 | assert_select "+ td", |
|
150 | assert_select "+ td", | |
146 | :text => "Main purpose:" |
|
151 | :text => "Main purpose:" | |
147 | end |
|
152 | end | |
148 | end |
|
153 | end | |
149 | end |
|
154 | end | |
150 | end |
|
155 | end | |
151 |
|
156 | |||
152 | def test_annotate_author_escaping |
|
157 | def test_annotate_author_escaping | |
153 | repository = Repository::Bazaar.create( |
|
158 | repository = Repository::Bazaar.create( | |
154 | :project => @project, |
|
159 | :project => @project, | |
155 | :url => File.join(REPOSITORY_PATH, "author_escaping"), |
|
160 | :url => File.join(REPOSITORY_PATH, "author_escaping"), | |
156 | :identifier => 'author_escaping', |
|
161 | :identifier => 'author_escaping', | |
157 | :log_encoding => 'UTF-8') |
|
162 | :log_encoding => 'UTF-8') | |
158 | assert repository |
|
163 | assert repository | |
159 | get :annotate, :id => PRJ_ID, :repository_id => 'author_escaping', |
|
164 | get :annotate, :id => PRJ_ID, :repository_id => 'author_escaping', | |
160 | :path => repository_path_hash(['author-escaping-test.txt'])[:param] |
|
165 | :path => repository_path_hash(['author-escaping-test.txt'])[:param] | |
161 | assert_response :success |
|
166 | assert_response :success | |
162 | assert_template 'annotate' |
|
167 | assert_template 'annotate' | |
163 | assert_select "th.line-num", :text => '1' do |
|
168 | assert_select "th.line-num", :text => '1' do | |
164 | assert_select "+ td.revision" do |
|
169 | assert_select "+ td.revision" do | |
165 | assert_select "a", :text => '2' |
|
170 | assert_select "a", :text => '2' | |
166 | assert_select "+ td.author", :text => "test &" do |
|
171 | assert_select "+ td.author", :text => "test &" do | |
167 | assert_select "+ td", |
|
172 | assert_select "+ td", | |
168 | :text => "author escaping test" |
|
173 | :text => "author escaping test" | |
169 | end |
|
174 | end | |
170 | end |
|
175 | end | |
171 | end |
|
176 | end | |
172 | end |
|
177 | end | |
173 |
|
178 | |||
|
179 | if REPOSITORY_PATH.respond_to?(:force_encoding) | |||
|
180 | def test_annotate_author_non_ascii | |||
|
181 | log_encoding = nil | |||
|
182 | if Encoding.locale_charmap == "UTF-8" || | |||
|
183 | Encoding.locale_charmap == "ISO-8859-1" | |||
|
184 | log_encoding = Encoding.locale_charmap | |||
|
185 | end | |||
|
186 | unless log_encoding.nil? | |||
|
187 | repository = Repository::Bazaar.create( | |||
|
188 | :project => @project, | |||
|
189 | :url => File.join(REPOSITORY_PATH, "author_non_ascii"), | |||
|
190 | :identifier => 'author_non_ascii', | |||
|
191 | :log_encoding => log_encoding) | |||
|
192 | assert repository | |||
|
193 | get :annotate, :id => PRJ_ID, :repository_id => 'author_non_ascii', | |||
|
194 | :path => repository_path_hash(['author-non-ascii-test.txt'])[:param] | |||
|
195 | assert_response :success | |||
|
196 | assert_template 'annotate' | |||
|
197 | assert_select "th.line-num", :text => '1' do | |||
|
198 | assert_select "+ td.revision" do | |||
|
199 | assert_select "a", :text => '2' | |||
|
200 | assert_select "+ td.author", :text => "test #{@char_1_utf8}" do | |||
|
201 | assert_select "+ td", | |||
|
202 | :text => "author non ASCII test" | |||
|
203 | end | |||
|
204 | end | |||
|
205 | end | |||
|
206 | end | |||
|
207 | end | |||
|
208 | end | |||
|
209 | ||||
174 | def test_destroy_valid_repository |
|
210 | def test_destroy_valid_repository | |
175 | @request.session[:user_id] = 1 # admin |
|
211 | @request.session[:user_id] = 1 # admin | |
176 | assert_equal 0, @repository.changesets.count |
|
212 | assert_equal 0, @repository.changesets.count | |
177 | @repository.fetch_changesets |
|
213 | @repository.fetch_changesets | |
178 | assert @repository.changesets.count > 0 |
|
214 | assert @repository.changesets.count > 0 | |
179 |
|
215 | |||
180 | assert_difference 'Repository.count', -1 do |
|
216 | assert_difference 'Repository.count', -1 do | |
181 | delete :destroy, :id => @repository.id |
|
217 | delete :destroy, :id => @repository.id | |
182 | end |
|
218 | end | |
183 | assert_response 302 |
|
219 | assert_response 302 | |
184 | @project.reload |
|
220 | @project.reload | |
185 | assert_nil @project.repository |
|
221 | assert_nil @project.repository | |
186 | end |
|
222 | end | |
187 |
|
223 | |||
188 | def test_destroy_invalid_repository |
|
224 | def test_destroy_invalid_repository | |
189 | @request.session[:user_id] = 1 # admin |
|
225 | @request.session[:user_id] = 1 # admin | |
190 | @project.repository.destroy |
|
226 | @project.repository.destroy | |
191 | @repository = Repository::Bazaar.create!( |
|
227 | @repository = Repository::Bazaar.create!( | |
192 | :project => @project, |
|
228 | :project => @project, | |
193 | :url => "/invalid", |
|
229 | :url => "/invalid", | |
194 | :log_encoding => 'UTF-8') |
|
230 | :log_encoding => 'UTF-8') | |
195 | @repository.fetch_changesets |
|
231 | @repository.fetch_changesets | |
196 | @repository.reload |
|
232 | @repository.reload | |
197 | assert_equal 0, @repository.changesets.count |
|
233 | assert_equal 0, @repository.changesets.count | |
198 |
|
234 | |||
199 | assert_difference 'Repository.count', -1 do |
|
235 | assert_difference 'Repository.count', -1 do | |
200 | delete :destroy, :id => @repository.id |
|
236 | delete :destroy, :id => @repository.id | |
201 | end |
|
237 | end | |
202 | assert_response 302 |
|
238 | assert_response 302 | |
203 | @project.reload |
|
239 | @project.reload | |
204 | assert_nil @project.repository |
|
240 | assert_nil @project.repository | |
205 | end |
|
241 | end | |
206 | else |
|
242 | else | |
207 | puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" |
|
243 | puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" | |
208 | def test_fake; assert true end |
|
244 | def test_fake; assert true end | |
209 | end |
|
245 | end | |
210 | end |
|
246 | end |
@@ -1,642 +1,662 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2013 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 RepositoriesGitControllerTest < ActionController::TestCase |
|
20 | class RepositoriesGitControllerTest < 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/git_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s | |
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
28 | PRJ_ID = 3 |
|
28 | PRJ_ID = 3 | |
29 | CHAR_1_HEX = "\xc3\x9c" |
|
29 | CHAR_1_HEX = "\xc3\x9c" | |
|
30 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |||
30 | NUM_REV = 28 |
|
31 | NUM_REV = 28 | |
31 |
|
32 | |||
32 | ## Git, Mercurial and CVS path encodings are binary. |
|
33 | ## Git, Mercurial and CVS path encodings are binary. | |
33 | ## Subversion supports URL encoding for path. |
|
34 | ## Subversion supports URL encoding for path. | |
34 | ## Redmine Mercurial adapter and extension use URL encoding. |
|
35 | ## Redmine Mercurial adapter and extension use URL encoding. | |
35 | ## Git accepts only binary path in command line parameter. |
|
36 | ## Git accepts only binary path in command line parameter. | |
36 | ## So, there is no way to use binary command line parameter in JRuby. |
|
37 | ## So, there is no way to use binary command line parameter in JRuby. | |
37 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') |
|
38 | JRUBY_SKIP = (RUBY_PLATFORM == 'java') | |
38 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" |
|
39 | JRUBY_SKIP_STR = "TODO: This test fails in JRuby" | |
39 |
|
40 | |||
40 | def setup |
|
41 | def setup | |
41 | @ruby19_non_utf8_pass = |
|
42 | @ruby19_non_utf8_pass = | |
42 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
43 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') | |
43 |
|
44 | |||
44 | User.current = nil |
|
45 | User.current = nil | |
45 | @project = Project.find(PRJ_ID) |
|
46 | @project = Project.find(PRJ_ID) | |
46 | @repository = Repository::Git.create( |
|
47 | @repository = Repository::Git.create( | |
47 | :project => @project, |
|
48 | :project => @project, | |
48 | :url => REPOSITORY_PATH, |
|
49 | :url => REPOSITORY_PATH, | |
49 | :path_encoding => 'ISO-8859-1' |
|
50 | :path_encoding => 'ISO-8859-1' | |
50 | ) |
|
51 | ) | |
51 | assert @repository |
|
52 | assert @repository | |
52 | @char_1 = CHAR_1_HEX.dup |
|
53 | @char_1 = CHAR_1_HEX.dup | |
|
54 | @felix_utf8 = FELIX_HEX.dup | |||
53 | if @char_1.respond_to?(:force_encoding) |
|
55 | if @char_1.respond_to?(:force_encoding) | |
54 | @char_1.force_encoding('UTF-8') |
|
56 | @char_1.force_encoding('UTF-8') | |
|
57 | @felix_utf8.force_encoding('UTF-8') | |||
55 | end |
|
58 | end | |
56 | end |
|
59 | end | |
57 |
|
60 | |||
58 | def test_create_and_update |
|
61 | def test_create_and_update | |
59 | @request.session[:user_id] = 1 |
|
62 | @request.session[:user_id] = 1 | |
60 | assert_difference 'Repository.count' do |
|
63 | assert_difference 'Repository.count' do | |
61 | post :create, :project_id => 'subproject1', |
|
64 | post :create, :project_id => 'subproject1', | |
62 | :repository_scm => 'Git', |
|
65 | :repository_scm => 'Git', | |
63 | :repository => { |
|
66 | :repository => { | |
64 | :url => '/test', |
|
67 | :url => '/test', | |
65 | :is_default => '0', |
|
68 | :is_default => '0', | |
66 | :identifier => 'test-create', |
|
69 | :identifier => 'test-create', | |
67 | :extra_report_last_commit => '1', |
|
70 | :extra_report_last_commit => '1', | |
68 | } |
|
71 | } | |
69 | end |
|
72 | end | |
70 | assert_response 302 |
|
73 | assert_response 302 | |
71 | repository = Repository.first(:order => 'id DESC') |
|
74 | repository = Repository.first(:order => 'id DESC') | |
72 | assert_kind_of Repository::Git, repository |
|
75 | assert_kind_of Repository::Git, repository | |
73 | assert_equal '/test', repository.url |
|
76 | assert_equal '/test', repository.url | |
74 | assert_equal true, repository.extra_report_last_commit |
|
77 | assert_equal true, repository.extra_report_last_commit | |
75 |
|
78 | |||
76 | put :update, :id => repository.id, |
|
79 | put :update, :id => repository.id, | |
77 | :repository => { |
|
80 | :repository => { | |
78 | :extra_report_last_commit => '0' |
|
81 | :extra_report_last_commit => '0' | |
79 | } |
|
82 | } | |
80 | assert_response 302 |
|
83 | assert_response 302 | |
81 | repo2 = Repository.find(repository.id) |
|
84 | repo2 = Repository.find(repository.id) | |
82 | assert_equal false, repo2.extra_report_last_commit |
|
85 | assert_equal false, repo2.extra_report_last_commit | |
83 | end |
|
86 | end | |
84 |
|
87 | |||
85 | if File.directory?(REPOSITORY_PATH) |
|
88 | if File.directory?(REPOSITORY_PATH) | |
86 | ## Ruby uses ANSI api to fork a process on Windows. |
|
89 | ## Ruby uses ANSI api to fork a process on Windows. | |
87 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
90 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
88 | ## and these are incompatible with ASCII. |
|
91 | ## and these are incompatible with ASCII. | |
89 | ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 |
|
92 | ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 | |
90 | ## http://code.google.com/p/msysgit/issues/detail?id=80 |
|
93 | ## http://code.google.com/p/msysgit/issues/detail?id=80 | |
91 | ## So, Latin-1 path tests fail on Japanese Windows |
|
94 | ## So, Latin-1 path tests fail on Japanese Windows | |
92 | WINDOWS_PASS = (Redmine::Platform.mswin? && |
|
95 | WINDOWS_PASS = (Redmine::Platform.mswin? && | |
93 | Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) |
|
96 | Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) | |
94 | WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" |
|
97 | WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" | |
95 |
|
98 | |||
96 | def test_get_new |
|
99 | def test_get_new | |
97 | @request.session[:user_id] = 1 |
|
100 | @request.session[:user_id] = 1 | |
98 | @project.repository.destroy |
|
101 | @project.repository.destroy | |
99 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' |
|
102 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' | |
100 | assert_response :success |
|
103 | assert_response :success | |
101 | assert_template 'new' |
|
104 | assert_template 'new' | |
102 | assert_kind_of Repository::Git, assigns(:repository) |
|
105 | assert_kind_of Repository::Git, assigns(:repository) | |
103 | assert assigns(:repository).new_record? |
|
106 | assert assigns(:repository).new_record? | |
104 | end |
|
107 | end | |
105 |
|
108 | |||
106 | def test_browse_root |
|
109 | def test_browse_root | |
107 | assert_equal 0, @repository.changesets.count |
|
110 | assert_equal 0, @repository.changesets.count | |
108 | @repository.fetch_changesets |
|
111 | @repository.fetch_changesets | |
109 | @project.reload |
|
112 | @project.reload | |
110 | assert_equal NUM_REV, @repository.changesets.count |
|
113 | assert_equal NUM_REV, @repository.changesets.count | |
111 |
|
114 | |||
112 | get :show, :id => PRJ_ID |
|
115 | get :show, :id => PRJ_ID | |
113 | assert_response :success |
|
116 | assert_response :success | |
114 | assert_template 'show' |
|
117 | assert_template 'show' | |
115 | assert_not_nil assigns(:entries) |
|
118 | assert_not_nil assigns(:entries) | |
116 | assert_equal 9, assigns(:entries).size |
|
119 | assert_equal 9, assigns(:entries).size | |
117 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
120 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
118 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} |
|
121 | assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'} | |
119 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
122 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
120 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
123 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
121 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} |
|
124 | assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'} | |
122 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} |
|
125 | assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'} | |
123 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} |
|
126 | assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'} | |
124 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} |
|
127 | assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'} | |
125 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} |
|
128 | assert assigns(:entries).detect {|e| e.name == ' filename with a leading space.txt ' && e.kind == 'file'} | |
126 | assert_not_nil assigns(:changesets) |
|
129 | assert_not_nil assigns(:changesets) | |
127 | assert assigns(:changesets).size > 0 |
|
130 | assert assigns(:changesets).size > 0 | |
128 | end |
|
131 | end | |
129 |
|
132 | |||
130 | def test_browse_branch |
|
133 | def test_browse_branch | |
131 | assert_equal 0, @repository.changesets.count |
|
134 | assert_equal 0, @repository.changesets.count | |
132 | @repository.fetch_changesets |
|
135 | @repository.fetch_changesets | |
133 | @project.reload |
|
136 | @project.reload | |
134 | assert_equal NUM_REV, @repository.changesets.count |
|
137 | assert_equal NUM_REV, @repository.changesets.count | |
135 | get :show, :id => PRJ_ID, :rev => 'test_branch' |
|
138 | get :show, :id => PRJ_ID, :rev => 'test_branch' | |
136 | assert_response :success |
|
139 | assert_response :success | |
137 | assert_template 'show' |
|
140 | assert_template 'show' | |
138 | assert_not_nil assigns(:entries) |
|
141 | assert_not_nil assigns(:entries) | |
139 | assert_equal 4, assigns(:entries).size |
|
142 | assert_equal 4, assigns(:entries).size | |
140 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
143 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
141 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
144 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
142 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
145 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
143 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} |
|
146 | assert assigns(:entries).detect {|e| e.name == 'test.txt' && e.kind == 'file'} | |
144 | assert_not_nil assigns(:changesets) |
|
147 | assert_not_nil assigns(:changesets) | |
145 | assert assigns(:changesets).size > 0 |
|
148 | assert assigns(:changesets).size > 0 | |
146 | end |
|
149 | end | |
147 |
|
150 | |||
148 | def test_browse_tag |
|
151 | def test_browse_tag | |
149 | assert_equal 0, @repository.changesets.count |
|
152 | assert_equal 0, @repository.changesets.count | |
150 | @repository.fetch_changesets |
|
153 | @repository.fetch_changesets | |
151 | @project.reload |
|
154 | @project.reload | |
152 | assert_equal NUM_REV, @repository.changesets.count |
|
155 | assert_equal NUM_REV, @repository.changesets.count | |
153 | [ |
|
156 | [ | |
154 | "tag00.lightweight", |
|
157 | "tag00.lightweight", | |
155 | "tag01.annotated", |
|
158 | "tag01.annotated", | |
156 | ].each do |t1| |
|
159 | ].each do |t1| | |
157 | get :show, :id => PRJ_ID, :rev => t1 |
|
160 | get :show, :id => PRJ_ID, :rev => t1 | |
158 | assert_response :success |
|
161 | assert_response :success | |
159 | assert_template 'show' |
|
162 | assert_template 'show' | |
160 | assert_not_nil assigns(:entries) |
|
163 | assert_not_nil assigns(:entries) | |
161 | assert assigns(:entries).size > 0 |
|
164 | assert assigns(:entries).size > 0 | |
162 | assert_not_nil assigns(:changesets) |
|
165 | assert_not_nil assigns(:changesets) | |
163 | assert assigns(:changesets).size > 0 |
|
166 | assert assigns(:changesets).size > 0 | |
164 | end |
|
167 | end | |
165 | end |
|
168 | end | |
166 |
|
169 | |||
167 | def test_browse_directory |
|
170 | def test_browse_directory | |
168 | assert_equal 0, @repository.changesets.count |
|
171 | assert_equal 0, @repository.changesets.count | |
169 | @repository.fetch_changesets |
|
172 | @repository.fetch_changesets | |
170 | @project.reload |
|
173 | @project.reload | |
171 | assert_equal NUM_REV, @repository.changesets.count |
|
174 | assert_equal NUM_REV, @repository.changesets.count | |
172 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] |
|
175 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] | |
173 | assert_response :success |
|
176 | assert_response :success | |
174 | assert_template 'show' |
|
177 | assert_template 'show' | |
175 | assert_not_nil assigns(:entries) |
|
178 | assert_not_nil assigns(:entries) | |
176 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) |
|
179 | assert_equal ['edit.png'], assigns(:entries).collect(&:name) | |
177 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
180 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
178 | assert_not_nil entry |
|
181 | assert_not_nil entry | |
179 | assert_equal 'file', entry.kind |
|
182 | assert_equal 'file', entry.kind | |
180 | assert_equal 'images/edit.png', entry.path |
|
183 | assert_equal 'images/edit.png', entry.path | |
181 | assert_not_nil assigns(:changesets) |
|
184 | assert_not_nil assigns(:changesets) | |
182 | assert assigns(:changesets).size > 0 |
|
185 | assert assigns(:changesets).size > 0 | |
183 | end |
|
186 | end | |
184 |
|
187 | |||
185 | def test_browse_at_given_revision |
|
188 | def test_browse_at_given_revision | |
186 | assert_equal 0, @repository.changesets.count |
|
189 | assert_equal 0, @repository.changesets.count | |
187 | @repository.fetch_changesets |
|
190 | @repository.fetch_changesets | |
188 | @project.reload |
|
191 | @project.reload | |
189 | assert_equal NUM_REV, @repository.changesets.count |
|
192 | assert_equal NUM_REV, @repository.changesets.count | |
190 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], |
|
193 | get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], | |
191 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' |
|
194 | :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518' | |
192 | assert_response :success |
|
195 | assert_response :success | |
193 | assert_template 'show' |
|
196 | assert_template 'show' | |
194 | assert_not_nil assigns(:entries) |
|
197 | assert_not_nil assigns(:entries) | |
195 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
198 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
196 | assert_not_nil assigns(:changesets) |
|
199 | assert_not_nil assigns(:changesets) | |
197 | assert assigns(:changesets).size > 0 |
|
200 | assert assigns(:changesets).size > 0 | |
198 | end |
|
201 | end | |
199 |
|
202 | |||
200 | def test_changes |
|
203 | def test_changes | |
201 | get :changes, :id => PRJ_ID, |
|
204 | get :changes, :id => PRJ_ID, | |
202 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
205 | :path => repository_path_hash(['images', 'edit.png'])[:param] | |
203 | assert_response :success |
|
206 | assert_response :success | |
204 | assert_template 'changes' |
|
207 | assert_template 'changes' | |
205 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
208 | assert_tag :tag => 'h2', :content => 'edit.png' | |
206 | end |
|
209 | end | |
207 |
|
210 | |||
208 | def test_entry_show |
|
211 | def test_entry_show | |
209 | get :entry, :id => PRJ_ID, |
|
212 | get :entry, :id => PRJ_ID, | |
210 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
213 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
211 | assert_response :success |
|
214 | assert_response :success | |
212 | assert_template 'entry' |
|
215 | assert_template 'entry' | |
213 | # Line 19 |
|
216 | # Line 19 | |
214 | assert_tag :tag => 'th', |
|
217 | assert_tag :tag => 'th', | |
215 | :content => '11', |
|
218 | :content => '11', | |
216 | :attributes => { :class => 'line-num' }, |
|
219 | :attributes => { :class => 'line-num' }, | |
217 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
220 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
218 | end |
|
221 | end | |
219 |
|
222 | |||
220 | def test_entry_show_latin_1 |
|
223 | def test_entry_show_latin_1 | |
221 | if @ruby19_non_utf8_pass |
|
224 | if @ruby19_non_utf8_pass | |
222 | puts_ruby19_non_utf8_pass() |
|
225 | puts_ruby19_non_utf8_pass() | |
223 | elsif WINDOWS_PASS |
|
226 | elsif WINDOWS_PASS | |
224 | puts WINDOWS_SKIP_STR |
|
227 | puts WINDOWS_SKIP_STR | |
225 | elsif JRUBY_SKIP |
|
228 | elsif JRUBY_SKIP | |
226 | puts JRUBY_SKIP_STR |
|
229 | puts JRUBY_SKIP_STR | |
227 | else |
|
230 | else | |
228 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
231 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
229 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
232 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
230 | get :entry, :id => PRJ_ID, |
|
233 | get :entry, :id => PRJ_ID, | |
231 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
234 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
232 | :rev => r1 |
|
235 | :rev => r1 | |
233 | assert_response :success |
|
236 | assert_response :success | |
234 | assert_template 'entry' |
|
237 | assert_template 'entry' | |
235 | assert_tag :tag => 'th', |
|
238 | assert_tag :tag => 'th', | |
236 | :content => '1', |
|
239 | :content => '1', | |
237 | :attributes => { :class => 'line-num' }, |
|
240 | :attributes => { :class => 'line-num' }, | |
238 | :sibling => { :tag => 'td', |
|
241 | :sibling => { :tag => 'td', | |
239 | :content => /test-#{@char_1}.txt/ } |
|
242 | :content => /test-#{@char_1}.txt/ } | |
240 | end |
|
243 | end | |
241 | end |
|
244 | end | |
242 | end |
|
245 | end | |
243 | end |
|
246 | end | |
244 |
|
247 | |||
245 | def test_entry_download |
|
248 | def test_entry_download | |
246 | get :entry, :id => PRJ_ID, |
|
249 | get :entry, :id => PRJ_ID, | |
247 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
250 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
248 | :format => 'raw' |
|
251 | :format => 'raw' | |
249 | assert_response :success |
|
252 | assert_response :success | |
250 | # File content |
|
253 | # File content | |
251 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
254 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
252 | end |
|
255 | end | |
253 |
|
256 | |||
254 | def test_directory_entry |
|
257 | def test_directory_entry | |
255 | get :entry, :id => PRJ_ID, |
|
258 | get :entry, :id => PRJ_ID, | |
256 | :path => repository_path_hash(['sources'])[:param] |
|
259 | :path => repository_path_hash(['sources'])[:param] | |
257 | assert_response :success |
|
260 | assert_response :success | |
258 | assert_template 'show' |
|
261 | assert_template 'show' | |
259 | assert_not_nil assigns(:entry) |
|
262 | assert_not_nil assigns(:entry) | |
260 | assert_equal 'sources', assigns(:entry).name |
|
263 | assert_equal 'sources', assigns(:entry).name | |
261 | end |
|
264 | end | |
262 |
|
265 | |||
263 | def test_diff |
|
266 | def test_diff | |
264 | assert_equal true, @repository.is_default |
|
267 | assert_equal true, @repository.is_default | |
265 | assert_nil @repository.identifier |
|
268 | assert_nil @repository.identifier | |
266 | assert_equal 0, @repository.changesets.count |
|
269 | assert_equal 0, @repository.changesets.count | |
267 | @repository.fetch_changesets |
|
270 | @repository.fetch_changesets | |
268 | @project.reload |
|
271 | @project.reload | |
269 | assert_equal NUM_REV, @repository.changesets.count |
|
272 | assert_equal NUM_REV, @repository.changesets.count | |
270 | # Full diff of changeset 2f9c0091 |
|
273 | # Full diff of changeset 2f9c0091 | |
271 | ['inline', 'sbs'].each do |dt| |
|
274 | ['inline', 'sbs'].each do |dt| | |
272 | get :diff, |
|
275 | get :diff, | |
273 | :id => PRJ_ID, |
|
276 | :id => PRJ_ID, | |
274 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
277 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
275 | :type => dt |
|
278 | :type => dt | |
276 | assert_response :success |
|
279 | assert_response :success | |
277 | assert_template 'diff' |
|
280 | assert_template 'diff' | |
278 | # Line 22 removed |
|
281 | # Line 22 removed | |
279 | assert_tag :tag => 'th', |
|
282 | assert_tag :tag => 'th', | |
280 | :content => /22/, |
|
283 | :content => /22/, | |
281 | :sibling => { :tag => 'td', |
|
284 | :sibling => { :tag => 'td', | |
282 | :attributes => { :class => /diff_out/ }, |
|
285 | :attributes => { :class => /diff_out/ }, | |
283 | :content => /def remove/ } |
|
286 | :content => /def remove/ } | |
284 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
287 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
285 | end |
|
288 | end | |
286 | end |
|
289 | end | |
287 |
|
290 | |||
288 | def test_diff_with_rev_and_path |
|
291 | def test_diff_with_rev_and_path | |
289 | assert_equal 0, @repository.changesets.count |
|
292 | assert_equal 0, @repository.changesets.count | |
290 | @repository.fetch_changesets |
|
293 | @repository.fetch_changesets | |
291 | @project.reload |
|
294 | @project.reload | |
292 | assert_equal NUM_REV, @repository.changesets.count |
|
295 | assert_equal NUM_REV, @repository.changesets.count | |
293 | with_settings :diff_max_lines_displayed => 1000 do |
|
296 | with_settings :diff_max_lines_displayed => 1000 do | |
294 | # Full diff of changeset 2f9c0091 |
|
297 | # Full diff of changeset 2f9c0091 | |
295 | ['inline', 'sbs'].each do |dt| |
|
298 | ['inline', 'sbs'].each do |dt| | |
296 | get :diff, |
|
299 | get :diff, | |
297 | :id => PRJ_ID, |
|
300 | :id => PRJ_ID, | |
298 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
301 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
299 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
302 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
300 | :type => dt |
|
303 | :type => dt | |
301 | assert_response :success |
|
304 | assert_response :success | |
302 | assert_template 'diff' |
|
305 | assert_template 'diff' | |
303 | # Line 22 removed |
|
306 | # Line 22 removed | |
304 | assert_tag :tag => 'th', |
|
307 | assert_tag :tag => 'th', | |
305 | :content => '22', |
|
308 | :content => '22', | |
306 | :sibling => { :tag => 'td', |
|
309 | :sibling => { :tag => 'td', | |
307 | :attributes => { :class => /diff_out/ }, |
|
310 | :attributes => { :class => /diff_out/ }, | |
308 | :content => /def remove/ } |
|
311 | :content => /def remove/ } | |
309 | assert_tag :tag => 'h2', :content => /2f9c0091/ |
|
312 | assert_tag :tag => 'h2', :content => /2f9c0091/ | |
310 | end |
|
313 | end | |
311 | end |
|
314 | end | |
312 | end |
|
315 | end | |
313 |
|
316 | |||
314 | def test_diff_truncated |
|
317 | def test_diff_truncated | |
315 | assert_equal 0, @repository.changesets.count |
|
318 | assert_equal 0, @repository.changesets.count | |
316 | @repository.fetch_changesets |
|
319 | @repository.fetch_changesets | |
317 | @project.reload |
|
320 | @project.reload | |
318 | assert_equal NUM_REV, @repository.changesets.count |
|
321 | assert_equal NUM_REV, @repository.changesets.count | |
319 |
|
322 | |||
320 | with_settings :diff_max_lines_displayed => 5 do |
|
323 | with_settings :diff_max_lines_displayed => 5 do | |
321 | # Truncated diff of changeset 2f9c0091 |
|
324 | # Truncated diff of changeset 2f9c0091 | |
322 | with_cache do |
|
325 | with_cache do | |
323 | with_settings :default_language => 'en' do |
|
326 | with_settings :default_language => 'en' do | |
324 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
327 | get :diff, :id => PRJ_ID, :type => 'inline', | |
325 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
328 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
326 | assert_response :success |
|
329 | assert_response :success | |
327 | assert @response.body.include?("... This diff was truncated") |
|
330 | assert @response.body.include?("... This diff was truncated") | |
328 | end |
|
331 | end | |
329 | with_settings :default_language => 'fr' do |
|
332 | with_settings :default_language => 'fr' do | |
330 | get :diff, :id => PRJ_ID, :type => 'inline', |
|
333 | get :diff, :id => PRJ_ID, :type => 'inline', | |
331 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
334 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
332 | assert_response :success |
|
335 | assert_response :success | |
333 | assert ! @response.body.include?("... This diff was truncated") |
|
336 | assert ! @response.body.include?("... This diff was truncated") | |
334 | assert @response.body.include?("... Ce diff") |
|
337 | assert @response.body.include?("... Ce diff") | |
335 | end |
|
338 | end | |
336 | end |
|
339 | end | |
337 | end |
|
340 | end | |
338 | end |
|
341 | end | |
339 |
|
342 | |||
340 | def test_diff_two_revs |
|
343 | def test_diff_two_revs | |
341 | assert_equal 0, @repository.changesets.count |
|
344 | assert_equal 0, @repository.changesets.count | |
342 | @repository.fetch_changesets |
|
345 | @repository.fetch_changesets | |
343 | @project.reload |
|
346 | @project.reload | |
344 | assert_equal NUM_REV, @repository.changesets.count |
|
347 | assert_equal NUM_REV, @repository.changesets.count | |
345 | ['inline', 'sbs'].each do |dt| |
|
348 | ['inline', 'sbs'].each do |dt| | |
346 | get :diff, |
|
349 | get :diff, | |
347 | :id => PRJ_ID, |
|
350 | :id => PRJ_ID, | |
348 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
351 | :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
349 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
352 | :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
350 | :type => dt |
|
353 | :type => dt | |
351 | assert_response :success |
|
354 | assert_response :success | |
352 | assert_template 'diff' |
|
355 | assert_template 'diff' | |
353 | diff = assigns(:diff) |
|
356 | diff = assigns(:diff) | |
354 | assert_not_nil diff |
|
357 | assert_not_nil diff | |
355 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ |
|
358 | assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ | |
356 | assert_tag :tag => "form", |
|
359 | assert_tag :tag => "form", | |
357 | :attributes => { |
|
360 | :attributes => { | |
358 | :action => "/projects/subproject1/repository/revisions/" + |
|
361 | :action => "/projects/subproject1/repository/revisions/" + | |
359 | "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" |
|
362 | "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" | |
360 | } |
|
363 | } | |
361 | assert_tag :tag => 'input', |
|
364 | assert_tag :tag => 'input', | |
362 | :attributes => { |
|
365 | :attributes => { | |
363 | :id => "rev_to", |
|
366 | :id => "rev_to", | |
364 | :name => "rev_to", |
|
367 | :name => "rev_to", | |
365 | :type => "hidden", |
|
368 | :type => "hidden", | |
366 | :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
369 | :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
367 | } |
|
370 | } | |
368 | end |
|
371 | end | |
369 | end |
|
372 | end | |
370 |
|
373 | |||
371 | def test_diff_path_in_subrepo |
|
374 | def test_diff_path_in_subrepo | |
372 | repo = Repository::Git.create( |
|
375 | repo = Repository::Git.create( | |
373 | :project => @project, |
|
376 | :project => @project, | |
374 | :url => REPOSITORY_PATH, |
|
377 | :url => REPOSITORY_PATH, | |
375 | :identifier => 'test-diff-path', |
|
378 | :identifier => 'test-diff-path', | |
376 | :path_encoding => 'ISO-8859-1' |
|
379 | :path_encoding => 'ISO-8859-1' | |
377 | ); |
|
380 | ); | |
378 | assert repo |
|
381 | assert repo | |
379 | assert_equal false, repo.is_default |
|
382 | assert_equal false, repo.is_default | |
380 | assert_equal 'test-diff-path', repo.identifier |
|
383 | assert_equal 'test-diff-path', repo.identifier | |
381 | get :diff, |
|
384 | get :diff, | |
382 | :id => PRJ_ID, |
|
385 | :id => PRJ_ID, | |
383 | :repository_id => 'test-diff-path', |
|
386 | :repository_id => 'test-diff-path', | |
384 | :rev => '61b685fbe55ab05b', |
|
387 | :rev => '61b685fbe55ab05b', | |
385 | :rev_to => '2f9c0091c754a91a', |
|
388 | :rev_to => '2f9c0091c754a91a', | |
386 | :type => 'inline' |
|
389 | :type => 'inline' | |
387 | assert_response :success |
|
390 | assert_response :success | |
388 | assert_template 'diff' |
|
391 | assert_template 'diff' | |
389 | diff = assigns(:diff) |
|
392 | diff = assigns(:diff) | |
390 | assert_not_nil diff |
|
393 | assert_not_nil diff | |
391 | assert_tag :tag => "form", |
|
394 | assert_tag :tag => "form", | |
392 | :attributes => { |
|
395 | :attributes => { | |
393 | :action => "/projects/subproject1/repository/test-diff-path/" + |
|
396 | :action => "/projects/subproject1/repository/test-diff-path/" + | |
394 | "revisions/61b685fbe55ab05b/diff" |
|
397 | "revisions/61b685fbe55ab05b/diff" | |
395 | } |
|
398 | } | |
396 | assert_tag :tag => 'input', |
|
399 | assert_tag :tag => 'input', | |
397 | :attributes => { |
|
400 | :attributes => { | |
398 | :id => "rev_to", |
|
401 | :id => "rev_to", | |
399 | :name => "rev_to", |
|
402 | :name => "rev_to", | |
400 | :type => "hidden", |
|
403 | :type => "hidden", | |
401 | :value => '2f9c0091c754a91a' |
|
404 | :value => '2f9c0091c754a91a' | |
402 | } |
|
405 | } | |
403 | end |
|
406 | end | |
404 |
|
407 | |||
405 | def test_diff_latin_1 |
|
408 | def test_diff_latin_1 | |
406 | if @ruby19_non_utf8_pass |
|
409 | if @ruby19_non_utf8_pass | |
407 | puts_ruby19_non_utf8_pass() |
|
410 | puts_ruby19_non_utf8_pass() | |
408 | else |
|
411 | else | |
409 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
412 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
410 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
413 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
411 | ['inline', 'sbs'].each do |dt| |
|
414 | ['inline', 'sbs'].each do |dt| | |
412 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt |
|
415 | get :diff, :id => PRJ_ID, :rev => r1, :type => dt | |
413 | assert_response :success |
|
416 | assert_response :success | |
414 | assert_template 'diff' |
|
417 | assert_template 'diff' | |
415 | assert_tag :tag => 'thead', |
|
418 | assert_tag :tag => 'thead', | |
416 | :descendant => { |
|
419 | :descendant => { | |
417 | :tag => 'th', |
|
420 | :tag => 'th', | |
418 | :attributes => { :class => 'filename' } , |
|
421 | :attributes => { :class => 'filename' } , | |
419 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , |
|
422 | :content => /latin-1-dir\/test-#{@char_1}.txt/ , | |
420 | }, |
|
423 | }, | |
421 | :sibling => { |
|
424 | :sibling => { | |
422 | :tag => 'tbody', |
|
425 | :tag => 'tbody', | |
423 | :descendant => { |
|
426 | :descendant => { | |
424 | :tag => 'td', |
|
427 | :tag => 'td', | |
425 | :attributes => { :class => /diff_in/ }, |
|
428 | :attributes => { :class => /diff_in/ }, | |
426 | :content => /test-#{@char_1}.txt/ |
|
429 | :content => /test-#{@char_1}.txt/ | |
427 | } |
|
430 | } | |
428 | } |
|
431 | } | |
429 | end |
|
432 | end | |
430 | end |
|
433 | end | |
431 | end |
|
434 | end | |
432 | end |
|
435 | end | |
433 | end |
|
436 | end | |
434 |
|
437 | |||
435 | def test_diff_should_show_filenames |
|
438 | def test_diff_should_show_filenames | |
436 | get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline' |
|
439 | get :diff, :id => PRJ_ID, :rev => 'deff712f05a90d96edbd70facc47d944be5897e3', :type => 'inline' | |
437 | assert_response :success |
|
440 | assert_response :success | |
438 | assert_template 'diff' |
|
441 | assert_template 'diff' | |
439 | # modified file |
|
442 | # modified file | |
440 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' |
|
443 | assert_select 'th.filename', :text => 'sources/watchers_controller.rb' | |
441 | # deleted file |
|
444 | # deleted file | |
442 | assert_select 'th.filename', :text => 'test.txt' |
|
445 | assert_select 'th.filename', :text => 'test.txt' | |
443 | end |
|
446 | end | |
444 |
|
447 | |||
445 | def test_save_diff_type |
|
448 | def test_save_diff_type | |
446 | user1 = User.find(1) |
|
449 | user1 = User.find(1) | |
447 | user1.pref[:diff_type] = nil |
|
450 | user1.pref[:diff_type] = nil | |
448 | user1.preference.save |
|
451 | user1.preference.save | |
449 | user = User.find(1) |
|
452 | user = User.find(1) | |
450 | assert_nil user.pref[:diff_type] |
|
453 | assert_nil user.pref[:diff_type] | |
451 |
|
454 | |||
452 | @request.session[:user_id] = 1 # admin |
|
455 | @request.session[:user_id] = 1 # admin | |
453 | get :diff, |
|
456 | get :diff, | |
454 | :id => PRJ_ID, |
|
457 | :id => PRJ_ID, | |
455 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' |
|
458 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' | |
456 | assert_response :success |
|
459 | assert_response :success | |
457 | assert_template 'diff' |
|
460 | assert_template 'diff' | |
458 | user.reload |
|
461 | user.reload | |
459 | assert_equal "inline", user.pref[:diff_type] |
|
462 | assert_equal "inline", user.pref[:diff_type] | |
460 | get :diff, |
|
463 | get :diff, | |
461 | :id => PRJ_ID, |
|
464 | :id => PRJ_ID, | |
462 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', |
|
465 | :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7', | |
463 | :type => 'sbs' |
|
466 | :type => 'sbs' | |
464 | assert_response :success |
|
467 | assert_response :success | |
465 | assert_template 'diff' |
|
468 | assert_template 'diff' | |
466 | user.reload |
|
469 | user.reload | |
467 | assert_equal "sbs", user.pref[:diff_type] |
|
470 | assert_equal "sbs", user.pref[:diff_type] | |
468 | end |
|
471 | end | |
469 |
|
472 | |||
470 | def test_annotate |
|
473 | def test_annotate | |
471 | get :annotate, :id => PRJ_ID, |
|
474 | get :annotate, :id => PRJ_ID, | |
472 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
475 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
473 | assert_response :success |
|
476 | assert_response :success | |
474 | assert_template 'annotate' |
|
477 | assert_template 'annotate' | |
475 |
|
478 | |||
476 | # Line 23, changeset 2f9c0091 |
|
479 | # Line 23, changeset 2f9c0091 | |
477 | assert_select 'tr' do |
|
480 | assert_select 'tr' do | |
478 | assert_select 'th.line-num', :text => '23' |
|
481 | assert_select 'th.line-num', :text => '23' | |
479 | assert_select 'td.revision', :text => /2f9c0091/ |
|
482 | assert_select 'td.revision', :text => /2f9c0091/ | |
480 | assert_select 'td.author', :text => 'jsmith' |
|
483 | assert_select 'td.author', :text => 'jsmith' | |
481 | assert_select 'td', :text => /remove_watcher/ |
|
484 | assert_select 'td', :text => /remove_watcher/ | |
482 | end |
|
485 | end | |
483 | end |
|
486 | end | |
484 |
|
487 | |||
485 | def test_annotate_at_given_revision |
|
488 | def test_annotate_at_given_revision | |
486 | assert_equal 0, @repository.changesets.count |
|
489 | assert_equal 0, @repository.changesets.count | |
487 | @repository.fetch_changesets |
|
490 | @repository.fetch_changesets | |
488 | @project.reload |
|
491 | @project.reload | |
489 | assert_equal NUM_REV, @repository.changesets.count |
|
492 | assert_equal NUM_REV, @repository.changesets.count | |
490 | get :annotate, :id => PRJ_ID, :rev => 'deff7', |
|
493 | get :annotate, :id => PRJ_ID, :rev => 'deff7', | |
491 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] |
|
494 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] | |
492 | assert_response :success |
|
495 | assert_response :success | |
493 | assert_template 'annotate' |
|
496 | assert_template 'annotate' | |
494 | assert_tag :tag => 'h2', :content => /@ deff712f/ |
|
497 | assert_tag :tag => 'h2', :content => /@ deff712f/ | |
495 | end |
|
498 | end | |
496 |
|
499 | |||
497 | def test_annotate_binary_file |
|
500 | def test_annotate_binary_file | |
498 | get :annotate, :id => PRJ_ID, |
|
501 | get :annotate, :id => PRJ_ID, | |
499 | :path => repository_path_hash(['images', 'edit.png'])[:param] |
|
502 | :path => repository_path_hash(['images', 'edit.png'])[:param] | |
500 | assert_response 500 |
|
503 | assert_response 500 | |
501 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
504 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
502 | :content => /cannot be annotated/ |
|
505 | :content => /cannot be annotated/ | |
503 | end |
|
506 | end | |
504 |
|
507 | |||
505 | def test_annotate_error_when_too_big |
|
508 | def test_annotate_error_when_too_big | |
506 | with_settings :file_max_size_displayed => 1 do |
|
509 | with_settings :file_max_size_displayed => 1 do | |
507 | get :annotate, :id => PRJ_ID, |
|
510 | get :annotate, :id => PRJ_ID, | |
508 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], |
|
511 | :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], | |
509 | :rev => 'deff712f' |
|
512 | :rev => 'deff712f' | |
510 | assert_response 500 |
|
513 | assert_response 500 | |
511 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
514 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, | |
512 | :content => /exceeds the maximum text file size/ |
|
515 | :content => /exceeds the maximum text file size/ | |
513 |
|
516 | |||
514 | get :annotate, :id => PRJ_ID, |
|
517 | get :annotate, :id => PRJ_ID, | |
515 | :path => repository_path_hash(['README'])[:param], |
|
518 | :path => repository_path_hash(['README'])[:param], | |
516 | :rev => '7234cb2' |
|
519 | :rev => '7234cb2' | |
517 | assert_response :success |
|
520 | assert_response :success | |
518 | assert_template 'annotate' |
|
521 | assert_template 'annotate' | |
519 | end |
|
522 | end | |
520 | end |
|
523 | end | |
521 |
|
524 | |||
522 | def test_annotate_latin_1 |
|
525 | def test_annotate_latin_1 | |
523 | if @ruby19_non_utf8_pass |
|
526 | if @ruby19_non_utf8_pass | |
524 | puts_ruby19_non_utf8_pass() |
|
527 | puts_ruby19_non_utf8_pass() | |
525 | elsif WINDOWS_PASS |
|
528 | elsif WINDOWS_PASS | |
526 | puts WINDOWS_SKIP_STR |
|
529 | puts WINDOWS_SKIP_STR | |
527 | elsif JRUBY_SKIP |
|
530 | elsif JRUBY_SKIP | |
528 | puts JRUBY_SKIP_STR |
|
531 | puts JRUBY_SKIP_STR | |
529 | else |
|
532 | else | |
530 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do |
|
533 | with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do | |
531 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| |
|
534 | ['57ca437c', '57ca437c0acbbcb749821fdf3726a1367056d364'].each do |r1| | |
532 | get :annotate, :id => PRJ_ID, |
|
535 | get :annotate, :id => PRJ_ID, | |
533 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], |
|
536 | :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], | |
534 | :rev => r1 |
|
537 | :rev => r1 | |
535 | assert_select "th.line-num", :text => '1' do |
|
538 | assert_select "th.line-num", :text => '1' do | |
536 | assert_select "+ td.revision" do |
|
539 | assert_select "+ td.revision" do | |
537 | assert_select "a", :text => '57ca437c' |
|
540 | assert_select "a", :text => '57ca437c' | |
538 | assert_select "+ td.author", :text => "jsmith" do |
|
541 | assert_select "+ td.author", :text => "jsmith" do | |
539 | assert_select "+ td", |
|
542 | assert_select "+ td", | |
540 | :text => "test-#{@char_1}.txt" |
|
543 | :text => "test-#{@char_1}.txt" | |
541 | end |
|
544 | end | |
542 | end |
|
545 | end | |
543 | end |
|
546 | end | |
544 | end |
|
547 | end | |
545 | end |
|
548 | end | |
546 | end |
|
549 | end | |
547 | end |
|
550 | end | |
548 |
|
551 | |||
|
552 | def test_annotate_latin_1_author | |||
|
553 | ['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1| | |||
|
554 | get :annotate, :id => PRJ_ID, | |||
|
555 | :path => repository_path_hash([" filename with a leading space.txt "])[:param], | |||
|
556 | :rev => r1 | |||
|
557 | assert_select "th.line-num", :text => '1' do | |||
|
558 | assert_select "+ td.revision" do | |||
|
559 | assert_select "a", :text => '83ca5fd5' | |||
|
560 | assert_select "+ td.author", :text => @felix_utf8 do | |||
|
561 | assert_select "+ td", | |||
|
562 | :text => "And this is a file with a leading and trailing space..." | |||
|
563 | end | |||
|
564 | end | |||
|
565 | end | |||
|
566 | end | |||
|
567 | end | |||
|
568 | ||||
549 | def test_revisions |
|
569 | def test_revisions | |
550 | assert_equal 0, @repository.changesets.count |
|
570 | assert_equal 0, @repository.changesets.count | |
551 | @repository.fetch_changesets |
|
571 | @repository.fetch_changesets | |
552 | @project.reload |
|
572 | @project.reload | |
553 | assert_equal NUM_REV, @repository.changesets.count |
|
573 | assert_equal NUM_REV, @repository.changesets.count | |
554 | get :revisions, :id => PRJ_ID |
|
574 | get :revisions, :id => PRJ_ID | |
555 | assert_response :success |
|
575 | assert_response :success | |
556 | assert_template 'revisions' |
|
576 | assert_template 'revisions' | |
557 | assert_tag :tag => 'form', |
|
577 | assert_tag :tag => 'form', | |
558 | :attributes => { |
|
578 | :attributes => { | |
559 | :method => 'get', |
|
579 | :method => 'get', | |
560 | :action => '/projects/subproject1/repository/revision' |
|
580 | :action => '/projects/subproject1/repository/revision' | |
561 | } |
|
581 | } | |
562 | end |
|
582 | end | |
563 |
|
583 | |||
564 | def test_revision |
|
584 | def test_revision | |
565 | assert_equal 0, @repository.changesets.count |
|
585 | assert_equal 0, @repository.changesets.count | |
566 | @repository.fetch_changesets |
|
586 | @repository.fetch_changesets | |
567 | @project.reload |
|
587 | @project.reload | |
568 | assert_equal NUM_REV, @repository.changesets.count |
|
588 | assert_equal NUM_REV, @repository.changesets.count | |
569 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| |
|
589 | ['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r| | |
570 | get :revision, :id => PRJ_ID, :rev => r |
|
590 | get :revision, :id => PRJ_ID, :rev => r | |
571 | assert_response :success |
|
591 | assert_response :success | |
572 | assert_template 'revision' |
|
592 | assert_template 'revision' | |
573 | end |
|
593 | end | |
574 | end |
|
594 | end | |
575 |
|
595 | |||
576 | def test_empty_revision |
|
596 | def test_empty_revision | |
577 | assert_equal 0, @repository.changesets.count |
|
597 | assert_equal 0, @repository.changesets.count | |
578 | @repository.fetch_changesets |
|
598 | @repository.fetch_changesets | |
579 | @project.reload |
|
599 | @project.reload | |
580 | assert_equal NUM_REV, @repository.changesets.count |
|
600 | assert_equal NUM_REV, @repository.changesets.count | |
581 | ['', ' ', nil].each do |r| |
|
601 | ['', ' ', nil].each do |r| | |
582 | get :revision, :id => PRJ_ID, :rev => r |
|
602 | get :revision, :id => PRJ_ID, :rev => r | |
583 | assert_response 404 |
|
603 | assert_response 404 | |
584 | assert_error_tag :content => /was not found/ |
|
604 | assert_error_tag :content => /was not found/ | |
585 | end |
|
605 | end | |
586 | end |
|
606 | end | |
587 |
|
607 | |||
588 | def test_destroy_valid_repository |
|
608 | def test_destroy_valid_repository | |
589 | @request.session[:user_id] = 1 # admin |
|
609 | @request.session[:user_id] = 1 # admin | |
590 | assert_equal 0, @repository.changesets.count |
|
610 | assert_equal 0, @repository.changesets.count | |
591 | @repository.fetch_changesets |
|
611 | @repository.fetch_changesets | |
592 | @project.reload |
|
612 | @project.reload | |
593 | assert_equal NUM_REV, @repository.changesets.count |
|
613 | assert_equal NUM_REV, @repository.changesets.count | |
594 |
|
614 | |||
595 | assert_difference 'Repository.count', -1 do |
|
615 | assert_difference 'Repository.count', -1 do | |
596 | delete :destroy, :id => @repository.id |
|
616 | delete :destroy, :id => @repository.id | |
597 | end |
|
617 | end | |
598 | assert_response 302 |
|
618 | assert_response 302 | |
599 | @project.reload |
|
619 | @project.reload | |
600 | assert_nil @project.repository |
|
620 | assert_nil @project.repository | |
601 | end |
|
621 | end | |
602 |
|
622 | |||
603 | def test_destroy_invalid_repository |
|
623 | def test_destroy_invalid_repository | |
604 | @request.session[:user_id] = 1 # admin |
|
624 | @request.session[:user_id] = 1 # admin | |
605 | @project.repository.destroy |
|
625 | @project.repository.destroy | |
606 | @repository = Repository::Git.create!( |
|
626 | @repository = Repository::Git.create!( | |
607 | :project => @project, |
|
627 | :project => @project, | |
608 | :url => "/invalid", |
|
628 | :url => "/invalid", | |
609 | :path_encoding => 'ISO-8859-1' |
|
629 | :path_encoding => 'ISO-8859-1' | |
610 | ) |
|
630 | ) | |
611 | @repository.fetch_changesets |
|
631 | @repository.fetch_changesets | |
612 | @repository.reload |
|
632 | @repository.reload | |
613 | assert_equal 0, @repository.changesets.count |
|
633 | assert_equal 0, @repository.changesets.count | |
614 |
|
634 | |||
615 | assert_difference 'Repository.count', -1 do |
|
635 | assert_difference 'Repository.count', -1 do | |
616 | delete :destroy, :id => @repository.id |
|
636 | delete :destroy, :id => @repository.id | |
617 | end |
|
637 | end | |
618 | assert_response 302 |
|
638 | assert_response 302 | |
619 | @project.reload |
|
639 | @project.reload | |
620 | assert_nil @project.repository |
|
640 | assert_nil @project.repository | |
621 | end |
|
641 | end | |
622 |
|
642 | |||
623 | private |
|
643 | private | |
624 |
|
644 | |||
625 | def puts_ruby19_non_utf8_pass |
|
645 | def puts_ruby19_non_utf8_pass | |
626 | puts "TODO: This test fails in Ruby 1.9 " + |
|
646 | puts "TODO: This test fails in Ruby 1.9 " + | |
627 | "and Encoding.default_external is not UTF-8. " + |
|
647 | "and Encoding.default_external is not UTF-8. " + | |
628 | "Current value is '#{Encoding.default_external.to_s}'" |
|
648 | "Current value is '#{Encoding.default_external.to_s}'" | |
629 | end |
|
649 | end | |
630 | else |
|
650 | else | |
631 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" |
|
651 | puts "Git test repository NOT FOUND. Skipping functional tests !!!" | |
632 | def test_fake; assert true end |
|
652 | def test_fake; assert true end | |
633 | end |
|
653 | end | |
634 |
|
654 | |||
635 | private |
|
655 | private | |
636 | def with_cache(&block) |
|
656 | def with_cache(&block) | |
637 | before = ActionController::Base.perform_caching |
|
657 | before = ActionController::Base.perform_caching | |
638 | ActionController::Base.perform_caching = true |
|
658 | ActionController::Base.perform_caching = true | |
639 | block.call |
|
659 | block.call | |
640 | ActionController::Base.perform_caching = before |
|
660 | ActionController::Base.perform_caching = before | |
641 | end |
|
661 | end | |
642 | end |
|
662 | end |
General Comments 0
You need to be logged in to leave comments.
Login now