scm: mercurial: code clean up functional test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5686 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-05-07 07:25:53 +00:00
parent f157ecb91a
commit ab6b848304
1 changed files with 13 additions and 7 deletions

View File

@ -25,11 +25,13 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
# No '..' in the repository path # No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository' REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') +
'/tmp/test/mercurial_repository'
CHAR_1_HEX = "\xc3\x9c" CHAR_1_HEX = "\xc3\x9c"
PRJ_ID = 3 PRJ_ID = 3
ruby19_non_utf8_pass = (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') ruby19_non_utf8_pass =
(RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
def setup def setup
@controller = RepositoriesController.new @controller = RepositoriesController.new
@ -110,12 +112,14 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
@repository.fetch_changesets @repository.fetch_changesets
@repository.reload @repository.reload
[13, '13', '3a330eb32958'].each do |r1| [13, '13', '3a330eb32958'].each do |r1|
get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], :rev => r1 get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'],
:rev => r1
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_not_nil assigns(:entries) assert_not_nil assigns(:entries)
assert_equal ['percent%file1.txt', 'percentfile1.txt'], assigns(:entries).collect(&:name) assert_equal ['percent%file1.txt', 'percentfile1.txt'],
assigns(:entries).collect(&:name)
changesets = assigns(:changesets) changesets = assigns(:changesets)
assert_not_nil changesets assert_not_nil changesets
assigns(:changesets).size > 0 assigns(:changesets).size > 0
@ -214,7 +218,8 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
end end
def test_entry_download def test_entry_download
get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' get :entry, :id => PRJ_ID,
:path => ['sources', 'watchers_controller.rb'], :format => 'raw'
assert_response :success assert_response :success
# File content # File content
assert @response.body.include?('WITHOUT ANY WARRANTY') assert @response.body.include?('WITHOUT ANY WARRANTY')
@ -317,7 +322,8 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
@repository.fetch_changesets @repository.fetch_changesets
@repository.reload @repository.reload
[2, '400bb8672109', '400', 400].each do |r1| [2, '400bb8672109', '400', 400].each do |r1|
get :annotate, :id => PRJ_ID, :rev => r1, :path => ['sources', 'watchers_controller.rb'] get :annotate, :id => PRJ_ID, :rev => r1,
:path => ['sources', 'watchers_controller.rb']
assert_response :success assert_response :success
assert_template 'annotate' assert_template 'annotate'
assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/