2019-03-21 03:27:53 +00:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 01:32:57 +00:00
|
|
|
|
2011-05-07 06:38:45 +00:00
|
|
|
# Redmine - project management software
|
2024-02-26 22:55:54 +00:00
|
|
|
# Copyright (C) 2006- Jean-Philippe Lang
|
2007-12-14 17:46:45 +00: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 06:38:45 +00:00
|
|
|
#
|
2007-12-14 17:46:45 +00: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 06:38:45 +00:00
|
|
|
#
|
2007-12-14 17:46:45 +00: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.
|
|
|
|
|
|
2023-01-01 07:13:39 +00:00
|
|
|
require_relative '../test_helper'
|
2007-12-14 17:46:45 +00:00
|
|
|
|
2017-07-23 11:26:04 +00:00
|
|
|
class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
|
2011-12-03 15:06:23 +00:00
|
|
|
tests RepositoriesController
|
|
|
|
|
|
2011-06-10 11:11:00 +00:00
|
|
|
REPOSITORY_PATH = Rails.root.join('tmp/test/mercurial_repository').to_s
|
2011-05-07 07:25:53 +00:00
|
|
|
PRJ_ID = 3
|
2022-09-01 05:16:38 +00:00
|
|
|
NUM_REV = 43
|
2011-03-22 11:26:15 +00:00
|
|
|
|
2007-12-14 17:46:45 +00:00
|
|
|
def setup
|
2017-07-23 11:26:04 +00:00
|
|
|
super
|
2007-12-14 17:46:45 +00:00
|
|
|
User.current = nil
|
2011-07-11 00:14:49 +00:00
|
|
|
@project = Project.find(PRJ_ID)
|
2020-10-02 12:58:50 +00:00
|
|
|
@repository =
|
|
|
|
|
Repository::Mercurial.create(
|
|
|
|
|
:project => @project,
|
|
|
|
|
:url => REPOSITORY_PATH,
|
|
|
|
|
:path_encoding => 'ISO-8859-1'
|
|
|
|
|
)
|
2011-01-11 05:15:56 +00:00
|
|
|
assert @repository
|
2025-04-10 09:42:10 +00:00
|
|
|
skip "SCM command is unavailable" unless @repository.class.scm_available
|
|
|
|
|
|
2011-02-16 11:18:18 +00:00
|
|
|
@diff_c_support = true
|
2007-12-14 17:46:45 +00:00
|
|
|
end
|
2011-01-11 05:15:56 +00:00
|
|
|
|
2019-09-13 05:00:53 +00:00
|
|
|
if Encoding.default_external.to_s != 'UTF-8'
|
2020-12-12 15:50:06 +00:00
|
|
|
puts "TODO: Mercurial functional test fails " \
|
|
|
|
|
"when Encoding.default_external is not UTF-8. " \
|
2020-05-08 12:25:27 +00:00
|
|
|
"Current value is '#{Encoding.default_external}'"
|
2011-03-04 11:07:58 +00:00
|
|
|
def test_fake; assert true end
|
|
|
|
|
elsif File.directory?(REPOSITORY_PATH)
|
2011-12-03 15:06:23 +00:00
|
|
|
|
2012-01-15 14:23:06 +00:00
|
|
|
def test_get_new
|
2011-12-03 15:06:23 +00:00
|
|
|
@request.session[:user_id] = 1
|
|
|
|
|
@project.repository.destroy
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:new,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:project_id => 'subproject1',
|
|
|
|
|
:repository_scm => 'Mercurial'
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-12-03 15:06:23 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'select[name=?]', 'repository_scm' do
|
|
|
|
|
assert_select 'option[value=?][selected=selected]', 'Mercurial'
|
|
|
|
|
end
|
2011-12-03 15:06:23 +00:00
|
|
|
end
|
|
|
|
|
|
2009-08-15 22:41:40 +00:00
|
|
|
def test_show_root
|
2011-09-12 01:15:09 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 10:23:51 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 01:15:09 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 4
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => 'images'
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => 'sources'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => '.hgtags'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'README'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr'
|
|
|
|
|
end
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-01-15 10:15:41 +00:00
|
|
|
|
2009-08-15 22:41:40 +00:00
|
|
|
def test_show_directory
|
2011-09-12 01:15:57 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 10:23:51 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 01:15:57 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:path => repository_path_hash(['images'])[:param]
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 2
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'delete.png'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'edit.png'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr'
|
|
|
|
|
end
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-01-09 02:13:54 +00:00
|
|
|
|
2009-08-15 22:41:40 +00:00
|
|
|
def test_show_at_given_revision
|
2011-09-12 01:16:40 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 10:23:51 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 01:16:40 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 02:13:54 +00:00
|
|
|
[0, '0', '0885933ad4f6'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:path => repository_path_hash(['images'])[:param],
|
2012-02-23 12:18:03 +00:00
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-01-09 02:13:54 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 1
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'delete.png'
|
|
|
|
|
end
|
2018-01-31 17:48:01 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr'
|
|
|
|
|
end
|
2011-01-09 02:13:54 +00:00
|
|
|
end
|
2008-04-06 10:35:55 +00:00
|
|
|
end
|
2011-01-05 15:03:16 +00:00
|
|
|
|
|
|
|
|
def test_show_directory_sql_escape_percent
|
2011-09-12 14:11:14 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 10:23:51 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:11:14 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 02:13:54 +00:00
|
|
|
[13, '13', '3a330eb32958'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sql_escape', 'percent%dir'])[:param],
|
2011-05-07 07:25:53 +00:00
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-01-09 02:13:54 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 2
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'percent%file1.txt'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'percentfile1.txt'
|
|
|
|
|
end
|
2018-01-31 17:48:01 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr td.id a', :text => /^13:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^11:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^10:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^9:/
|
|
|
|
|
end
|
2011-01-09 02:13:54 +00:00
|
|
|
end
|
2011-01-05 15:03:16 +00:00
|
|
|
end
|
|
|
|
|
|
2011-05-07 07:25:09 +00:00
|
|
|
def test_show_directory_latin_1_path
|
2011-09-12 14:11:40 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-04 11:07:58 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:11:40 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-03-04 11:07:58 +00:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['latin-1-dir'])[:param],
|
|
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-03-04 11:07:58 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 4
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => "make-latin-1-file.rb"
|
2019-03-19 15:43:55 +00:00
|
|
|
assert_select 'tr.file td.filename a', :text => "test-Ü-1.txt"
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => "test-Ü-2.txt"
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => "test-Ü.txt"
|
2016-07-21 17:48:05 +00:00
|
|
|
end
|
2018-01-31 17:48:01 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr td.id a', :text => /^21:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^20:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^19:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^18:/
|
|
|
|
|
assert_select 'tr td.id a', :text => /^17:/
|
|
|
|
|
end
|
2011-03-04 11:07:58 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-01-20 19:46:28 +00:00
|
|
|
def show_should_show_branch_selection_form
|
|
|
|
|
@repository.fetch_changesets
|
|
|
|
|
@project.reload
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do
|
|
|
|
|
assert_select 'select[name=branch]' do
|
|
|
|
|
assert_select 'option[value=?]', 'test-branch-01'
|
|
|
|
|
end
|
|
|
|
|
end
|
2012-01-20 19:46:28 +00:00
|
|
|
end
|
|
|
|
|
|
2011-03-14 13:42:16 +00:00
|
|
|
def test_show_branch
|
2011-09-12 14:12:07 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:42:16 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:12:07 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2019-09-14 19:03:31 +00:00
|
|
|
[
|
2020-05-08 12:25:18 +00:00
|
|
|
'default',
|
|
|
|
|
'branch-Ü-01',
|
|
|
|
|
'branch (1)[2]&,%.-3_4',
|
|
|
|
|
'branch-Ü-00',
|
|
|
|
|
'test_branch.latin-1',
|
|
|
|
|
'test-branch-00',
|
2011-03-14 13:42:16 +00:00
|
|
|
].each do |bra|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => bra
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-03-14 13:42:16 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody tr'
|
|
|
|
|
assert_select 'table.changesets tbody tr'
|
2011-03-14 13:42:16 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-03-14 13:42:37 +00:00
|
|
|
def test_show_tag
|
2011-09-12 14:12:32 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-03-14 13:42:37 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:12:32 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2019-09-14 19:03:31 +00:00
|
|
|
[
|
2019-03-19 15:43:55 +00:00
|
|
|
'tag-Ü-00',
|
2011-03-14 13:42:37 +00:00
|
|
|
'tag_test.00',
|
|
|
|
|
'tag-init-revision'
|
|
|
|
|
].each do |tag|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:show,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => tag
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-03-14 13:42:37 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody tr'
|
|
|
|
|
assert_select 'table.changesets tbody tr'
|
2011-03-14 13:42:37 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2007-12-19 22:14:03 +00:00
|
|
|
def test_changes
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:changes,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['images', 'edit.png'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'h2', :text => /edit.png/
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-05-07 06:38:45 +00:00
|
|
|
|
2007-12-19 22:14:03 +00:00
|
|
|
def test_entry_show
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:entry,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
2011-01-05 15:01:39 +00:00
|
|
|
# Line 10
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-03-04 11:07:58 +00:00
|
|
|
|
2011-05-07 07:25:09 +00:00
|
|
|
def test_entry_show_latin_1_path
|
2011-03-04 11:07:58 +00:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:entry,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2020-10-02 12:58:50 +00:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
|
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-03-04 11:07:58 +00:00
|
|
|
assert_response :success
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/
|
2011-03-04 11:07:58 +00:00
|
|
|
end
|
|
|
|
|
end
|
2011-05-07 06:38:45 +00:00
|
|
|
|
2011-05-07 13:36:07 +00:00
|
|
|
def test_entry_show_latin_1_contents
|
|
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
|
[27, '27', '7bbf4c738e71'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:entry,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2020-10-02 12:58:50 +00:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
|
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-05-07 13:36:07 +00:00
|
|
|
assert_response :success
|
2019-03-19 15:43:55 +00:00
|
|
|
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
2011-05-07 13:36:07 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2007-12-19 22:14:03 +00:00
|
|
|
def test_entry_download
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:entry,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param],
|
|
|
|
|
:format => 'raw'
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
|
|
|
|
# File content
|
|
|
|
|
assert @response.body.include?('WITHOUT ANY WARRANTY')
|
|
|
|
|
end
|
2008-04-27 10:12:15 +00:00
|
|
|
|
2011-03-22 11:26:57 +00:00
|
|
|
def test_entry_binary_force_download
|
2016-04-12 16:53:01 +00:00
|
|
|
# TODO: add a binary file which is not an image to the test repo
|
2011-03-22 11:26:57 +00:00
|
|
|
end
|
|
|
|
|
|
2008-04-27 10:12:15 +00:00
|
|
|
def test_directory_entry
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:entry,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2008-04-27 10:12:15 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'h2 a', :text => 'sources'
|
|
|
|
|
assert_select 'table.entries tbody'
|
2008-04-27 10:12:15 +00:00
|
|
|
end
|
2011-03-22 11:26:57 +00:00
|
|
|
|
2007-12-19 22:14:03 +00:00
|
|
|
def test_diff
|
2011-09-12 14:12:57 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-11 16:04:28 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:12:57 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-09 02:13:54 +00:00
|
|
|
[4, '4', 'def6d2f1254a'].each do |r1|
|
|
|
|
|
# Full diff of changeset 4
|
2011-06-01 07:45:48 +00:00
|
|
|
['inline', 'sbs'].each do |dt|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:diff,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => r1,
|
|
|
|
|
:type => dt
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-06-01 07:45:48 +00:00
|
|
|
assert_response :success
|
|
|
|
|
if @diff_c_support
|
|
|
|
|
# Line 22 removed
|
2022-02-19 07:36:40 +00:00
|
|
|
assert_select 'th.line-num[data-txt=22] ~ td.diff_out', :text => /def remove/
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'h2', :text => /4:def6d2f1254a/
|
2011-06-01 07:45:48 +00:00
|
|
|
end
|
2011-01-11 16:04:28 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_diff_two_revs
|
2011-09-12 14:13:22 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-11 16:04:28 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:13:22 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-11 16:04:28 +00:00
|
|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
|
|
|
|
[4, 'def6d2f1254a'].each do |r2|
|
2011-06-01 07:46:35 +00:00
|
|
|
['inline', 'sbs'].each do |dt|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:diff,
|
|
|
|
|
:params => {
|
2011-06-01 07:46:35 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2011-06-01 07:46:35 +00:00
|
|
|
:rev => r1,
|
|
|
|
|
:rev_to => r2,
|
|
|
|
|
:type => dt
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-06-01 07:46:35 +00:00
|
|
|
assert_response :success
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/
|
2011-06-01 07:46:35 +00:00
|
|
|
end
|
2011-01-11 05:15:56 +00:00
|
|
|
end
|
2011-01-09 02:13:54 +00:00
|
|
|
end
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-01-09 01:30:18 +00:00
|
|
|
|
2011-05-07 07:25:09 +00:00
|
|
|
def test_diff_latin_1_path
|
2011-05-07 13:35:31 +00:00
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
|
[21, 'adf805632193'].each do |r1|
|
2011-06-01 07:47:19 +00:00
|
|
|
['inline', 'sbs'].each do |dt|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:diff,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => r1,
|
|
|
|
|
:type => dt
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-06-01 07:47:19 +00:00
|
|
|
assert_response :success
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'table' do
|
2019-03-19 15:43:55 +00:00
|
|
|
assert_select 'thead th.filename', :text => /latin-1-dir\/test-Ü-2.txt/
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'tbody td.diff_in', :text => /It is written in Python/
|
|
|
|
|
end
|
2011-06-01 07:47:19 +00:00
|
|
|
end
|
2011-05-07 13:35:31 +00:00
|
|
|
end
|
2011-03-04 11:07:58 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2012-09-19 02:29:11 +00:00
|
|
|
def test_diff_should_show_modified_filenames
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:diff,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => '400bb8672109',
|
|
|
|
|
:type => 'inline'
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2012-09-19 02:29:11 +00:00
|
|
|
assert_response :success
|
|
|
|
|
assert_select 'th.filename', :text => 'sources/watchers_controller.rb'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_diff_should_show_deleted_filenames
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:diff,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => 'b3a615152df8',
|
|
|
|
|
:type => 'inline'
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2012-09-19 02:29:11 +00:00
|
|
|
assert_response :success
|
|
|
|
|
assert_select 'th.filename', :text => 'sources/welcome_controller.rb'
|
|
|
|
|
end
|
|
|
|
|
|
2007-12-19 22:14:03 +00:00
|
|
|
def test_annotate
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:annotate,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2007-12-19 22:14:03 +00:00
|
|
|
assert_response :success
|
2012-07-28 18:16:55 +00:00
|
|
|
|
2012-07-28 18:11:03 +00:00
|
|
|
# Line 22, revision 4:def6d2f1254a
|
2012-07-28 18:16:55 +00:00
|
|
|
assert_select 'tr' do
|
2022-02-19 07:36:40 +00:00
|
|
|
assert_select 'th.line-num a[data-txt=?]', '22'
|
2012-07-28 18:16:55 +00:00
|
|
|
assert_select 'td.revision', :text => '4:def6d2f1254a'
|
|
|
|
|
assert_select 'td.author', :text => 'jsmith'
|
|
|
|
|
assert_select 'td', :text => /remove_watcher/
|
|
|
|
|
end
|
2007-12-19 22:14:03 +00:00
|
|
|
end
|
2011-01-13 12:04:51 +00:00
|
|
|
|
2011-06-10 07:05:36 +00:00
|
|
|
def test_annotate_not_in_tip
|
2011-09-12 14:13:47 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-06-10 07:05:36 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:13:47 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:annotate,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2024-05-18 05:56:55 +00:00
|
|
|
assert_response :not_found
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select_error /was not found/
|
2011-06-10 07:05:36 +00:00
|
|
|
end
|
|
|
|
|
|
2011-01-21 13:22:28 +00:00
|
|
|
def test_annotate_at_given_revision
|
2011-09-12 14:14:09 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-21 13:22:28 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:14:09 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-21 13:22:28 +00:00
|
|
|
[2, '400bb8672109', '400', 400].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:annotate,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => r1,
|
2012-02-23 12:18:03 +00:00
|
|
|
:path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-01-21 13:22:28 +00:00
|
|
|
assert_response :success
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'h2', :text => /@ 2:400bb8672109/
|
2011-01-21 13:22:28 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-05-07 07:25:09 +00:00
|
|
|
def test_annotate_latin_1_path
|
2011-03-04 11:07:58 +00:00
|
|
|
[21, '21', 'adf805632193'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:annotate,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2020-10-02 12:58:50 +00:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-Ü-2.txt"])[:param],
|
|
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2011-03-04 11:07:58 +00:00
|
|
|
assert_response :success
|
2022-02-19 07:36:40 +00:00
|
|
|
assert_select "th.line-num" do
|
|
|
|
|
assert_select "a[data-txt=?]", '1'
|
2013-09-18 05:01:35 +00:00
|
|
|
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 11:07:58 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-05-07 14:22:42 +00:00
|
|
|
def test_annotate_latin_1_contents
|
|
|
|
|
with_settings :repositories_encodings => 'UTF-8,ISO-8859-1' do
|
|
|
|
|
[27, '7bbf4c738e71'].each do |r1|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:annotate,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2020-10-02 12:58:50 +00:00
|
|
|
:path => repository_path_hash(['latin-1-dir', "test-Ü.txt"])[:param],
|
|
|
|
|
:rev => r1
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2019-03-19 15:43:55 +00:00
|
|
|
assert_select 'tr#L1 td.line-code', :text => /test-Ü.txt/
|
2011-05-07 14:22:42 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2013-05-30 07:41:17 +00: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
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:revision,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => r
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2013-05-30 07:41:17 +00:00
|
|
|
assert_response :success
|
|
|
|
|
assert_select 'title',
|
2013-05-30 08:05:44 +00:00
|
|
|
:text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine'
|
2019-07-30 13:07:31 +00:00
|
|
|
end
|
2013-05-30 07:41:17 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-01-13 12:04:51 +00:00
|
|
|
def test_empty_revision
|
2011-09-12 14:14:32 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-01-13 12:04:51 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:14:32 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-13 12:04:51 +00:00
|
|
|
['', ' ', nil].each do |r|
|
2020-10-02 12:58:50 +00:00
|
|
|
get(
|
|
|
|
|
:revision,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => PRJ_ID,
|
2018-06-16 14:27:51 +00:00
|
|
|
:repository_id => @repository.id,
|
2017-05-31 17:32:34 +00:00
|
|
|
:rev => r
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2024-05-18 05:56:55 +00:00
|
|
|
assert_response :not_found
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select_error /was not found/
|
2011-01-13 12:04:51 +00:00
|
|
|
end
|
|
|
|
|
end
|
2011-07-11 00:15:34 +00:00
|
|
|
|
|
|
|
|
def test_destroy_valid_repository
|
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2011-09-12 14:02:24 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-07-11 00:15:34 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 14:02:24 +00:00
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-07-11 00:15:34 +00:00
|
|
|
|
2012-01-15 14:23:06 +00:00
|
|
|
assert_difference 'Repository.count', -1 do
|
2020-10-02 12:58:50 +00:00
|
|
|
delete(
|
|
|
|
|
:destroy,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => @repository.id
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2012-01-15 14:23:06 +00:00
|
|
|
end
|
2024-05-18 05:56:55 +00:00
|
|
|
assert_response :found
|
2011-07-11 00:15:34 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_nil @project.repository
|
|
|
|
|
end
|
2011-07-11 00:56:49 +00:00
|
|
|
|
|
|
|
|
def test_destroy_invalid_repository
|
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2012-01-15 14:23:06 +00:00
|
|
|
@project.repository.destroy
|
2020-10-02 12:58:50 +00:00
|
|
|
@repository =
|
|
|
|
|
Repository::Mercurial.create!(
|
|
|
|
|
:project => Project.find(PRJ_ID),
|
|
|
|
|
:url => "/invalid",
|
|
|
|
|
:path_encoding => 'ISO-8859-1'
|
|
|
|
|
)
|
2011-07-11 00:56:49 +00:00
|
|
|
@repository.fetch_changesets
|
|
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
|
|
2012-01-15 14:23:06 +00:00
|
|
|
assert_difference 'Repository.count', -1 do
|
2020-10-02 12:58:50 +00:00
|
|
|
delete(
|
|
|
|
|
:destroy,
|
|
|
|
|
:params => {
|
2017-05-31 17:32:34 +00:00
|
|
|
:id => @repository.id
|
|
|
|
|
}
|
2020-10-02 12:58:50 +00:00
|
|
|
)
|
2012-01-15 14:23:06 +00:00
|
|
|
end
|
2024-05-18 05:56:55 +00:00
|
|
|
assert_response :found
|
2011-07-11 00:56:49 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_nil @project.repository
|
|
|
|
|
end
|
2007-12-19 22:14:03 +00:00
|
|
|
else
|
|
|
|
|
puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
|
|
|
|
|
def test_fake; assert true end
|
2007-12-14 17:46:45 +00:00
|
|
|
end
|
|
|
|
|
end
|