From e67afc88866ad6c85b8453c232e914ae55a62c76 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 3 Dec 2011 15:13:47 +0000 Subject: [PATCH] Test for repository edit and cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8052 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../repositories_bazaar_controller_test.rb | 20 ++++++++++++------- .../repositories_cvs_controller_test.rb | 20 ++++++++++++------- .../repositories_darcs_controller_test.rb | 20 ++++++++++++------- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/test/functional/repositories_bazaar_controller_test.rb b/test/functional/repositories_bazaar_controller_test.rb index 7e963ac1f..0273ef8cd 100644 --- a/test/functional/repositories_bazaar_controller_test.rb +++ b/test/functional/repositories_bazaar_controller_test.rb @@ -16,12 +16,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require File.expand_path('../../test_helper', __FILE__) -require 'repositories_controller' - -# Re-raise errors caught by the controller. -class RepositoriesController; def rescue_action(e) raise e end; end class RepositoriesBazaarControllerTest < ActionController::TestCase + tests RepositoriesController + fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules @@ -29,9 +27,6 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase PRJ_ID = 3 def setup - @controller = RepositoriesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new User.current = nil @project = Project.find(PRJ_ID) @repository = Repository::Bazaar.create( @@ -42,6 +37,17 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) + def test_get_edit + @request.session[:user_id] = 1 + @project.repository.destroy + xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Bazaar' + assert_response :success + assert_equal 'text/javascript', @response.content_type + 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 get :show, :id => PRJ_ID assert_response :success diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb index 425a16431..a3de673dc 100644 --- a/test/functional/repositories_cvs_controller_test.rb +++ b/test/functional/repositories_cvs_controller_test.rb @@ -16,12 +16,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require File.expand_path('../../test_helper', __FILE__) -require 'repositories_controller' - -# Re-raise errors caught by the controller. -class RepositoriesController; def rescue_action(e) raise e end; end class RepositoriesCvsControllerTest < ActionController::TestCase + tests RepositoriesController + fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules @@ -33,9 +31,6 @@ class RepositoriesCvsControllerTest < ActionController::TestCase NUM_REV = 7 def setup - @controller = RepositoriesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new Setting.default_language = 'en' User.current = nil @@ -48,6 +43,17 @@ class RepositoriesCvsControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) + def test_get_edit + @request.session[:user_id] = 1 + @project.repository.destroy + xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Cvs' + assert_response :success + assert_equal 'text/javascript', @response.content_type + 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 assert_equal 0, @repository.changesets.count @repository.fetch_changesets diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb index 4bc399b19..07d845a21 100644 --- a/test/functional/repositories_darcs_controller_test.rb +++ b/test/functional/repositories_darcs_controller_test.rb @@ -16,12 +16,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require File.expand_path('../../test_helper', __FILE__) -require 'repositories_controller' - -# Re-raise errors caught by the controller. -class RepositoriesController; def rescue_action(e) raise e end; end class RepositoriesDarcsControllerTest < ActionController::TestCase + tests RepositoriesController + fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules @@ -30,9 +28,6 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase NUM_REV = 6 def setup - @controller = RepositoriesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new User.current = nil @project = Project.find(PRJ_ID) @repository = Repository::Darcs.create( @@ -44,6 +39,17 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase end if File.directory?(REPOSITORY_PATH) + def test_get_edit + @request.session[:user_id] = 1 + @project.repository.destroy + xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Darcs' + assert_response :success + assert_equal 'text/javascript', @response.content_type + 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 assert_equal 0, @repository.changesets.count @repository.fetch_changesets