]> source.dussan.org Git - redmine.git/commitdiff
Adds an action to SysController to fetch changesets of one or all projects (#2925).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2009 16:50:26 +0000 (16:50 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 28 Nov 2009 16:50:26 +0000 (16:50 +0000)
Exemples:
* /sys/fetch_changesets (=> fetches changesets for all active projects)
* /sys/fetch_changeseys?id=foo (=> fetches changesets for project foo only)

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

app/controllers/sys_controller.rb
test/functional/sys_controller_test.rb

index da4b119a787b1f2c67d9205d47365c29dca408be..5e74192a9ceb16a076d187bf0956cf6053b8be4f 100644 (file)
@@ -37,6 +37,23 @@ class SysController < ActionController::Base
       end
     end
   end
+  
+  def fetch_changesets
+    projects = []
+    if params[:id]
+      projects << Project.active.has_module(:repository).find(params[:id])
+    else
+      projects = Project.active.has_module(:repository).find(:all, :include => :repository)
+    end
+    projects.each do |project|
+      if project.repository
+        project.repository.fetch_changesets
+      end
+    end
+    render :nothing => true, :status => 200
+  rescue ActiveRecord::RecordNotFound
+    render :nothing => true, :status => 404
+  end
 
   protected
 
index 59b1d2af6ef62c7edf666154129d05d8bc3f832b..187fbe410c5dd940d54d3d60d22a215627c7a90a 100644 (file)
@@ -53,4 +53,19 @@ class SysControllerTest < ActionController::TestCase
     assert r.is_a?(Repository::Subversion)
     assert_equal 'file:///create/project/repository/subproject2', r.url
   end
+  
+  def test_fetch_changesets
+    get :fetch_changesets
+    assert_response :success
+  end
+  
+  def test_fetch_changesets_one_project
+    get :fetch_changesets, :id => 'ecookbook'
+    assert_response :success
+  end
+  
+  def test_fetch_changesets_unknown_project
+    get :fetch_changesets, :id => 'unknown'
+    assert_response 404
+  end
 end