# No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
CHAR_1_HEX = "\xc3\x9c"
-
+ PRJ_ID = 3
+
ruby19_non_utf8_pass = (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
def setup
@response = ActionController::TestResponse.new
User.current = nil
@repository = Repository::Mercurial.create(
- :project => Project.find(3),
+ :project => Project.find(PRJ_ID),
:url => REPOSITORY_PATH,
:path_encoding => 'ISO-8859-1'
)
def test_show_root
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
def test_show_directory
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3, :path => ['images']
+ get :show, :id => PRJ_ID, :path => ['images']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@repository.fetch_changesets
@repository.reload
[0, '0', '0885933ad4f6'].each do |r1|
- get :show, :id => 3, :path => ['images'], :rev => r1
+ get :show, :id => PRJ_ID, :path => ['images'], :rev => r1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@repository.fetch_changesets
@repository.reload
[13, '13', '3a330eb32958'].each do |r1|
- get :show, :id => 3, :path => ['sql_escape', 'percent%dir'], :rev => r1
+ get :show, :id => PRJ_ID, :path => ['sql_escape', 'percent%dir'], :rev => r1
assert_response :success
assert_template 'show'
@repository.fetch_changesets
@repository.reload
[21, '21', 'adf805632193'].each do |r1|
- get :show, :id => 3, :path => ['latin-1-dir'], :rev => r1
+ get :show, :id => PRJ_ID, :path => ['latin-1-dir'], :rev => r1
assert_response :success
assert_template 'show'
'test_branch.latin-1',
'test-branch-00',
].each do |bra|
- get :show, :id => 3, :rev => bra
+ get :show, :id => PRJ_ID, :rev => bra
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
'tag_test.00',
'tag-init-revision'
].each do |tag|
- get :show, :id => 3, :rev => tag
+ get :show, :id => PRJ_ID, :rev => tag
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_changes
- get :changes, :id => 3, :path => ['images', 'edit.png']
+ get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
assert_response :success
assert_template 'changes'
assert_tag :tag => 'h2', :content => 'edit.png'
end
def test_entry_show
- get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'entry'
# Line 10
def test_entry_show_latin_1
[21, '21', 'adf805632193'].each do |r1|
- get :entry, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
+ get :entry, :id => PRJ_ID, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
assert_response :success
assert_template 'entry'
assert_tag :tag => 'th',
:content => '1',
:attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
+ :sibling => { :tag => 'td',
+ :content => /Mercurial is a distributed version control system/ }
end
end
def test_entry_download
- get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
assert_response :success
# File content
assert @response.body.include?('WITHOUT ANY WARRANTY')
end
def test_directory_entry
- get :entry, :id => 3, :path => ['sources']
+ get :entry, :id => PRJ_ID, :path => ['sources']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entry)
def test_diff
@repository.fetch_changesets
@repository.reload
-
[4, '4', 'def6d2f1254a'].each do |r1|
# Full diff of changeset 4
- get :diff, :id => 3, :rev => r1
+ get :diff, :id => PRJ_ID, :rev => r1
assert_response :success
assert_template 'diff'
-
if @diff_c_support
# Line 22 removed
assert_tag :tag => 'th',
def test_diff_two_revs
@repository.fetch_changesets
@repository.reload
-
[2, '400bb8672109', '400', 400].each do |r1|
[4, 'def6d2f1254a'].each do |r2|
- get :diff, :id => 3, :rev => r1,
- :rev_to => r2
+ get :diff, :id => PRJ_ID, :rev => r1,
+ :rev_to => r2
assert_response :success
assert_template 'diff'
def test_diff_latin_1
[21, 'adf805632193'].each do |r1|
- get :diff, :id => 3, :rev => r1
+ get :diff, :id => PRJ_ID, :rev => r1
assert_response :success
assert_template 'diff'
assert_tag :tag => 'th',
end
def test_annotate
- get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'annotate'
# Line 23, revision 4:def6d2f1254a
@repository.fetch_changesets
@repository.reload
[2, '400bb8672109', '400', 400].each do |r1|
- get :annotate, :id => 3, :rev => r1, :path => ['sources', 'watchers_controller.rb']
+ get :annotate, :id => PRJ_ID, :rev => r1, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'annotate'
assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
def test_annotate_latin_1
[21, '21', 'adf805632193'].each do |r1|
- get :annotate, :id => 3, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
+ get :annotate, :id => PRJ_ID, :path => ['latin-1-dir', "test-#{@char_1}-2.txt"], :rev => r1
assert_response :success
assert_template 'annotate'
assert_tag :tag => 'th',
assert_tag :tag => 'th',
:content => '1',
:attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /Mercurial is a distributed version control system/ }
+ :sibling => { :tag => 'td',
+ :content => /Mercurial is a distributed version control system/ }
end
end
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
- get :revision, :id => 3, :rev => r
+ get :revision, :id => PRJ_ID, :rev => r
assert_response 404
assert_error_tag :content => /was not found/
end