diff options
Diffstat (limited to 'test/functional/repositories_controller_test.rb')
-rw-r--r-- | test/functional/repositories_controller_test.rb | 165 |
1 files changed, 132 insertions, 33 deletions
diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 5fec94c37..72ed05a2c 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -28,7 +28,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_new @request.session[:user_id] = 1 - get :new, :project_id => 'subproject1' + get :new, :params => { + :project_id => 'subproject1' + } assert_response :success assert_select 'select[name=?]', 'repository_scm' do assert_select 'option[value=?][selected=selected]', 'Subversion' @@ -39,7 +41,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_new_should_propose_enabled_scm_only @request.session[:user_id] = 1 with_settings :enabled_scm => ['Mercurial', 'Git'] do - get :new, :project_id => 'subproject1' + get :new, :params => { + :project_id => 'subproject1' + } end assert_response :success @@ -52,7 +56,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_get_new_with_type @request.session[:user_id] = 1 - get :new, :project_id => 'subproject1', :repository_scm => 'Git' + get :new, :params => { + :project_id => 'subproject1', + :repository_scm => 'Git' + } assert_response :success assert_select 'select[name=?]', 'repository_scm' do @@ -63,9 +70,15 @@ class RepositoriesControllerTest < Redmine::ControllerTest 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', :is_default => '1', :identifier => ''} + post :create, :params => { + :project_id => 'subproject1', + :repository_scm => 'Subversion', + :repository => { + :url => 'file:///test', + :is_default => '1', + :identifier => '' + } + } end assert_response 302 repository = Repository.order('id DESC').first @@ -76,9 +89,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest 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'} + post :create, :params => { + :project_id => 'subproject1', + :repository_scm => 'Subversion', + :repository => { + :url => 'invalid' + } + } end assert_response :success assert_select_error /URL is invalid/ @@ -89,21 +106,33 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_edit @request.session[:user_id] = 1 - get :edit, :id => 11 + get :edit, :params => { + :id => 11 + } assert_response :success assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test' end def test_update @request.session[:user_id] = 1 - put :update, :id => 11, :repository => {:password => 'test_update'} + put :update, :params => { + :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} + put :update, :params => { + :id => 11, + :repository => { + :password => 'x'*260 + } + } assert_response :success assert_select_error /Password is too long/ end @@ -111,7 +140,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_destroy @request.session[:user_id] = 1 assert_difference 'Repository.count', -1 do - delete :destroy, :id => 11 + delete :destroy, :params => { + :id => 11 + } end assert_response 302 assert_nil Repository.find_by_id(11) @@ -121,7 +152,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest Repository::Subversion.any_instance.expects(:fetch_changesets).once with_settings :autofetch_changesets => '1' do - get :show, :id => 1 + get :show, :params => { + :id => 1 + } end end @@ -129,7 +162,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest Repository::Subversion.any_instance.expects(:fetch_changesets).never with_settings :autofetch_changesets => '0' do - get :show, :id => 1 + get :show, :params => { + :id => 1 + } end end @@ -138,12 +173,16 @@ class RepositoriesControllerTest < Redmine::ControllerTest Project.find(1).close with_settings :autofetch_changesets => '1' do - get :show, :id => 1 + get :show, :params => { + :id => 1 + } end end def test_revisions - get :revisions, :id => 1 + get :revisions, :params => { + :id => 1 + } assert_response :success assert_select 'table.changesets' end @@ -151,18 +190,27 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_revisions_for_other_repository repository = Repository::Subversion.create!(:project_id => 1, :identifier => 'foo', :url => 'file:///foo') - get :revisions, :id => 1, :repository_id => 'foo' + get :revisions, :params => { + :id => 1, + :repository_id => 'foo' + } assert_response :success assert_select 'table.changesets' end def test_revisions_for_invalid_repository - get :revisions, :id => 1, :repository_id => 'foo' + get :revisions, :params => { + :id => 1, + :repository_id => 'foo' + } assert_response 404 end def test_revision - get :revision, :id => 1, :rev => 1 + get :revision, :params => { + :id => 1, + :rev => 1 + } assert_response :success assert_select 'h2', :text => 'Revision 1' end @@ -171,7 +219,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest Changeset.where(:id => 100).update_all(:comments => 'Simple *text*') with_settings :commit_logs_formatting => '0' do - get :revision, :id => 1, :rev => 1 + get :revision, :params => { + :id => 1, + :rev => 1 + } assert_response :success assert_select '.changeset-comments', :text => 'Simple *text*' end @@ -181,7 +232,10 @@ class RepositoriesControllerTest < Redmine::ControllerTest Role.find(1).add_permission! :manage_related_issues @request.session[:user_id] = 2 - get :revision, :id => 1, :rev => 1 + get :revision, :params => { + :id => 1, + :rev => 1 + } assert_response :success assert_select 'form[action=?]', '/projects/ecookbook/repository/revisions/1/issues' do @@ -190,14 +244,20 @@ class RepositoriesControllerTest < Redmine::ControllerTest end def test_revision_should_not_change_the_project_menu_link - get :revision, :id => 1, :rev => 1 + get :revision, :params => { + :id => 1, + :rev => 1 + } assert_response :success assert_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository' end def test_revision_with_before_nil_and_afer_normal - get :revision, {:id => 1, :rev => 1} + get :revision, :params => { + :id => 1, + :rev => 1 + } assert_response :success assert_select 'div.contextual' do @@ -209,7 +269,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_add_related_issue @request.session[:user_id] = 2 assert_difference 'Changeset.find(103).issues.size' do - xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js' + post :add_related_issue, :params => { + :id => 1, + :rev => 4, + :issue_id => 2, + :format => 'js' + }, + :xhr => true assert_response :success assert_equal 'text/javascript', response.content_type end @@ -221,7 +287,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_add_related_issue_should_accept_issue_id_with_sharp @request.session[:user_id] = 2 assert_difference 'Changeset.find(103).issues.size' do - xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => "#2", :format => 'js' + post :add_related_issue, :params => { + :id => 1, + :rev => 4, + :issue_id => "#2", + :format => 'js' + }, + :xhr => true end assert_equal [2], Changeset.find(103).issue_ids end @@ -229,7 +301,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest def test_add_related_issue_with_invalid_issue_id @request.session[:user_id] = 2 assert_no_difference 'Changeset.find(103).issues.size' do - xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999, :format => 'js' + post :add_related_issue, :params => { + :id => 1, + :rev => 4, + :issue_id => 9999, + :format => 'js' + }, + :xhr => true assert_response :success assert_equal 'text/javascript', response.content_type end @@ -242,7 +320,13 @@ class RepositoriesControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 assert_difference 'Changeset.find(103).issues.size', -1 do - xhr :delete, :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js' + delete :remove_related_issue, :params => { + :id => 1, + :rev => 4, + :issue_id => 2, + :format => 'js' + }, + :xhr => true assert_response :success assert_equal 'text/javascript', response.content_type end @@ -256,13 +340,19 @@ class RepositoriesControllerTest < Redmine::ControllerTest assert_not_nil latest Date.stubs(:today).returns(latest.to_date + 10) - get :graph, :id => 1, :graph => 'commits_per_month' + get :graph, :params => { + :id => 1, + :graph => 'commits_per_month' + } assert_response :success assert_equal 'image/svg+xml', @response.content_type end def test_graph_commits_per_author - get :graph, :id => 1, :graph => 'commits_per_author' + get :graph, :params => { + :id => 1, + :graph => 'commits_per_author' + } assert_response :success assert_equal 'image/svg+xml', @response.content_type end @@ -278,7 +368,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest :comments => 'Committed by foo.' ) - get :committers, :id => 10 + get :committers, :params => { + :id => 10 + } assert_response :success assert_select 'input[value=dlopper] + select option[value="3"][selected=selected]', :text => 'Dave Lopper' @@ -289,7 +381,9 @@ class RepositoriesControllerTest < Redmine::ControllerTest Changeset.delete_all @request.session[:user_id] = 2 - get :committers, :id => 10 + get :committers, :params => { + :id => 10 + } assert_response :success end @@ -304,7 +398,12 @@ class RepositoriesControllerTest < Redmine::ControllerTest :comments => 'Committed by foo.' ) assert_no_difference "Changeset.where(:user_id => 3).count" do - post :committers, :id => 10, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']} + post :committers, :params => { + :id => 10, + :committers => { + '0' => ['foo', '2'], '1' => ['dlopper', '3'] + } + } assert_response 302 assert_equal User.find(2), c.reload.user end |