<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -63,16 +63,20 @@ class Admin::RepositoriesController &lt; AdminAreaController
   end
   
   def validate
-    path = params[:path].blank? ? '' : params[:path]
-    @result = if !File.exists?(path)
+    path  = params[:path].blank? ? '' : params[:path]
+    klass = Repository[params[:kind]]
+
+    @result = if klass.nil? or !klass.enabled? 
+      _('Support for {{system}} is not enabled.', :system =&gt; params[:kind].to_s.classify)
+    elsif !File.exists?(path)
       _('Failure! Path does not exist.')
     elsif !File.readable?(path) || !File.executable?(path)
       _('Failure! You are not permitted to browse this path.')
     else
-      begin        
-        repos = Repository[params[:kind]].new(:path =&gt; params[:path])
+      repos = klass.new(:path =&gt; params[:path])
+      if repos.active?
         _('Success! Path contains a valid repository (latest revision: {{latest}}).', :latest =&gt; repos.latest_revision)
-      rescue 
+      else
         _('Failure! Path does not contain a valid repository.')
       end
     end</diff>
      <filename>app/controllers/admin/repositories_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,11 @@ class Repository::Abstract &lt; ::Repository
       revision.to_s
     end
     
+    # Determines of the repository support is enabled
+    def enabled?
+      raise NotImplementedError, 'enabled? is an abstract method'
+    end
+
     private
 
       def subclasses_preloaded?
@@ -31,7 +36,7 @@ class Repository::Abstract &lt; ::Repository
 
   # Determines of the repository is ready to be used
   def active?
-    node('').present? rescue false
+    self.class.enabled? &amp;&amp; ( node('').present? rescue false )
   end
   memoize :active?
 </diff>
      <filename>app/models/repository/abstract.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,11 +9,11 @@ class Repository::Git &lt; Repository::Abstract
     def truncate_revision(revision)
       super.first(7)
     end
-    
-  end
 
-  def active?
-    SCM_GIT_ENABLED and super
+    def enabled?
+      SCM_GIT_ENABLED
+    end
+    
   end
 
   def latest_revision</diff>
      <filename>app/models/repository/git.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,12 @@
 #++
 class Repository::Subversion &lt; Repository::Abstract
 
+  def self.enabled?
+    SCM_SUBVERSION_ENABLED
+  end
+
   def active?
-    SCM_SUBVERSION_ENABLED and ( open_fs.present? rescue false )
+    self.class.enabled? and ( open_fs.present? rescue false )
   end
   
   def latest_revision</diff>
      <filename>app/models/repository/subversion.rb</filename>
    </modified>
    <modified>
      <diff>@@ -205,8 +205,10 @@ describe Admin::RepositoriesController do
     before do
       File.stub!(:exists?).and_return(true)
       File.stub!(:readable?).and_return(true)
-      File.stub!(:executable?).and_return(true)
-      @repository = mock_model(Repository::Abstract, :latest_revision =&gt; 'R10')
+      File.stub!(:executable?).and_return(true)      
+      Repository::Subversion.stub!(:enabled?).and_return(true)
+      
+      @repository = mock_model(Repository::Abstract, :active? =&gt; true, :latest_revision =&gt; 'R10')
       Repository.stub!(:[]).and_return(Repository::Subversion)
       Repository::Subversion.stub!(:new).and_return(@repository)
     end
@@ -220,6 +222,18 @@ describe Admin::RepositoriesController do
       xhr :get, :validate, :kind =&gt; 'Subversion', :path =&gt; '/home/me/repositories/project'
     end
 
+    it 'should handle invalid repository types' do
+      Repository.should_receive(:[]).with('Subversion').and_return(nil)
+      do_get
+      response.body.should match(/Support for Subversion is not enabled/)
+    end
+
+    it 'should handle disabled repository types' do
+      Repository::Subversion.should_receive(:enabled?).and_return(false)
+      do_get
+      response.body.should match(/Support for Subversion is not enabled/)
+    end
+
     it 'should return correct message if path doesn\'t exist' do
       File.should_receive(:exists?).with('/home/me/repositories/project').and_return(false)
       do_get
@@ -244,7 +258,7 @@ describe Admin::RepositoriesController do
     end
 
     it 'should return a failure message if path does not contain a repository' do
-      @repository.should_receive(:latest_revision).and_raise 'Error, there is no repository here'
+      @repository.should_receive(:active?).and_return(false)
       do_get
       response.body.should match(/Failure/)
     end</diff>
      <filename>spec/controllers/admin/repositories_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -92,8 +92,8 @@ describe Repository::Subversion::Node do
       @node.content.should_not be_blank      
     end
 
-    it 'should have a textual content' do
-      request_node(&quot;retrospectiva/config/environment.rb&quot;, nil, false).content.should == ''      
+    it 'should be able to skip content' do
+      request_node(&quot;retrospectiva/config/environment.rb&quot;, nil, true).content.should == ''      
     end
 
     it 'should return the content-length as size' do
@@ -145,4 +145,4 @@ describe Repository::Subversion::Node do
     end
   end
   
-end if SCM_SUBVERSION_ENABLED
+end if Repository::Subversion.enabled?</diff>
      <filename>spec/models/repository/subversion/node_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9e95e467622bf1eb16a54cd50b785eb23a71bb67</id>
    </parent>
  </parents>
  <author>
    <name>Dimitrij Denissenko</name>
    <email>contact@dvisionfactory.com</email>
  </author>
  <url>http://github.com/dim/retrospectiva/commit/b4450f2d6a58647d1ad4ce4abc9daf94a4091457</url>
  <id>b4450f2d6a58647d1ad4ce4abc9daf94a4091457</id>
  <committed-date>2009-10-29T00:58:12-07:00</committed-date>
  <authored-date>2009-10-29T00:58:12-07:00</authored-date>
  <message>Improved repository checks [#699]</message>
  <tree>38f601993cd774fe7f866fbd821d96254c73986b</tree>
  <committer>
    <name>Dimitrij Denissenko</name>
    <email>contact@dvisionfactory.com</email>
  </committer>
</commit>
