scm: darcs: refactor functional test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4979 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-03-01 07:38:05 +00:00
parent 984283dde9
commit f2c750c3e9
1 changed files with 28 additions and 15 deletions

View File

@ -26,18 +26,23 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
# No '..' in the repository path # No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository' REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
PRJ_ID = 3
def setup def setup
@controller = RepositoriesController.new @controller = RepositoriesController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new
User.current = nil User.current = nil
Repository::Darcs.create(:project => Project.find(3), :url => REPOSITORY_PATH) @project = Project.find(PRJ_ID)
@repository = Repository::Darcs.create(:project => @project, :url => REPOSITORY_PATH)
assert @repository
end end
if File.directory?(REPOSITORY_PATH) if File.directory?(REPOSITORY_PATH)
def test_show def test_show
get :show, :id => 3 @repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_not_nil assigns(:entries) assert_not_nil assigns(:entries)
@ -45,7 +50,9 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
end end
def test_browse_root def test_browse_root
get :show, :id => 3 @repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_not_nil assigns(:entries) assert_not_nil assigns(:entries)
@ -56,7 +63,9 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
end end
def test_browse_directory def test_browse_directory
get :show, :id => 3, :path => ['images'] @repository.fetch_changesets
@repository.reload
get :show, :id => PRJ_ID, :path => ['images']
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_not_nil assigns(:entries) assert_not_nil assigns(:entries)
@ -68,8 +77,9 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
end end
def test_browse_at_given_revision def test_browse_at_given_revision
Project.find(3).repository.fetch_changesets @repository.fetch_changesets
get :show, :id => 3, :path => ['images'], :rev => 1 @repository.reload
get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_not_nil assigns(:entries) assert_not_nil assigns(:entries)
@ -77,16 +87,19 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
end end
def test_changes def test_changes
get :changes, :id => 3, :path => ['images', 'edit.png'] @repository.fetch_changesets
@repository.reload
get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
assert_response :success assert_response :success
assert_template 'changes' assert_template 'changes'
assert_tag :tag => 'h2', :content => 'edit.png' assert_tag :tag => 'h2', :content => 'edit.png'
end end
def test_diff def test_diff
Project.find(3).repository.fetch_changesets @repository.fetch_changesets
@repository.reload
# Full diff of changeset 5 # Full diff of changeset 5
get :diff, :id => 3, :rev => 5 get :diff, :id => PRJ_ID, :rev => 5
assert_response :success assert_response :success
assert_template 'diff' assert_template 'diff'
# Line 22 removed # Line 22 removed