]> source.dussan.org Git - redmine.git/commitdiff
Searching for issue number with REST API redirects to issue HTML page (#29055).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 15 Mar 2019 07:28:25 +0000 (07:28 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 15 Mar 2019 07:28:25 +0000 (07:28 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17949 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/search_controller.rb
test/integration/api_test/search_test.rb

index 37ac37cac3aea2f54c5d179958b8a6e453329794..8ae53e7ffdc6b930e06c6623e054cd6d83d254ce 100644 (file)
@@ -39,7 +39,7 @@ class SearchController < ApplicationController
     end
 
     # quick jump to an issue
-    if (m = @question.match(/^#?(\d+)$/)) && (issue = Issue.visible.find_by_id(m[1].to_i))
+    if !api_request? && (m = @question.match(/^#?(\d+)$/)) && (issue = Issue.visible.find_by_id(m[1].to_i))
       redirect_to issue_path(issue)
       return
     end
index 65d4654d8fda32a4aae1246533e74e7007c7b749..951fb45a9f14c2508982bf31cdf165c73d13fb8e 100644 (file)
@@ -91,4 +91,9 @@ class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
     assert_equal 4, json['limit']
     assert_equal issue[8..10], json['results'].map {|r| r['id']}
   end
+  test "GET /search.xml should not quick jump to the issue with given id" do
+    get '/search.xml', :params => {:q => '3'}
+    assert_response :success
+  end
 end