diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-15 18:19:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-15 18:19:19 +0000 |
commit | 1bd5e58c847816ae5751ee0026e55597d1541dd4 (patch) | |
tree | b5c1be1f966f8b08986978713882856d014e363d /test | |
parent | d996cc0584901e7f44171093b170f882978124f7 (diff) | |
download | redmine-1bd5e58c847816ae5751ee0026e55597d1541dd4.tar.gz redmine-1bd5e58c847816ae5751ee0026e55597d1541dd4.zip |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/exemplars/repository_exemplar.rb | 2 | ||||
-rw-r--r-- | test/fixtures/repositories.yml | 2 | ||||
-rw-r--r-- | test/functional/repositories_controller_test.rb | 25 | ||||
-rw-r--r-- | test/integration/routing/repositories_test.rb | 145 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 13 | ||||
-rw-r--r-- | test/unit/user_test.rb | 5 |
6 files changed, 179 insertions, 13 deletions
diff --git a/test/exemplars/repository_exemplar.rb b/test/exemplars/repository_exemplar.rb index 7b596ea36..961bee7ae 100644 --- a/test/exemplars/repository_exemplar.rb +++ b/test/exemplars/repository_exemplar.rb @@ -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 diff --git a/test/fixtures/repositories.yml b/test/fixtures/repositories.yml index 61930f395..ef7285f61 100644 --- a/test/fixtures/repositories.yml +++ b/test/fixtures/repositories.yml @@ -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 diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 4310c7630..817e16e2a 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -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 diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index edc49e70b..d2573eb36 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -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 = {} diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index ad0fc9f5f..275dc8bee 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -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", diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 4a1cb3337..a9484501d 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -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, |