Mercurial > hg > soundsoftware-site
comparison test/functional/repositories_bazaar_controller_test.rb @ 1464:261b3d9a4903 redmine-2.4
Update to Redmine 2.4 branch rev 12663
author | Chris Cannam |
---|---|
date | Tue, 14 Jan 2014 14:37:42 +0000 |
parents | 433d4f72a19b |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1296:038ba2d95de8 | 1464:261b3d9a4903 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 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. |
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/trunk').to_s | 26 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s |
27 REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk") | |
27 PRJ_ID = 3 | 28 PRJ_ID = 3 |
29 CHAR_1_UTF8_HEX = "\xc3\x9c" | |
28 | 30 |
29 def setup | 31 def setup |
30 User.current = nil | 32 User.current = nil |
31 @project = Project.find(PRJ_ID) | 33 @project = Project.find(PRJ_ID) |
32 @repository = Repository::Bazaar.create( | 34 @repository = Repository::Bazaar.create( |
33 :project => @project, | 35 :project => @project, |
34 :url => REPOSITORY_PATH, | 36 :url => REPOSITORY_PATH_TRUNK, |
35 :log_encoding => 'UTF-8') | 37 :log_encoding => 'UTF-8') |
36 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 | |
37 end | 43 end |
38 | 44 |
39 if File.directory?(REPOSITORY_PATH) | 45 if File.directory?(REPOSITORY_PATH) |
40 def test_get_new | 46 def test_get_new |
41 @request.session[:user_id] = 1 | 47 @request.session[:user_id] = 1 |
135 def test_annotate | 141 def test_annotate |
136 get :annotate, :id => PRJ_ID, | 142 get :annotate, :id => PRJ_ID, |
137 :path => repository_path_hash(['doc-mkdir.txt'])[:param] | 143 :path => repository_path_hash(['doc-mkdir.txt'])[:param] |
138 assert_response :success | 144 assert_response :success |
139 assert_template 'annotate' | 145 assert_template 'annotate' |
140 assert_tag :tag => 'th', :content => '2', | 146 assert_select "th.line-num", :text => '2' do |
141 :sibling => { | 147 assert_select "+ td.revision" do |
142 :tag => 'td', | 148 assert_select "a", :text => '3' |
143 :child => { | 149 assert_select "+ td.author", :text => "jsmith@" do |
144 :tag => 'a', | 150 assert_select "+ td", |
145 :content => '3' | 151 :text => "Main purpose:" |
146 } | 152 end |
147 } | 153 end |
148 assert_tag :tag => 'th', :content => '2', | 154 end |
149 :sibling => { :tag => 'td', :content => /jsmith/ } | 155 end |
150 assert_tag :tag => 'th', :content => '2', | 156 |
151 :sibling => { | 157 def test_annotate_author_escaping |
152 :tag => 'td', | 158 repository = Repository::Bazaar.create( |
153 :child => { | 159 :project => @project, |
154 :tag => 'a', | 160 :url => File.join(REPOSITORY_PATH, "author_escaping"), |
155 :content => '3' | 161 :identifier => 'author_escaping', |
156 } | 162 :log_encoding => 'UTF-8') |
157 } | 163 assert repository |
158 assert_tag :tag => 'th', :content => '2', | 164 get :annotate, :id => PRJ_ID, :repository_id => 'author_escaping', |
159 :sibling => { :tag => 'td', :content => /Main purpose/ } | 165 :path => repository_path_hash(['author-escaping-test.txt'])[:param] |
166 assert_response :success | |
167 assert_template 'annotate' | |
168 assert_select "th.line-num", :text => '1' do | |
169 assert_select "+ td.revision" do | |
170 assert_select "a", :text => '2' | |
171 assert_select "+ td.author", :text => "test &" do | |
172 assert_select "+ td", | |
173 :text => "author escaping test" | |
174 end | |
175 end | |
176 end | |
177 end | |
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 | |
160 end | 208 end |
161 | 209 |
162 def test_destroy_valid_repository | 210 def test_destroy_valid_repository |
163 @request.session[:user_id] = 1 # admin | 211 @request.session[:user_id] = 1 # admin |
164 assert_equal 0, @repository.changesets.count | 212 assert_equal 0, @repository.changesets.count |