]> source.dussan.org Git - redmine.git/commitdiff
Disable autofetching of repository changesets if projects are closed (#13945).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 12 May 2013 10:05:35 +0000 (10:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 12 May 2013 10:05:35 +0000 (10:05 +0000)
Patch by Mischa The Evil.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11838 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/repositories_controller.rb
test/functional/repositories_controller_test.rb

index 2912b72bfab688bbef414645a47d468a26d530e1..77b74bfe3a963f295241b66dc6616ab5f7c7c425 100644 (file)
@@ -111,7 +111,7 @@ class RepositoriesController < ApplicationController
   end
 
   def show
-    @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
+    @repository.fetch_changesets if @project.active? && Setting.autofetch_changesets? && @path.empty?
 
     @entries = @repository.entries(@path, @rev)
     @changeset = @repository.find_changeset_by_name(@rev)
index 315090c59ba14048a53a098721db51942d4a682c..2231e31348d654d57f808050d328ade7e1d5377a 100644 (file)
@@ -111,6 +111,31 @@ class RepositoriesControllerTest < ActionController::TestCase
     assert_nil Repository.find_by_id(11)
   end
 
+  def test_show_with_autofetch_changesets_enabled_should_fetch_changesets
+    Repository::Subversion.any_instance.expects(:fetch_changesets).once
+
+    with_settings :autofetch_changesets => '1' do
+      get :show, :id => 1
+    end
+  end
+
+  def test_show_with_autofetch_changesets_disabled_should_not_fetch_changesets
+    Repository::Subversion.any_instance.expects(:fetch_changesets).never
+
+    with_settings :autofetch_changesets => '0' do
+      get :show, :id => 1
+    end
+  end
+
+  def test_show_with_closed_project_should_not_fetch_changesets
+    Repository::Subversion.any_instance.expects(:fetch_changesets).never
+    Project.find(1).close
+
+    with_settings :autofetch_changesets => '1' do
+      get :show, :id => 1
+    end
+  end
+
   def test_revisions
     get :revisions, :id => 1
     assert_response :success