From abc0b0ea3e520ce1174b687f55c03ac85c128950 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Jan 2012 22:23:56 +0000 Subject: [PATCH] Don't use a disabled SCM as a default repository SCM (#779). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8653 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 2 +- test/functional/repositories_controller_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 539dcd9dc..cd467d2d7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -36,7 +36,7 @@ class RepositoriesController < ApplicationController rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new - scm = params[:repository_scm] || Redmine::Scm::Base.all.first + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) @repository.is_default = @project.repository.nil? @repository.project = @project diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 817e16e2a..6bcbb6beb 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -43,6 +43,22 @@ class RepositoriesControllerTest < ActionController::TestCase assert_tag 'input', :attributes => {:name => 'repository[url]'} end + 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' + end + assert_response :success + assert_template 'new' + assert_kind_of Repository::Mercurial, assigns(:repository) + assert_tag 'select', :attributes => {:name => 'repository_scm'}, + :children => {:count => 3} + assert_tag 'select', :attributes => {:name => 'repository_scm'}, + :child => {:tag => 'option', :attributes => {:value => 'Mercurial', :selected => 'selected'}} + assert_tag 'select', :attributes => {:name => 'repository_scm'}, + :child => {:tag => 'option', :attributes => {:value => 'Git', :selected => nil}} + end + def test_create @request.session[:user_id] = 1 assert_difference 'Repository.count' do