summaryrefslogtreecommitdiffstats
path: root/test/functional/repositories_darcs_controller_test.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-03-01 07:38:05 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-03-01 07:38:05 +0000
commitf2c750c3e9fc188ae2efc471ffebe37f1e634431 (patch)
tree73b96cecb2c6ededda02b2cd1c25b8df2256c122 /test/functional/repositories_darcs_controller_test.rb
parent984283dde99a094039429f6b9c0c6b9a40ccb031 (diff)
downloadredmine-f2c750c3e9fc188ae2efc471ffebe37f1e634431.tar.gz
redmine-f2c750c3e9fc188ae2efc471ffebe37f1e634431.zip
scm: darcs: refactor functional test.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4979 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/repositories_darcs_controller_test.rb')
-rw-r--r--test/functional/repositories_darcs_controller_test.rb43
1 files changed, 28 insertions, 15 deletions
diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb
index 0a5d57a8b..a315f9fa8 100644
--- a/test/functional/repositories_darcs_controller_test.rb
+++ b/test/functional/repositories_darcs_controller_test.rb
@@ -26,26 +26,33 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
# No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/darcs_repository'
+ PRJ_ID = 3
def setup
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
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
-
+
if File.directory?(REPOSITORY_PATH)
def test_show
- get :show, :id => 3
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_not_nil assigns(:changesets)
end
-
+
def test_browse_root
- get :show, :id => 3
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
@@ -54,9 +61,11 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
end
-
+
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_template 'show'
assert_not_nil assigns(:entries)
@@ -66,27 +75,31 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
assert_equal 'file', entry.kind
assert_equal 'images/edit.png', entry.path
end
-
+
def test_browse_at_given_revision
- Project.find(3).repository.fetch_changesets
- get :show, :id => 3, :path => ['images'], :rev => 1
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_equal ['delete.png'], assigns(:entries).collect(&:name)
end
-
+
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_template 'changes'
assert_tag :tag => 'h2', :content => 'edit.png'
end
-
+
def test_diff
- Project.find(3).repository.fetch_changesets
+ @repository.fetch_changesets
+ @repository.reload
# Full diff of changeset 5
- get :diff, :id => 3, :rev => 5
+ get :diff, :id => PRJ_ID, :rev => 5
assert_response :success
assert_template 'diff'
# Line 22 removed