summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-15 14:23:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-15 14:23:06 +0000
commitfb1a2fd7cd4ca7335d660265a32604f6e2006dd6 (patch)
tree444bf09c5a63e91cc314de7c7e9fd78f93d1ff09 /test
parent6f462d373f1b57657082f22f882942d41df47a39 (diff)
downloadredmine-fb1a2fd7cd4ca7335d660265a32604f6e2006dd6.tar.gz
redmine-fb1a2fd7cd4ca7335d660265a32604f6e2006dd6.zip
Resourcified repositories for CRUD operations to prepare for multiple SCM per project (#779).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8648 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/enabled_modules.yml4
-rw-r--r--test/functional/repositories_bazaar_controller_test.rb30
-rw-r--r--test/functional/repositories_controller_test.rb88
-rw-r--r--test/functional/repositories_cvs_controller_test.rb29
-rw-r--r--test/functional/repositories_darcs_controller_test.rb29
-rw-r--r--test/functional/repositories_filesystem_controller_test.rb27
-rw-r--r--test/functional/repositories_git_controller_test.rb29
-rw-r--r--test/functional/repositories_mercurial_controller_test.rb31
-rw-r--r--test/functional/repositories_subversion_controller_test.rb56
-rw-r--r--test/functional/sys_controller_test.rb4
-rw-r--r--test/integration/routing/repositories_test.rb38
11 files changed, 199 insertions, 166 deletions
diff --git a/test/fixtures/enabled_modules.yml b/test/fixtures/enabled_modules.yml
index 3b4eb7ace..d833c20b8 100644
--- a/test/fixtures/enabled_modules.yml
+++ b/test/fixtures/enabled_modules.yml
@@ -99,3 +99,7 @@ enabled_modules_025:
name: news
project_id: 2
id: 25
+enabled_modules_026:
+ name: repository
+ project_id: 2
+ id: 26
diff --git a/test/functional/repositories_bazaar_controller_test.rb b/test/functional/repositories_bazaar_controller_test.rb
index 0273ef8cd..099c05088 100644
--- a/test/functional/repositories_bazaar_controller_test.rb
+++ b/test/functional/repositories_bazaar_controller_test.rb
@@ -37,15 +37,14 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
end
if File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Bazaar'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Bazaar, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_browse_root
@@ -157,10 +156,11 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
@request.session[:user_id] = 1 # admin
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
- @project.reload
assert @repository.changesets.count > 0
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -168,26 +168,18 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert @repository.changesets.count > 0
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Bazaar.create(
+ @project.repository.destroy
+ @repository = Repository::Bazaar.create!(
:project => @project,
:url => "/invalid",
:log_encoding => 'UTF-8')
- assert @repository
@repository.fetch_changesets
@repository.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb
index 5fd82d103..4310c7630 100644
--- a/test/functional/repositories_controller_test.rb
+++ b/test/functional/repositories_controller_test.rb
@@ -22,7 +22,7 @@ require 'repositories_controller'
class RepositoriesController; def rescue_action(e) raise e end; end
class RepositoriesControllerTest < ActionController::TestCase
- fixtures :projects, :users, :roles, :members, :member_roles,
+ fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules,
:repositories, :issues, :issue_statuses, :changesets, :changes,
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
@@ -33,6 +33,82 @@ class RepositoriesControllerTest < ActionController::TestCase
User.current = nil
end
+ def test_new
+ @request.session[:user_id] = 1
+ get :new, :project_id => 'subproject1'
+ assert_response :success
+ assert_template 'new'
+ assert_kind_of Repository::Subversion, assigns(:repository)
+ assert assigns(:repository).new_record?
+ assert_tag 'input', :attributes => {:name => 'repository[url]'}
+ end
+
+ # TODO: remove it when multiple SCM support is added
+ def test_new_with_existing_repository
+ @request.session[:user_id] = 1
+ get :new, :project_id => 'ecookbook'
+ assert_response 302
+ end
+
+ def test_create
+ @request.session[:user_id] = 1
+ assert_difference 'Repository.count' do
+ post :create, :project_id => 'subproject1',
+ :repository_scm => 'Subversion',
+ :repository => {:url => 'file:///test'}
+ end
+ assert_response 302
+ repository = Repository.first(:order => 'id DESC')
+ assert_kind_of Repository::Subversion, repository
+ assert_equal 'file:///test', repository.url
+ end
+
+ def test_create_with_failure
+ @request.session[:user_id] = 1
+ assert_no_difference 'Repository.count' do
+ post :create, :project_id => 'subproject1',
+ :repository_scm => 'Subversion',
+ :repository => {:url => 'invalid'}
+ end
+ assert_response :success
+ assert_template 'new'
+ assert_kind_of Repository::Subversion, assigns(:repository)
+ assert assigns(:repository).new_record?
+ end
+
+ def test_edit
+ @request.session[:user_id] = 1
+ get :edit, :id => 11
+ assert_response :success
+ assert_template 'edit'
+ assert_equal Repository.find(11), assigns(:repository)
+ assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test'}
+ end
+
+ def test_update
+ @request.session[:user_id] = 1
+ put :update, :id => 11, :repository => {:password => 'test_update'}
+ assert_response 302
+ assert_equal 'test_update', Repository.find(11).password
+ end
+
+ def test_update_with_failure
+ @request.session[:user_id] = 1
+ put :update, :id => 11, :repository => {:password => 'x'*260}
+ assert_response :success
+ assert_template 'edit'
+ assert_equal Repository.find(11), assigns(:repository)
+ end
+
+ def test_destroy
+ @request.session[:user_id] = 1
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => 11
+ end
+ assert_response 302
+ assert_nil Repository.find_by_id(11)
+ end
+
def test_revisions
get :revisions, :id => 1
assert_response :success
@@ -71,7 +147,7 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_equal 'image/svg+xml', @response.content_type
end
- def test_committers
+ def test_get_committers
@request.session[:user_id] = 2
# add a commit with an unknown user
Changeset.create!(
@@ -82,7 +158,7 @@ class RepositoriesControllerTest < ActionController::TestCase
:comments => 'Committed by foo.'
)
- get :committers, :id => 1
+ get :committers, :id => 10
assert_response :success
assert_template 'committers'
@@ -99,7 +175,7 @@ class RepositoriesControllerTest < ActionController::TestCase
:descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
end
- def test_map_committers
+ def test_post_committers
@request.session[:user_id] = 2
# add a commit with an unknown user
c = Changeset.create!(
@@ -110,8 +186,8 @@ class RepositoriesControllerTest < ActionController::TestCase
:comments => 'Committed by foo.'
)
assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
- post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
- assert_redirected_to '/projects/ecookbook/repository/committers'
+ post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
+ assert_response 302
assert_equal User.find(2), c.reload.user
end
end
diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb
index a3de673dc..2ad9b856a 100644
--- a/test/functional/repositories_cvs_controller_test.rb
+++ b/test/functional/repositories_cvs_controller_test.rb
@@ -43,15 +43,14 @@ class RepositoriesCvsControllerTest < ActionController::TestCase
end
if File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Cvs'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Cvs'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Cvs, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_browse_root
@@ -247,7 +246,9 @@ class RepositoriesCvsControllerTest < ActionController::TestCase
@project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -255,28 +256,20 @@ class RepositoriesCvsControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert_equal NUM_REV, @repository.changesets.count
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Cvs.create(
+ @project.repository.destroy
+ @repository = Repository::Cvs.create!(
:project => Project.find(PRJ_ID),
:root_url => "/invalid",
:url => MODULE_NAME,
:log_encoding => 'UTF-8'
)
- assert @repository
@repository.fetch_changesets
@project.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb
index 07d845a21..64873fc15 100644
--- a/test/functional/repositories_darcs_controller_test.rb
+++ b/test/functional/repositories_darcs_controller_test.rb
@@ -39,15 +39,14 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
end
if File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Darcs'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Darcs'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Darcs, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_browse_root
@@ -130,7 +129,9 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
@project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -138,27 +139,19 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert_equal NUM_REV, @repository.changesets.count
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Darcs.create(
+ @project.repository.destroy
+ @repository = Repository::Darcs.create!(
:project => @project,
:url => "/invalid",
:log_encoding => 'UTF-8'
)
- assert @repository
@repository.fetch_changesets
@project.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_filesystem_controller_test.rb b/test/functional/repositories_filesystem_controller_test.rb
index 257537893..0b10d8fe3 100644
--- a/test/functional/repositories_filesystem_controller_test.rb
+++ b/test/functional/repositories_filesystem_controller_test.rb
@@ -41,15 +41,14 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
end
if File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Filesystem'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Filesystem'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Filesystem, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_browse_root
@@ -126,7 +125,9 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
def test_destroy_valid_repository
@request.session[:user_id] = 1 # admin
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -134,20 +135,16 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Filesystem.create(
- :project => Project.find(PRJ_ID),
+ @project.repository.destroy
+ @repository = Repository::Filesystem.create!(
+ :project => @project,
:url => "/invalid",
:path_encoding => ''
)
- assert @repository
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb
index 094a6e7f1..33984fdf7 100644
--- a/test/functional/repositories_git_controller_test.rb
+++ b/test/functional/repositories_git_controller_test.rb
@@ -58,15 +58,14 @@ class RepositoriesGitControllerTest < ActionController::TestCase
end
if File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Git'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Git'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Git, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_browse_root
@@ -424,7 +423,9 @@ class RepositoriesGitControllerTest < ActionController::TestCase
@project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -432,27 +433,19 @@ class RepositoriesGitControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert_equal NUM_REV, @repository.changesets.count
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Git.create(
+ @project.repository.destroy
+ @repository = Repository::Git.create!(
:project => @project,
:url => "/invalid",
:path_encoding => 'ISO-8859-1'
)
- assert @repository
@repository.fetch_changesets
@repository.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb
index 1a580a62d..2792a3fdb 100644
--- a/test/functional/repositories_mercurial_controller_test.rb
+++ b/test/functional/repositories_mercurial_controller_test.rb
@@ -60,15 +60,14 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
def test_fake; assert true end
elsif File.directory?(REPOSITORY_PATH)
- def test_get_edit
+ def test_get_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Mercurial'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Mercurial, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
end
def test_show_root
@@ -469,10 +468,11 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
@request.session[:user_id] = 1 # admin
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
- @project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -480,27 +480,18 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert_equal NUM_REV, @repository.changesets.count
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Mercurial.create(
+ @project.repository.destroy
+ @repository = Repository::Mercurial.create!(
:project => Project.find(PRJ_ID),
:url => "/invalid",
:path_encoding => 'ISO-8859-1'
)
- assert @repository
@repository.fetch_changesets
- @project.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb
index a47e8bc0b..0e0de2e3b 100644
--- a/test/functional/repositories_subversion_controller_test.rb
+++ b/test/functional/repositories_subversion_controller_test.rb
@@ -38,40 +38,14 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
end
if repository_configured?('subversion')
- def test_get_edit
+ def test_new
@request.session[:user_id] = 1
@project.repository.destroy
- xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Subversion'
+ get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
assert_response :success
- assert_equal 'text/javascript', @response.content_type
+ assert_template 'new'
assert_kind_of Repository::Subversion, assigns(:repository)
assert assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
- end
-
- def test_post_edit
- @request.session[:user_id] = 1
- @project.repository.destroy
- assert_difference 'Repository.count' do
- xhr :post, :edit, :id => 'subproject1', :repository_scm => 'Subversion', :repository => {:url => 'file:///svn/path'}
- end
- assert_response :success
- assert_equal 'text/javascript', @response.content_type
- assert_kind_of Repository::Subversion, assigns(:repository)
- assert !assigns(:repository).new_record?
- assert_select_rjs :replace_html, 'tab-content-repository'
- end
-
- def test_post_edit_existing_repository
- @request.session[:user_id] = 1
- assert_no_difference 'Repository.count' do
- xhr :post, :edit, :id => 'subproject1', :repository_scm => 'Subversion', :repository => {:password => 'newpassword'}
- end
- assert_response :success
- assert_equal 'text/javascript', @response.content_type
- assert_kind_of Repository::Subversion, assigns(:repository)
- assert_select_rjs :replace_html, 'tab-content-repository'
- assert_equal 'newpassword', Project.find('subproject1').repository.password
end
def test_show
@@ -381,10 +355,11 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
@request.session[:user_id] = 1 # admin
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
- @project.reload
assert_equal NUM_REV, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
@@ -392,25 +367,16 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
def test_destroy_invalid_repository
@request.session[:user_id] = 1 # admin
- assert_equal 0, @repository.changesets.count
- @repository.fetch_changesets
- @project.reload
- assert_equal NUM_REV, @repository.changesets.count
-
- get :destroy, :id => PRJ_ID
- assert_response 302
- @project.reload
- assert_nil @project.repository
-
- @repository = Repository::Subversion.create(
+ @project.repository.destroy
+ @repository = Repository::Subversion.create!(
:project => @project,
:url => "file:///invalid")
- assert @repository
@repository.fetch_changesets
- @project.reload
assert_equal 0, @repository.changesets.count
- get :destroy, :id => PRJ_ID
+ assert_difference 'Repository.count', -1 do
+ delete :destroy, :id => @repository.id
+ end
assert_response 302
@project.reload
assert_nil @project.repository
diff --git a/test/functional/sys_controller_test.rb b/test/functional/sys_controller_test.rb
index e16c90c1d..97368b200 100644
--- a/test/functional/sys_controller_test.rb
+++ b/test/functional/sys_controller_test.rb
@@ -84,13 +84,13 @@ class SysControllerTest < ActionController::TestCase
end
def test_fetch_changesets
- Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true)
+ Repository::Subversion.any_instance.expects(:fetch_changesets).twice.returns(true)
get :fetch_changesets
assert_response :success
end
def test_fetch_changesets_one_project
- Repository::Subversion.any_instance.expects(:fetch_changesets).returns(true)
+ Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true)
get :fetch_changesets, :id => 'ecookbook'
assert_response :success
end
diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb
index 9c1d6ff4e..edc49e70b 100644
--- a/test/integration/routing/repositories_test.rb
+++ b/test/integration/routing/repositories_test.rb
@@ -24,19 +24,47 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
assert_equal %w[path to file.c], @path_hash[:param]
end
- def test_repositories
+ def test_repositories_resources
assert_routing(
{ :method => 'get',
- :path => "/projects/redmine/repository" },
- { :controller => 'repositories', :action => 'show', :id => 'redmine' }
+ :path => "/projects/redmine/repositories/new" },
+ { :controller => 'repositories', :action => 'new', :project_id => 'redmine' }
+ )
+ assert_routing(
+ { :method => 'post',
+ :path => "/projects/redmine/repositories" },
+ { :controller => 'repositories', :action => 'create', :project_id => 'redmine' }
+ )
+ assert_routing(
+ { :method => 'get',
+ :path => "/repositories/1/edit" },
+ { :controller => 'repositories', :action => 'edit', :id => '1' }
+ )
+ assert_routing(
+ { :method => 'put',
+ :path => "/repositories/1" },
+ { :controller => 'repositories', :action => 'update', :id => '1' }
+ )
+ assert_routing(
+ { :method => 'delete',
+ :path => "/repositories/1" },
+ { :controller => 'repositories', :action => 'destroy', :id => '1' }
)
["get", "post"].each do |method|
assert_routing(
{ :method => method,
- :path => "/projects/redmine/repository/edit" },
- { :controller => 'repositories', :action => 'edit', :id => 'redmine' }
+ :path => "/repositories/1/committers" },
+ { :controller => 'repositories', :action => 'committers', :id => '1' }
)
end
+ end
+
+ def test_repositories
+ assert_routing(
+ { :method => 'get',
+ :path => "/projects/redmine/repository" },
+ { :controller => 'repositories', :action => 'show', :id => 'redmine' }
+ )
assert_routing(
{ :method => 'get',
:path => "/projects/redmine/repository/statistics" },