scm: subversion: change some functional tests project id from 1 to 3.

TODO: remaining tests read fixture. All tests need to read test repository.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4896 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-02-21 03:59:30 +00:00 committed by Eric Davis
parent cc2d6f3605
commit 748ce27728
1 changed files with 66 additions and 19 deletions

View File

@ -26,17 +26,26 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
:repositories, :issues, :issue_statuses, :changesets, :changes,
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
PRJ_ID = 3
def setup
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
Setting.default_language = 'en'
User.current = nil
@project = Project.find(PRJ_ID)
@repository = Repository::Subversion.create(:project => @project,
:url => "file://#{self.class.repository_path('subversion')}")
assert @repository
end
if repository_configured?('subversion')
def test_show
get :show, :id => 1
@repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@ -44,7 +53,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_browse_root
get :show, :id => 1
@repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@ -53,7 +64,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_browse_directory
get :show, :id => 1, :path => ['subversion_test']
@repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID, :path => ['subversion_test']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@ -65,7 +78,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_browse_at_given_revision
get :show, :id => 1, :path => ['subversion_test'], :rev => 4
@repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID, :path => ['subversion_test'], :rev => 4
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@ -73,7 +88,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_file_changes
get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
@repository.fetch_changesets
@repository.reload
get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
assert_response :success
assert_template 'changes'
@ -93,7 +110,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_directory_changes
get :changes, :id => 1, :path => ['subversion_test', 'folder' ]
@repository.fetch_changesets
@repository.reload
get :changes, :id => PRJ_ID, :path => ['subversion_test', 'folder' ]
assert_response :success
assert_template 'changes'
@ -103,15 +122,19 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_entry
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
@repository.fetch_changesets
@repository.reload
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
assert_response :success
assert_template 'entry'
end
def test_entry_should_send_if_too_big
@repository.fetch_changesets
@repository.reload
# no files in the test repo is larger than 1KB...
with_settings :file_max_size_displayed => 0 do
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
assert_response :success
assert_template ''
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
@ -119,7 +142,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_entry_at_given_revision
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
@repository.fetch_changesets
@repository.reload
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
assert_response :success
assert_template 'entry'
# this line was removed in r3 and file was moved in r6
@ -128,27 +153,36 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_entry_not_found
get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
@repository.fetch_changesets
@repository.reload
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'zzz.c']
assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
:content => /The entry or revision was not found in the repository/
end
def test_entry_download
get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
@repository.fetch_changesets
@repository.reload
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
assert_response :success
assert_template ''
assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
end
def test_directory_entry
get :entry, :id => 1, :path => ['subversion_test', 'folder']
@repository.fetch_changesets
@repository.reload
get :entry, :id => PRJ_ID, :path => ['subversion_test', 'folder']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entry)
assert_equal 'folder', assigns(:entry).name
end
# TODO: this test needs fixtures.
def test_revision
@repository.fetch_changesets
@repository.reload
get :revision, :id => 1, :rev => 2
assert_response :success
assert_template 'revision'
@ -167,25 +201,30 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_invalid_revision
get :revision, :id => 1, :rev => 'something_weird'
@repository.fetch_changesets
@repository.reload
get :revision, :id => PRJ_ID, :rev => 'something_weird'
assert_response 404
assert_error_tag :content => /was not found/
end
def test_invalid_revision_diff
get :diff, :id => 1, :rev => '1', :rev_to => 'something_weird'
get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird'
assert_response 404
assert_error_tag :content => /was not found/
end
def test_empty_revision
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
get :revision, :id => 1, :rev => r
get :revision, :id => PRJ_ID, :rev => r
assert_response 404
assert_error_tag :content => /was not found/
end
end
# TODO: this test needs fixtures.
def test_revision_with_repository_pointing_to_a_subdirectory
r = Project.find(1).repository
# Changes repository url to a subdirectory
@ -209,7 +248,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_revision_diff
get :diff, :id => 1, :rev => 3
@repository.fetch_changesets
@repository.reload
get :diff, :id => PRJ_ID, :rev => 3
assert_response :success
assert_template 'diff'
@ -217,7 +258,9 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_directory_diff
get :diff, :id => 1, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder']
@repository.fetch_changesets
@repository.reload
get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, :path => ['subversion_test', 'folder']
assert_response :success
assert_template 'diff'
@ -230,13 +273,17 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
def test_annotate
get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
@repository.fetch_changesets
@repository.reload
get :annotate, :id => PRJ_ID, :path => ['subversion_test', 'helloworld.c']
assert_response :success
assert_template 'annotate'
end
def test_annotate_at_given_revision
get :annotate, :id => 1, :rev => 8, :path => ['subversion_test', 'helloworld.c']
@repository.fetch_changesets
@repository.reload
get :annotate, :id => PRJ_ID, :rev => 8, :path => ['subversion_test', 'helloworld.c']
assert_response :success
assert_template 'annotate'
assert_tag :tag => 'h2', :content => /@ 8/