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