2011-05-07 10:38:45 +04:00
|
|
|
# Redmine - project management software
|
2014-01-30 02:45:39 +04:00
|
|
|
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
2007-12-14 20:46:45 +03:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-07 10:38:45 +04:00
|
|
|
#
|
2007-12-14 20:46:45 +03:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-05-07 10:38:45 +04:00
|
|
|
#
|
2007-12-14 20:46:45 +03:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2007-12-14 20:46:45 +03:00
|
|
|
|
2009-09-13 21:14:35 +04:00
|
|
|
class RepositoriesMercurialControllerTest < ActionController::TestCase
|
2011-12-03 19:06:23 +04:00
|
|
|
tests RepositoriesController
|
|
|
|
|
2011-06-10 15:11:00 +04:00
|
|
|
fixtures :projects, :users, :roles, :members, :member_roles,
|
|
|
|
:repositories, :enabled_modules
|
2007-12-14 20:46:45 +03:00
|
|
|
|
2011-06-10 15:11:00 +04:00
|
|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
|
2011-03-04 14:07:58 +03:00
|
|
|
CHAR_1_HEX = "\xc3\x9c"
|
2011-05-07 11:25:53 +04:00
|
|
|
PRJ_ID = 3
|
2014-02-26 15:27:41 +04:00
|
|
|
NUM_REV = 34
|
2011-03-22 14:26:15 +03:00
|
|
|
|
2011-05-07 11:25:53 +04:00
|
|
|
ruby19_non_utf8_pass =
|
|
|
|
(RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8')
|
2007-12-14 20:46:45 +03:00
|
|
|
|
|
|
|
def setup
|
|
|
|
User.current = nil
|
2011-07-11 04:14:49 +04:00
|
|
|
@project = Project.find(PRJ_ID)
|
2011-03-04 07:25:48 +03:00
|
|
|
@repository = Repository::Mercurial.create(
|
2011-07-11 04:14:49 +04:00
|
|
|
:project => @project,
|
2011-03-04 07:25:48 +03:00
|
|
|
:url => REPOSITORY_PATH,
|
|
|
|
:path_encoding => 'ISO-8859-1'
|
|
|
|
)
|
2011-01-11 08:15:56 +03:00
|
|
|
assert @repository
|
2011-02-16 14:18:18 +03:00
|
|
|
@diff_c_support = true
|
2011-03-04 14:07:58 +03:00
|
|
|
@char_1 = CHAR_1_HEX.dup
|
2011-03-14 11:15:22 +03:00
|
|
|
@tag_char_1 = "tag-#{CHAR_1_HEX}-00"
|
|
|
|
@branch_char_0 = "branch-#{CHAR_1_HEX}-00"
|
|
|
|
@branch_char_1 = "branch-#{CHAR_1_HEX}-01"
|
2011-03-04 14:07:58 +03:00
|
|
|
if @char_1.respond_to?(:force_encoding)
|
|
|
|
@char_1.force_encoding('UTF-8')
|
2011-03-14 11:15:22 +03:00
|
|
|
@tag_char_1.force_encoding('UTF-8')
|
|
|
|
@branch_char_0.force_encoding('UTF-8')
|
|
|
|
@branch_char_1.force_encoding('UTF-8')
|
2011-03-04 14:07:58 +03:00
|
|
|
end
|
2007-12-14 20:46:45 +03:00
|
|
|
end
|
2011-01-11 08:15:56 +03:00
|
|
|
|
2011-03-04 14:07:58 +03:00
|
|
|
if ruby19_non_utf8_pass
|
|
|
|
puts "TODO: Mercurial functional test fails in Ruby 1.9 " +
|
|
|
|
"and Encoding.default_external is not UTF-8. " +
|
2011-05-07 10:38:45 +04:00
|
|
|
"Current value is '#{Encoding.default_external.to_s}'"
|
2011-03-04 14:07:58 +03:00
|
|
|
def test_fake; assert true end
|
|
|
|
elsif File.directory?(REPOSITORY_PATH)
|
2011-12-03 19:06:23 +04:00
|
|
|
|
2012-01-15 18:23:06 +04:00
|
|
|
def test_get_new
|
2011-12-03 19:06:23 +04:00
|
|
|
@request.session[:user_id] = 1
|
|
|
|
@project.repository.destroy
|
2012-01-15 18:23:06 +04:00
|
|
|
get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial'
|
2011-12-03 19:06:23 +04:00
|
|
|
assert_response :success
|
2012-01-15 18:23:06 +04:00
|
|
|
assert_template 'new'
|
2011-12-03 19:06:23 +04:00
|
|
|
assert_kind_of Repository::Mercurial, assigns(:repository)
|
|
|
|
assert assigns(:repository).new_record?
|
|
|
|
end
|
|
|
|
|
2009-08-16 02:41:40 +04:00
|
|
|
def test_show_root
|
2011-09-12 05:15:09 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:23:51 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 05:15:09 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-03-22 14:26:15 +03:00
|
|
|
get :show, :id => PRJ_ID
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
2009-08-16 02:41:40 +04:00
|
|
|
assert_template 'show'
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_not_nil assigns(:entries)
|
2011-01-05 18:02:47 +03:00
|
|
|
assert_equal 4, assigns(:entries).size
|
2011-01-05 18:01:39 +03:00
|
|
|
assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
|
2007-12-20 01:14:03 +03:00
|
|
|
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
|
2011-01-05 18:01:39 +03:00
|
|
|
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
|
2011-03-14 13:23:51 +03:00
|
|
|
assert_not_nil assigns(:changesets)
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2007-12-20 01:14:03 +03:00
|
|
|
end
|
2011-01-15 13:15:41 +03:00
|
|
|
|
2009-08-16 02:41:40 +04:00
|
|
|
def test_show_directory
|
2011-09-12 05:15:57 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:23:51 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 05:15:57 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2012-02-23 16:18:03 +04:00
|
|
|
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param]
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
2009-08-16 02:41:40 +04:00
|
|
|
assert_template 'show'
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_not_nil assigns(:entries)
|
2008-04-06 14:35:55 +04:00
|
|
|
assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
|
2007-12-20 01:14:03 +03:00
|
|
|
entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
|
|
|
|
assert_not_nil entry
|
|
|
|
assert_equal 'file', entry.kind
|
|
|
|
assert_equal 'images/edit.png', entry.path
|
2011-03-14 13:23:51 +03:00
|
|
|
assert_not_nil assigns(:changesets)
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2007-12-20 01:14:03 +03:00
|
|
|
end
|
2011-01-09 05:13:54 +03:00
|
|
|
|
2009-08-16 02:41:40 +04:00
|
|
|
def test_show_at_given_revision
|
2011-09-12 05:16:40 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:23:51 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 05:16:40 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 05:13:54 +03:00
|
|
|
[0, '0', '0885933ad4f6'].each do |r1|
|
2012-02-23 16:18:03 +04:00
|
|
|
get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param],
|
|
|
|
:rev => r1
|
2011-01-09 05:13:54 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'show'
|
|
|
|
assert_not_nil assigns(:entries)
|
|
|
|
assert_equal ['delete.png'], assigns(:entries).collect(&:name)
|
2011-03-14 13:23:51 +03:00
|
|
|
assert_not_nil assigns(:changesets)
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2011-01-09 05:13:54 +03:00
|
|
|
end
|
2008-04-06 14:35:55 +04:00
|
|
|
end
|
2011-01-05 18:03:16 +03:00
|
|
|
|
|
|
|
def test_show_directory_sql_escape_percent
|
2011-09-12 18:11:14 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:23:51 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:11:14 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 05:13:54 +03:00
|
|
|
[13, '13', '3a330eb32958'].each do |r1|
|
2012-02-23 16:18:03 +04:00
|
|
|
get :show, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
|
2011-05-07 11:25:53 +04:00
|
|
|
:rev => r1
|
2011-01-09 05:13:54 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'show'
|
2011-01-05 18:03:16 +03:00
|
|
|
|
2011-01-09 05:13:54 +03:00
|
|
|
assert_not_nil assigns(:entries)
|
2011-05-07 11:25:53 +04:00
|
|
|
assert_equal ['percent%file1.txt', 'percentfile1.txt'],
|
|
|
|
assigns(:entries).collect(&:name)
|
2011-01-09 05:13:54 +03:00
|
|
|
changesets = assigns(:changesets)
|
2011-03-14 14:03:34 +03:00
|
|
|
assert_not_nil changesets
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2011-03-14 14:03:34 +03:00
|
|
|
assert_equal %w(13 11 10 9), changesets.collect(&:revision)
|
2011-01-09 05:13:54 +03:00
|
|
|
end
|
2011-01-05 18:03:16 +03:00
|
|
|
end
|
|
|
|
|
2011-05-07 11:25:09 +04:00
|
|
|
def test_show_directory_latin_1_path
|
2011-09-12 18:11:40 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-04 14:07:58 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:11:40 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-03-04 14:07:58 +03:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2012-02-23 16:18:03 +04:00
|
|
|
get :show, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['latin-1-dir'])[:param],
|
|
|
|
:rev => r1
|
2011-03-04 14:07:58 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'show'
|
|
|
|
|
|
|
|
assert_not_nil assigns(:entries)
|
|
|
|
assert_equal ["make-latin-1-file.rb",
|
|
|
|
"test-#{@char_1}-1.txt",
|
|
|
|
"test-#{@char_1}-2.txt",
|
|
|
|
"test-#{@char_1}.txt"], assigns(:entries).collect(&:name)
|
|
|
|
changesets = assigns(:changesets)
|
|
|
|
assert_not_nil changesets
|
2011-03-14 13:36:34 +03:00
|
|
|
assert_equal %w(21 20 19 18 17), changesets.collect(&:revision)
|
2011-03-04 14:07:58 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-20 23:46:28 +04:00
|
|
|
def show_should_show_branch_selection_form
|
|
|
|
@repository.fetch_changesets
|
|
|
|
@project.reload
|
|
|
|
get :show, :id => PRJ_ID
|
|
|
|
assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'}
|
|
|
|
assert_tag 'select', :attributes => {:name => 'branch'},
|
|
|
|
:child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}},
|
|
|
|
:parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}}
|
|
|
|
end
|
|
|
|
|
2011-03-14 16:42:16 +03:00
|
|
|
def test_show_branch
|
2011-09-12 18:12:07 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 16:42:16 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:12:07 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-03-14 16:42:16 +03:00
|
|
|
[
|
|
|
|
'default',
|
|
|
|
@branch_char_1,
|
|
|
|
'branch (1)[2]&,%.-3_4',
|
|
|
|
@branch_char_0,
|
|
|
|
'test_branch.latin-1',
|
|
|
|
'test-branch-00',
|
|
|
|
].each do |bra|
|
2011-03-22 14:26:15 +03:00
|
|
|
get :show, :id => PRJ_ID, :rev => bra
|
2011-03-14 16:42:16 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'show'
|
|
|
|
assert_not_nil assigns(:entries)
|
|
|
|
assert assigns(:entries).size > 0
|
|
|
|
assert_not_nil assigns(:changesets)
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2011-03-14 16:42:16 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-14 16:42:37 +03:00
|
|
|
def test_show_tag
|
2011-09-12 18:12:32 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 16:42:37 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:12:32 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-03-14 16:42:37 +03:00
|
|
|
[
|
|
|
|
@tag_char_1,
|
|
|
|
'tag_test.00',
|
|
|
|
'tag-init-revision'
|
|
|
|
].each do |tag|
|
2011-03-22 14:26:15 +03:00
|
|
|
get :show, :id => PRJ_ID, :rev => tag
|
2011-03-14 16:42:37 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'show'
|
|
|
|
assert_not_nil assigns(:entries)
|
|
|
|
assert assigns(:entries).size > 0
|
|
|
|
assert_not_nil assigns(:changesets)
|
2011-07-10 17:11:16 +04:00
|
|
|
assert assigns(:changesets).size > 0
|
2011-03-14 16:42:37 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-12-20 01:14:03 +03:00
|
|
|
def test_changes
|
2012-02-23 16:18:03 +04:00
|
|
|
get :changes, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'changes'
|
|
|
|
assert_tag :tag => 'h2', :content => 'edit.png'
|
|
|
|
end
|
2011-05-07 10:38:45 +04:00
|
|
|
|
2007-12-20 01:14:03 +03:00
|
|
|
def test_entry_show
|
2012-02-23 16:18:03 +04:00
|
|
|
get :entry, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'entry'
|
2011-01-05 18:01:39 +03:00
|
|
|
# Line 10
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_tag :tag => 'th',
|
2011-01-05 18:01:39 +03:00
|
|
|
:content => '10',
|
|
|
|
:attributes => { :class => 'line-num' },
|
2007-12-20 01:14:03 +03:00
|
|
|
:sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
|
|
|
|
end
|
2011-03-04 14:07:58 +03:00
|
|
|
|
2011-05-07 11:25:09 +04:00
|
|
|
def test_entry_show_latin_1_path
|
2011-03-04 14:07:58 +03:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2011-05-07 11:25:09 +04:00
|
|
|
get :entry, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
|
|
|
:rev => r1
|
2011-03-04 14:07:58 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'entry'
|
|
|
|
assert_tag :tag => 'th',
|
|
|
|
:content => '1',
|
|
|
|
:attributes => { :class => 'line-num' },
|
2011-03-22 14:26:15 +03:00
|
|
|
:sibling => { :tag => 'td',
|
|
|
|
:content => /Mercurial is a distributed version control system/ }
|
2011-03-04 14:07:58 +03:00
|
|
|
end
|
|
|
|
end
|
2011-05-07 10:38:45 +04:00
|
|
|
|
2011-05-07 17:36:07 +04:00
|
|
|
def test_entry_show_latin_1_contents
|
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
[27, '27', '7bbf4c738e71'].each do |r1|
|
|
|
|
get :entry, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
|
|
|
:rev => r1
|
2011-05-07 17:36:07 +04:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'entry'
|
|
|
|
assert_tag :tag => 'th',
|
|
|
|
:content => '1',
|
|
|
|
:attributes => { :class => 'line-num' },
|
|
|
|
:sibling => { :tag => 'td',
|
|
|
|
:content => /test-#{@char_1}.txt/ }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-12-20 01:14:03 +03:00
|
|
|
def test_entry_download
|
2011-05-07 11:25:53 +04:00
|
|
|
get :entry, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
|
|
|
:format => 'raw'
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
|
|
|
# File content
|
|
|
|
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
|
|
|
end
|
2008-04-27 14:12:15 +04:00
|
|
|
|
2011-03-22 14:26:57 +03:00
|
|
|
def test_entry_binary_force_download
|
2012-02-23 16:18:03 +04:00
|
|
|
get :entry, :id => PRJ_ID, :rev => 1,
|
|
|
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
2011-03-22 14:26:57 +03:00
|
|
|
assert_response :success
|
2011-03-22 19:56:52 +03:00
|
|
|
assert_equal 'image/png', @response.content_type
|
2011-03-22 14:26:57 +03:00
|
|
|
end
|
|
|
|
|
2008-04-27 14:12:15 +04:00
|
|
|
def test_directory_entry
|
2012-02-23 16:18:03 +04:00
|
|
|
get :entry, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['sources'])[:param]
|
2008-04-27 14:12:15 +04:00
|
|
|
assert_response :success
|
2009-08-16 02:41:40 +04:00
|
|
|
assert_template 'show'
|
2008-04-27 14:12:15 +04:00
|
|
|
assert_not_nil assigns(:entry)
|
|
|
|
assert_equal 'sources', assigns(:entry).name
|
|
|
|
end
|
2011-03-22 14:26:57 +03:00
|
|
|
|
2007-12-20 01:14:03 +03:00
|
|
|
def test_diff
|
2011-09-12 18:12:57 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-11 19:04:28 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:12:57 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 05:13:54 +03:00
|
|
|
[4, '4', 'def6d2f1254a'].each do |r1|
|
|
|
|
# Full diff of changeset 4
|
2011-06-01 11:45:48 +04:00
|
|
|
['inline', 'sbs'].each do |dt|
|
|
|
|
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'diff'
|
|
|
|
if @diff_c_support
|
|
|
|
# Line 22 removed
|
|
|
|
assert_tag :tag => 'th',
|
|
|
|
:content => '22',
|
|
|
|
:sibling => { :tag => 'td',
|
|
|
|
:attributes => { :class => /diff_out/ },
|
|
|
|
:content => /def remove/ }
|
|
|
|
assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
|
|
|
|
end
|
2011-01-11 19:04:28 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_diff_two_revs
|
2011-09-12 18:13:22 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-11 19:04:28 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:13:22 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-11 19:04:28 +03:00
|
|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
|
|
|
[4, 'def6d2f1254a'].each do |r2|
|
2011-06-01 11:46:35 +04:00
|
|
|
['inline', 'sbs'].each do |dt|
|
|
|
|
get :diff,
|
|
|
|
:id => PRJ_ID,
|
|
|
|
:rev => r1,
|
|
|
|
:rev_to => r2,
|
|
|
|
:type => dt
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'diff'
|
|
|
|
diff = assigns(:diff)
|
|
|
|
assert_not_nil diff
|
|
|
|
assert_tag :tag => 'h2',
|
|
|
|
:content => /4:def6d2f1254a 2:400bb8672109/
|
|
|
|
end
|
2011-01-11 08:15:56 +03:00
|
|
|
end
|
2011-01-09 05:13:54 +03:00
|
|
|
end
|
2007-12-20 01:14:03 +03:00
|
|
|
end
|
2011-01-09 04:30:18 +03:00
|
|
|
|
2011-05-07 11:25:09 +04:00
|
|
|
def test_diff_latin_1_path
|
2011-05-07 17:35:31 +04:00
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
[21, 'adf805632193'].each do |r1|
|
2011-06-01 11:47:19 +04:00
|
|
|
['inline', 'sbs'].each do |dt|
|
|
|
|
get :diff, :id => PRJ_ID, :rev => r1, :type => dt
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'diff'
|
|
|
|
assert_tag :tag => 'thead',
|
2011-05-07 17:35:31 +04:00
|
|
|
:descendant => {
|
2011-06-01 11:47:19 +04:00
|
|
|
:tag => 'th',
|
|
|
|
:attributes => { :class => 'filename' } ,
|
|
|
|
:content => /latin-1-dir\/test-#{@char_1}-2.txt/ ,
|
|
|
|
},
|
|
|
|
:sibling => {
|
|
|
|
:tag => 'tbody',
|
|
|
|
:descendant => {
|
|
|
|
:tag => 'td',
|
|
|
|
:attributes => { :class => /diff_in/ },
|
|
|
|
:content => /It is written in Python/
|
|
|
|
}
|
2011-05-07 17:35:31 +04:00
|
|
|
}
|
2011-06-01 11:47:19 +04:00
|
|
|
end
|
2011-05-07 17:35:31 +04:00
|
|
|
end
|
2011-03-04 14:07:58 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-19 06:29:11 +04:00
|
|
|
def test_diff_should_show_modified_filenames
|
|
|
|
get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline'
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'diff'
|
|
|
|
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_diff_should_show_deleted_filenames
|
|
|
|
get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline'
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'diff'
|
|
|
|
assert_select 'th.filename', :text => 'sources/welcome_controller.rb'
|
|
|
|
end
|
|
|
|
|
2007-12-20 01:14:03 +03:00
|
|
|
def test_annotate
|
2012-02-23 16:18:03 +04:00
|
|
|
get :annotate, :id => PRJ_ID,
|
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2007-12-20 01:14:03 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'annotate'
|
2012-07-28 22:16:55 +04:00
|
|
|
|
2012-07-28 22:11:03 +04:00
|
|
|
# Line 22, revision 4:def6d2f1254a
|
2012-07-28 22:16:55 +04:00
|
|
|
assert_select 'tr' do
|
|
|
|
assert_select 'th.line-num', :text => '22'
|
|
|
|
assert_select 'td.revision', :text => '4:def6d2f1254a'
|
|
|
|
assert_select 'td.author', :text => 'jsmith'
|
|
|
|
assert_select 'td', :text => /remove_watcher/
|
|
|
|
end
|
2007-12-20 01:14:03 +03:00
|
|
|
end
|
2011-01-13 15:04:51 +03:00
|
|
|
|
2011-06-10 11:05:36 +04:00
|
|
|
def test_annotate_not_in_tip
|
2011-09-12 18:13:47 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-06-10 11:05:36 +04:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:13:47 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-06-10 11:05:36 +04:00
|
|
|
get :annotate, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
|
2011-06-10 11:05:36 +04:00
|
|
|
assert_response 404
|
|
|
|
assert_error_tag :content => /was not found/
|
|
|
|
end
|
|
|
|
|
2011-01-21 16:22:28 +03:00
|
|
|
def test_annotate_at_given_revision
|
2011-09-12 18:14:09 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-21 16:22:28 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:14:09 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-21 16:22:28 +03:00
|
|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
2011-05-07 11:25:53 +04:00
|
|
|
get :annotate, :id => PRJ_ID, :rev => r1,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2011-01-21 16:22:28 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'annotate'
|
|
|
|
assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-07 11:25:09 +04:00
|
|
|
def test_annotate_latin_1_path
|
2011-03-04 14:07:58 +03:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2011-05-07 18:10:43 +04:00
|
|
|
get :annotate, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param],
|
|
|
|
:rev => r1
|
2011-03-04 14:07:58 +03:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'annotate'
|
2013-09-18 09:01:35 +04:00
|
|
|
assert_select "th.line-num", :text => '1' do
|
|
|
|
assert_select "+ td.revision" do
|
|
|
|
assert_select "a", :text => '20:709858aafd1b'
|
|
|
|
assert_select "+ td.author", :text => "jsmith" do
|
|
|
|
assert_select "+ td",
|
|
|
|
:text => "Mercurial is a distributed version control system."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-03-04 14:07:58 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-07 18:22:42 +04:00
|
|
|
def test_annotate_latin_1_contents
|
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
[27, '7bbf4c738e71'].each do |r1|
|
|
|
|
get :annotate, :id => PRJ_ID,
|
2012-02-23 16:18:03 +04:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param],
|
|
|
|
:rev => r1
|
2011-05-07 18:22:42 +04:00
|
|
|
assert_tag :tag => 'th',
|
|
|
|
:content => '1',
|
|
|
|
:attributes => { :class => 'line-num' },
|
|
|
|
:sibling => { :tag => 'td',
|
|
|
|
:content => /test-#{@char_1}.txt/ }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-30 11:41:17 +04:00
|
|
|
def test_revision
|
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
@repository.fetch_changesets
|
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
|
|
|
['1', '9d5b5b', '9d5b5b004199'].each do |r|
|
|
|
|
with_settings :default_language => "en" do
|
|
|
|
get :revision, :id => PRJ_ID, :rev => r
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'revision'
|
|
|
|
assert_select 'title',
|
2013-05-30 12:05:44 +04:00
|
|
|
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
2013-05-30 11:41:17 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-01-13 15:04:51 +03:00
|
|
|
def test_empty_revision
|
2011-09-12 18:14:32 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-13 15:04:51 +03:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:14:32 +04:00
|
|
|
@project.reload
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-13 15:04:51 +03:00
|
|
|
['', ' ', nil].each do |r|
|
2011-03-22 14:26:15 +03:00
|
|
|
get :revision, :id => PRJ_ID, :rev => r
|
2011-01-14 23:22:36 +03:00
|
|
|
assert_response 404
|
2011-01-13 15:04:51 +03:00
|
|
|
assert_error_tag :content => /was not found/
|
|
|
|
end
|
|
|
|
end
|
2011-07-11 04:15:34 +04:00
|
|
|
|
|
|
|
def test_destroy_valid_repository
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2011-09-12 18:02:24 +04:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-07-11 04:15:34 +04:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 18:02:24 +04:00
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-07-11 04:15:34 +04:00
|
|
|
|
2012-01-15 18:23:06 +04:00
|
|
|
assert_difference 'Repository.count', -1 do
|
|
|
|
delete :destroy, :id => @repository.id
|
|
|
|
end
|
2011-07-11 04:15:34 +04:00
|
|
|
assert_response 302
|
|
|
|
@project.reload
|
|
|
|
assert_nil @project.repository
|
|
|
|
end
|
2011-07-11 04:56:49 +04:00
|
|
|
|
|
|
|
def test_destroy_invalid_repository
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2012-01-15 18:23:06 +04:00
|
|
|
@project.repository.destroy
|
|
|
|
@repository = Repository::Mercurial.create!(
|
2011-07-11 04:56:49 +04:00
|
|
|
:project => Project.find(PRJ_ID),
|
|
|
|
:url => "/invalid",
|
|
|
|
:path_encoding => 'ISO-8859-1'
|
|
|
|
)
|
|
|
|
@repository.fetch_changesets
|
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
|
2012-01-15 18:23:06 +04:00
|
|
|
assert_difference 'Repository.count', -1 do
|
|
|
|
delete :destroy, :id => @repository.id
|
|
|
|
end
|
2011-07-11 04:56:49 +04:00
|
|
|
assert_response 302
|
|
|
|
@project.reload
|
|
|
|
assert_nil @project.repository
|
|
|
|
end
|
2007-12-20 01:14:03 +03:00
|
|
|
else
|
|
|
|
puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
|
|
|
|
def test_fake; assert true end
|
2007-12-14 20:46:45 +03:00
|
|
|
end
|
|
|
|
end
|