Adds support for multiple repositories per project (#779).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8650 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Repository < ActiveRecord::Base
|
||||
generator_for :type => 'Subversion'
|
||||
generator_for :url, :start => 'file:///test/svn'
|
||||
|
||||
generator_for :identifier, :start => 'repo1'
|
||||
end
|
||||
|
||||
Vendored
+2
@@ -7,6 +7,7 @@ repositories_001:
|
||||
password: ""
|
||||
login: ""
|
||||
type: Subversion
|
||||
is_default: true
|
||||
repositories_002:
|
||||
project_id: 2
|
||||
url: svn://localhost/test
|
||||
@@ -15,3 +16,4 @@ repositories_002:
|
||||
password: ""
|
||||
login: ""
|
||||
type: Subversion
|
||||
is_default: true
|
||||
|
||||
@@ -43,19 +43,12 @@ class RepositoriesControllerTest < ActionController::TestCase
|
||||
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'}
|
||||
:repository => {:url => 'file:///test', :is_default => '1', :identifier => ''}
|
||||
end
|
||||
assert_response 302
|
||||
repository = Repository.first(:order => 'id DESC')
|
||||
@@ -113,9 +106,25 @@ class RepositoriesControllerTest < ActionController::TestCase
|
||||
get :revisions, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'revisions'
|
||||
assert_equal Repository.find(10), assigns(:repository)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
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'
|
||||
assert_response :success
|
||||
assert_template 'revisions'
|
||||
assert_equal repository, assigns(:repository)
|
||||
assert_not_nil assigns(:changesets)
|
||||
end
|
||||
|
||||
def test_revisions_for_invalid_repository
|
||||
get :revisions, :id => 1, :repository_id => 'foo'
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_revision
|
||||
get :revision, :id => 1, :rev => 1
|
||||
assert_response :success
|
||||
|
||||
@@ -70,6 +70,29 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
|
||||
:path => "/projects/redmine/repository/statistics" },
|
||||
{ :controller => 'repositories', :action => 'stats', :id => 'redmine' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/graph" },
|
||||
{ :controller => 'repositories', :action => 'graph', :id => 'redmine' }
|
||||
)
|
||||
end
|
||||
|
||||
def test_repositories_with_repository_id
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo" },
|
||||
{ :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/statistics" },
|
||||
{ :controller => 'repositories', :action => 'stats', :id => 'redmine', :repository_id => 'foo' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/graph" },
|
||||
{ :controller => 'repositories', :action => 'graph', :id => 'redmine', :repository_id => 'foo' }
|
||||
)
|
||||
end
|
||||
|
||||
def test_repositories_revisions
|
||||
@@ -153,6 +176,87 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
|
||||
)
|
||||
end
|
||||
|
||||
def test_repositories_revisions_with_repository_id
|
||||
empty_path_param = []
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions" },
|
||||
{ :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions.atom" },
|
||||
{ :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo',
|
||||
:format => 'atom' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457" },
|
||||
{ :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo',
|
||||
:rev => '2457' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/show" },
|
||||
{ :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => empty_path_param, :rev => '2457' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/show/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] , :rev => '2457'}
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/changes" },
|
||||
{ :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => empty_path_param, :rev => '2457' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/changes/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] , :rev => '2457'}
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/diff" },
|
||||
{ :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
|
||||
:rev => '2457' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2457/diff.diff" },
|
||||
{ :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
|
||||
:rev => '2457', :format => 'diff' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param], :rev => '2' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2/entry/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param], :rev => '2' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param], :rev => '2', :format => 'raw' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/revisions/2/annotate/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param], :rev => '2' }
|
||||
)
|
||||
end
|
||||
|
||||
def test_repositories_non_revisions_path
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
@@ -192,7 +296,46 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
def test_repositories_non_revisions_path_with_repository_id
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/diff/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/browse/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'browse', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/entry/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param], :format => 'raw' }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/annotate/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] }
|
||||
)
|
||||
assert_routing(
|
||||
{ :method => 'get',
|
||||
:path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" },
|
||||
{ :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo',
|
||||
:path => @path_hash[:param] }
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def repository_path_hash(arr)
|
||||
hs = {}
|
||||
|
||||
@@ -50,6 +50,19 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||
assert_equal repository, project.repository
|
||||
end
|
||||
|
||||
def test_first_repository_should_be_set_as_default
|
||||
repository1 = Repository::Subversion.new(:project => Project.find(3), :identifier => 'svn1', :url => 'file:///svn1')
|
||||
assert repository1.save
|
||||
assert repository1.is_default?
|
||||
|
||||
repository2 = Repository::Subversion.new(:project => Project.find(3), :identifier => 'svn2', :url => 'file:///svn2')
|
||||
assert repository2.save
|
||||
assert !repository2.is_default?
|
||||
|
||||
assert_equal repository1, Project.find(3).repository
|
||||
assert_equal [repository1, repository2], Project.find(3).repositories.sort
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
changesets = Changeset.count(:all, :conditions => "repository_id = 10")
|
||||
changes = Change.count(:all, :conditions => "repository_id = 10",
|
||||
|
||||
@@ -316,9 +316,8 @@ class UserTest < ActiveSupport::TestCase
|
||||
|
||||
def test_destroy_should_nullify_changesets
|
||||
changeset = Changeset.create!(
|
||||
:repository => Repository::Subversion.create!(
|
||||
:project_id => 1,
|
||||
:url => 'file:///var/svn'
|
||||
:repository => Repository::Subversion.generate!(
|
||||
:project_id => 1
|
||||
),
|
||||
:revision => '12',
|
||||
:committed_on => Time.now,
|
||||
|
||||
Reference in New Issue
Block a user