2011-03-20 18:25:38 +00:00
|
|
|
# Redmine - project management software
|
2017-06-25 08:40:31 +00:00
|
|
|
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
2007-12-12 20:56:22 +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-08 05:08:05 +00:00
|
|
|
#
|
2007-12-12 20:56:22 +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-08 05:08:05 +00:00
|
|
|
#
|
2007-12-12 20:56:22 +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.
|
|
|
|
|
|
2010-12-12 23:24:34 +00:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2007-12-12 20:56:22 +00:00
|
|
|
|
2016-07-14 09:35:49 +00:00
|
|
|
class RepositoriesSubversionControllerTest < Redmine::ControllerTest
|
2011-12-03 08:53:02 +00:00
|
|
|
tests RepositoriesController
|
|
|
|
|
|
2015-01-17 14:14:12 +00:00
|
|
|
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :enabled_modules,
|
2008-09-14 12:41:24 +00:00
|
|
|
:repositories, :issues, :issue_statuses, :changesets, :changes,
|
|
|
|
|
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
|
2007-12-12 20:56:22 +00:00
|
|
|
|
2011-02-21 03:59:30 +00:00
|
|
|
PRJ_ID = 3
|
2011-09-12 11:14:34 +00:00
|
|
|
NUM_REV = 11
|
2011-02-21 03:59:30 +00:00
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def setup
|
2008-02-16 18:09:26 +00:00
|
|
|
Setting.default_language = 'en'
|
2007-12-12 20:56:22 +00:00
|
|
|
User.current = nil
|
2011-02-21 03:59:30 +00:00
|
|
|
|
|
|
|
|
@project = Project.find(PRJ_ID)
|
|
|
|
|
@repository = Repository::Subversion.create(:project => @project,
|
2011-03-20 18:25:38 +00:00
|
|
|
:url => self.class.subversion_repository_url)
|
2011-02-21 03:59:30 +00:00
|
|
|
assert @repository
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
|
|
|
|
|
2010-05-01 08:32:21 +00:00
|
|
|
if repository_configured?('subversion')
|
2012-01-15 14:23:06 +00:00
|
|
|
def test_new
|
2011-12-03 08:47:40 +00:00
|
|
|
@request.session[:user_id] = 1
|
|
|
|
|
@project.repository.destroy
|
2017-05-31 17:32:34 +00:00
|
|
|
get :new, :params => {
|
|
|
|
|
:project_id => 'subproject1',
|
|
|
|
|
:repository_scm => 'Subversion'
|
|
|
|
|
}
|
2011-12-03 08:47:40 +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]', 'Subversion'
|
|
|
|
|
end
|
2011-12-03 08:47:40 +00:00
|
|
|
end
|
|
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def test_show
|
2011-09-12 11:15:18 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 11:15:18 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :show, :params => {
|
|
|
|
|
:id => PRJ_ID
|
|
|
|
|
}
|
2007-12-12 20:56:22 +00:00
|
|
|
assert_response :success
|
2012-01-16 20:22:12 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 1
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => 'subversion_test'
|
|
|
|
|
assert_select 'tr.dir td.filename a[href=?]', '/projects/subproject1/repository/show/subversion_test'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr', 10
|
|
|
|
|
assert_select 'tr td.id a', :text => '11'
|
|
|
|
|
end
|
2012-01-16 20:23:25 +00:00
|
|
|
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'input[name=rev]'
|
|
|
|
|
assert_select 'a', :text => 'Statistics'
|
|
|
|
|
assert_select 'a', :text => 'Atom'
|
|
|
|
|
assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root'
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2012-04-25 17:17:49 +00:00
|
|
|
def test_show_non_default
|
|
|
|
|
Repository::Subversion.create(:project => @project,
|
|
|
|
|
:url => self.class.subversion_repository_url,
|
|
|
|
|
:is_default => false, :identifier => 'svn')
|
|
|
|
|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :show, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:repository_id => 'svn'
|
|
|
|
|
}
|
2012-04-25 17:17:49 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
2014-11-20 19:38:40 +00:00
|
|
|
assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]'
|
2012-04-25 17:17:49 +00:00
|
|
|
# Repository menu should link to the main repo
|
2014-11-20 19:38:40 +00:00
|
|
|
assert_select '#main-menu a[href="/projects/subproject1/repository"]'
|
2012-04-25 17:17:49 +00:00
|
|
|
end
|
|
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def test_browse_directory
|
2011-09-12 13:05:45 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:05:45 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :show, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:path => repository_path_hash(['subversion_test'])[:param]
|
|
|
|
|
}
|
2007-12-12 20:56:22 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 5
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => '[folder_with_brackets]'
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => 'folder'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => '.project'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'helloworld.c'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'textfile.txt'
|
|
|
|
|
end
|
|
|
|
|
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'a.text-x-c', :text => 'helloworld.c'
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2008-04-06 10:35:55 +00:00
|
|
|
|
|
|
|
|
def test_browse_at_given_revision
|
2011-09-12 13:06:13 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:06:13 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :show, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:path => repository_path_hash(['subversion_test'])[:param],
|
2012-02-23 10:10:48 +00:00
|
|
|
:rev => 4
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2008-04-06 10:35:55 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
|
|
|
|
|
assert_select 'table.entries tbody' do
|
|
|
|
|
assert_select 'tr', 5
|
|
|
|
|
assert_select 'tr.dir td.filename a', :text => 'folder'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => '.project'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'helloworld.c'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'helloworld.rb'
|
|
|
|
|
assert_select 'tr.file td.filename a', :text => 'textfile.txt'
|
|
|
|
|
end
|
2008-04-06 10:35:55 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2009-09-01 12:13:17 +00:00
|
|
|
def test_file_changes
|
2011-09-12 13:06:38 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:06:38 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :changes, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2008-07-05 08:59:04 +00:00
|
|
|
assert_response :success
|
2011-05-08 05:08:05 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr', 3
|
|
|
|
|
assert_select 'tr td.id a', :text => '6'
|
|
|
|
|
assert_select 'tr td.id a', :text => '3'
|
|
|
|
|
assert_select 'tr td.id a', :text => '2'
|
|
|
|
|
end
|
2011-05-08 05:08:05 +00:00
|
|
|
|
2009-01-07 20:22:06 +00:00
|
|
|
# svn properties displayed with svn >= 1.5 only
|
|
|
|
|
if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'ul li' do
|
|
|
|
|
assert_select 'b', :text => 'svn:eol-style'
|
|
|
|
|
assert_select 'span', :text => 'native'
|
|
|
|
|
end
|
2009-01-07 20:22:06 +00:00
|
|
|
end
|
2008-07-05 08:59:04 +00:00
|
|
|
end
|
2009-09-01 12:13:17 +00:00
|
|
|
|
|
|
|
|
def test_directory_changes
|
2011-09-12 13:07:05 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:07:05 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :changes, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2009-09-01 12:13:17 +00:00
|
|
|
assert_response :success
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'table.changesets tbody' do
|
|
|
|
|
assert_select 'tr', 6
|
|
|
|
|
assert_select 'tr td.id a', :text => '10'
|
|
|
|
|
assert_select 'tr td.id a', :text => '9'
|
|
|
|
|
assert_select 'tr td.id a', :text => '7'
|
|
|
|
|
assert_select 'tr td.id a', :text => '6'
|
|
|
|
|
assert_select 'tr td.id a', :text => '5'
|
|
|
|
|
assert_select 'tr td.id a', :text => '2'
|
|
|
|
|
end
|
2009-09-01 12:13:17 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def test_entry
|
2011-09-12 13:07:30 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:07:30 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2007-12-12 20:56:22 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'h2 a', :text => 'subversion_test'
|
|
|
|
|
assert_select 'h2 a', :text => 'helloworld.c'
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2016-05-08 08:02:23 +00:00
|
|
|
def test_entry_should_show_other_if_too_big
|
2011-09-12 13:07:55 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:07:55 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2009-02-21 16:04:51 +00:00
|
|
|
# no files in the test repo is larger than 1KB...
|
|
|
|
|
with_settings :file_max_size_displayed => 0 do
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2009-02-21 16:04:51 +00:00
|
|
|
assert_response :success
|
2016-05-08 08:02:23 +00:00
|
|
|
assert_equal 'text/html', @response.content_type
|
|
|
|
|
assert_select 'p.nodata'
|
2009-02-21 16:04:51 +00:00
|
|
|
end
|
|
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2016-04-12 16:53:01 +00:00
|
|
|
def test_entry_should_display_images
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-06-07 17:00:29 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2012-06-07 17:00:29 +00:00
|
|
|
assert_response :success
|
2016-07-21 17:48:05 +00:00
|
|
|
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
|
2012-06-07 17:00:29 +00:00
|
|
|
end
|
|
|
|
|
|
2008-06-15 15:47:28 +00:00
|
|
|
def test_entry_at_given_revision
|
2011-09-12 13:08:19 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:08:19 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
|
|
|
|
|
:rev => 2
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2008-06-15 15:47:28 +00:00
|
|
|
assert_response :success
|
|
|
|
|
# this line was removed in r3 and file was moved in r6
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'td.line-code', :text => /Here's the code/
|
2008-06-15 15:47:28 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2008-01-25 10:55:16 +00:00
|
|
|
def test_entry_not_found
|
2011-09-12 13:08:42 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:08:42 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'zzz.c'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/
|
2008-01-25 10:55:16 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def test_entry_download
|
2011-09-12 13:09:06 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 13:09:06 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :raw, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-05-05 01:01:29 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2007-12-12 20:56:22 +00:00
|
|
|
assert_response :success
|
2009-02-21 16:04:51 +00:00
|
|
|
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2008-04-27 10:12:15 +00:00
|
|
|
def test_directory_entry
|
2011-09-12 12:52:31 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:52:31 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :entry, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
|
2017-05-31 17:32:34 +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 => 'subversion_test'
|
|
|
|
|
assert_select 'h2 a', :text => 'folder'
|
2008-04-27 10:12:15 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2011-02-21 03:59:30 +00:00
|
|
|
# TODO: this test needs fixtures.
|
2008-05-24 17:58:34 +00:00
|
|
|
def test_revision
|
2017-05-31 17:32:34 +00:00
|
|
|
get :revision, :params => {
|
|
|
|
|
:id => 1,
|
|
|
|
|
:rev => 2
|
|
|
|
|
}
|
2008-05-24 17:58:34 +00:00
|
|
|
assert_response :success
|
2012-07-28 18:41:08 +00:00
|
|
|
|
|
|
|
|
assert_select 'ul' do
|
|
|
|
|
assert_select 'li' do
|
|
|
|
|
# link to the entry at rev 2
|
|
|
|
|
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo', :text => 'repo'
|
|
|
|
|
# link to partial diff
|
|
|
|
|
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo'
|
|
|
|
|
end
|
|
|
|
|
end
|
2008-05-24 17:58:34 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2010-12-18 18:37:49 +00:00
|
|
|
def test_invalid_revision
|
2011-09-12 12:53:00 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:53:00 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :revision, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => 'something_weird'
|
|
|
|
|
}
|
2011-01-14 20:22:36 +00:00
|
|
|
assert_response 404
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select_error /was not found/
|
2010-12-18 18:37:49 +00:00
|
|
|
end
|
2011-01-13 12:04:30 +00:00
|
|
|
|
2011-02-17 14:17:04 +00:00
|
|
|
def test_invalid_revision_diff
|
2017-05-31 17:32:34 +00:00
|
|
|
get :diff, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => '1',
|
|
|
|
|
:rev_to => 'something_weird'
|
|
|
|
|
}
|
2011-02-17 14:17:04 +00:00
|
|
|
assert_response 404
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select_error /was not found/
|
2011-02-17 14:17:04 +00:00
|
|
|
end
|
|
|
|
|
|
2011-01-13 12:04:30 +00:00
|
|
|
def test_empty_revision
|
2011-09-12 12:53:34 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:53:34 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-01-13 12:04:30 +00:00
|
|
|
['', ' ', nil].each do |r|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :revision, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => r
|
|
|
|
|
}
|
2011-01-14 20:22:36 +00:00
|
|
|
assert_response 404
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select_error /was not found/
|
2011-01-13 12:04:30 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2011-02-21 03:59:30 +00:00
|
|
|
# TODO: this test needs fixtures.
|
2008-05-24 17:58:34 +00:00
|
|
|
def test_revision_with_repository_pointing_to_a_subdirectory
|
|
|
|
|
r = Project.find(1).repository
|
|
|
|
|
# Changes repository url to a subdirectory
|
|
|
|
|
r.update_attribute :url, (r.url + '/test/some')
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :revision, :params => {
|
|
|
|
|
:id => 1,
|
|
|
|
|
:rev => 2
|
|
|
|
|
}
|
2008-05-24 17:58:34 +00:00
|
|
|
assert_response :success
|
2012-07-28 18:41:08 +00:00
|
|
|
|
|
|
|
|
assert_select 'ul' do
|
|
|
|
|
assert_select 'li' do
|
|
|
|
|
# link to the entry at rev 2
|
|
|
|
|
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo', :text => 'repo'
|
|
|
|
|
# link to partial diff
|
|
|
|
|
assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo'
|
|
|
|
|
end
|
|
|
|
|
end
|
2008-05-24 17:58:34 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2009-09-01 12:13:17 +00:00
|
|
|
def test_revision_diff
|
2011-09-12 12:54:05 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:54:05 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-06-01 06:12:13 +00:00
|
|
|
['inline', 'sbs'].each do |dt|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :diff, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => 3,
|
|
|
|
|
:type => dt
|
|
|
|
|
}
|
2011-06-01 06:12:13 +00:00
|
|
|
assert_response :success
|
2012-09-18 19:44:08 +00:00
|
|
|
assert_select 'h2', :text => /Revision 3/
|
|
|
|
|
assert_select 'th.filename', :text => 'subversion_test/textfile.txt'
|
2011-06-01 06:12:13 +00:00
|
|
|
end
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2009-09-01 12:13:17 +00:00
|
|
|
|
2011-12-03 13:18:00 +00:00
|
|
|
def test_revision_diff_raw_format
|
|
|
|
|
assert_equal 0, @repository.changesets.count
|
|
|
|
|
@repository.fetch_changesets
|
|
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
|
|
|
|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :diff, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => 5,
|
|
|
|
|
:format => 'diff'
|
|
|
|
|
}
|
2011-12-03 13:18:00 +00:00
|
|
|
assert_response :success
|
|
|
|
|
assert_equal 'text/x-patch', @response.content_type
|
2013-12-20 17:17:08 +00:00
|
|
|
assert_equal 'Index: subversion_test/folder/greeter.rb', @response.body.split(/\r?\n/).first
|
2011-12-03 13:18:00 +00:00
|
|
|
end
|
|
|
|
|
|
2009-09-01 12:13:17 +00:00
|
|
|
def test_directory_diff
|
2011-09-12 12:54:39 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:54:39 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-06-01 06:12:34 +00:00
|
|
|
['inline', 'sbs'].each do |dt|
|
2017-05-31 17:32:34 +00:00
|
|
|
get :diff, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => 6,
|
|
|
|
|
:rev_to => 2,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'folder'])[:param],
|
|
|
|
|
:type => dt
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2011-06-01 06:12:34 +00:00
|
|
|
assert_response :success
|
2011-01-09 09:53:50 +00:00
|
|
|
|
2014-11-22 09:38:21 +00:00
|
|
|
assert_select 'h2', :text => /2:6/
|
2016-07-21 17:48:05 +00:00
|
|
|
# 2 files modified
|
|
|
|
|
assert_select 'table.filecontent', 2
|
|
|
|
|
assert_select 'table.filecontent thead th.filename', :text => 'greeter.rb'
|
|
|
|
|
assert_select 'table.filecontent thead th.filename', :text => 'helloworld.rb'
|
2011-06-01 06:12:34 +00:00
|
|
|
end
|
2009-09-01 12:13:17 +00:00
|
|
|
end
|
2011-04-28 11:24:02 +00:00
|
|
|
|
2007-12-12 20:56:22 +00:00
|
|
|
def test_annotate
|
2011-09-12 12:55:07 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:55:07 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :annotate, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
2017-05-31 17:32:34 +00:00
|
|
|
}
|
2007-12-12 20:56:22 +00:00
|
|
|
assert_response :success
|
2012-07-28 18:36:03 +00:00
|
|
|
|
|
|
|
|
assert_select 'tr' do
|
|
|
|
|
assert_select 'th.line-num', :text => '1'
|
|
|
|
|
assert_select 'td.revision', :text => '4'
|
|
|
|
|
assert_select 'td.author', :text => 'jp'
|
|
|
|
|
assert_select 'td', :text => /stdio.h/
|
|
|
|
|
end
|
|
|
|
|
# Same revision
|
|
|
|
|
assert_select 'tr' do
|
|
|
|
|
assert_select 'th.line-num', :text => '2'
|
|
|
|
|
assert_select 'td.revision', :text => ''
|
|
|
|
|
assert_select 'td.author', :text => ''
|
|
|
|
|
end
|
2007-12-12 20:56:22 +00:00
|
|
|
end
|
2011-01-21 13:22:28 +00:00
|
|
|
|
|
|
|
|
def test_annotate_at_given_revision
|
2011-09-12 12:55:48 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-02-21 03:59:30 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:55:48 +00:00
|
|
|
@project.reload
|
|
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2017-05-31 17:32:34 +00:00
|
|
|
get :annotate, :params => {
|
|
|
|
|
:id => PRJ_ID,
|
|
|
|
|
:rev => 8,
|
2012-02-23 10:10:48 +00:00
|
|
|
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
|
2017-05-31 17:32:34 +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 => /@ 8/
|
2011-01-21 13:22:28 +00:00
|
|
|
end
|
2011-07-10 15:47:35 +00:00
|
|
|
|
|
|
|
|
def test_destroy_valid_repository
|
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2011-09-12 12:56:28 +00:00
|
|
|
assert_equal 0, @repository.changesets.count
|
2011-07-10 15:47:35 +00:00
|
|
|
@repository.fetch_changesets
|
2011-09-12 12:56:28 +00:00
|
|
|
assert_equal NUM_REV, @repository.changesets.count
|
2011-07-10 15:47:35 +00:00
|
|
|
|
2012-01-15 14:23:06 +00:00
|
|
|
assert_difference 'Repository.count', -1 do
|
2017-05-31 17:32:34 +00:00
|
|
|
delete :destroy, :params => {
|
|
|
|
|
:id => @repository.id
|
|
|
|
|
}
|
2012-01-15 14:23:06 +00:00
|
|
|
end
|
2011-07-10 15:47:35 +00:00
|
|
|
assert_response 302
|
|
|
|
|
@project.reload
|
|
|
|
|
assert_nil @project.repository
|
|
|
|
|
end
|
|
|
|
|
|
2011-07-10 15:48:21 +00:00
|
|
|
def test_destroy_invalid_repository
|
|
|
|
|
@request.session[:user_id] = 1 # admin
|
2012-01-15 14:23:06 +00:00
|
|
|
@project.repository.destroy
|
|
|
|
|
@repository = Repository::Subversion.create!(
|
2011-07-10 21:47:51 +00:00
|
|
|
:project => @project,
|
|
|
|
|
:url => "file:///invalid")
|
2011-07-10 15:48:21 +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
|
2017-05-31 17:32:34 +00:00
|
|
|
delete :destroy, :params => {
|
|
|
|
|
:id => @repository.id
|
|
|
|
|
}
|
2012-01-15 14:23:06 +00:00
|
|
|
end
|
2011-07-10 15:48:21 +00:00
|
|
|
assert_response 302
|
|
|
|
|
@project.reload
|
|
|
|
|
assert_nil @project.repository
|
|
|
|
|
end
|
2007-12-12 20:56:22 +00:00
|
|
|
else
|
|
|
|
|
puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
|
|
|
|
|
def test_fake; assert true end
|
|
|
|
|
end
|
|
|
|
|
end
|