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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user