]> source.dussan.org Git - redmine.git/commitdiff
Can not use Project#find on scopes with Rails 3.1.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Feb 2012 12:57:30 +0000 (12:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 25 Feb 2012 12:57:30 +0000 (12:57 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9001 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index ed29c34d427e18b95bda404d145c6d297bffa7da..cad3e4ab3f88e8de9e5f901f50cb2877997bcca0 100644 (file)
@@ -48,10 +48,18 @@ class SysController < ActionController::Base
 
   def fetch_changesets
     projects = []
+    scope = Project.active.has_module(:repository)
     if params[:id]
-      projects << Project.active.has_module(:repository).find(params[:id])
+      project = nil
+      if params[:id].to_s =~ /^\d*$/
+        project = scope.find(params[:id])
+      else
+        project = scope.find_by_identifier(params[:id])
+      end
+      raise ActiveRecord::RecordNotFound unless project
+      projects << project
     else
-      projects = Project.active.has_module(:repository).all
+      projects = scope.all
     end
     projects.each do |project|
       project.repositories.each do |repository|
index 97368b200bdc3b9e8cb0f21df39801c536acb678..558a6d9362004b81b93f02c8a92fc9c87f3cb6ed 100644 (file)
@@ -89,12 +89,18 @@ class SysControllerTest < ActionController::TestCase
     assert_response :success
   end
 
-  def test_fetch_changesets_one_project
+  def test_fetch_changesets_one_project_by_identifier
     Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true)
     get :fetch_changesets, :id => 'ecookbook'
     assert_response :success
   end
 
+  def test_fetch_changesets_one_project_by_id
+    Repository::Subversion.any_instance.expects(:fetch_changesets).once.returns(true)
+    get :fetch_changesets, :id => '1'
+    assert_response :success
+  end
+
   def test_fetch_changesets_unknown_project
     get :fetch_changesets, :id => 'unknown'
     assert_response 404