From 53a6e66da665ff9c32bf8f196ff4ed234167b929 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 7 Nov 2015 08:18:10 +0000 Subject: [PATCH] Merged r14758 (#21071). git-svn-id: http://svn.redmine.org/redmine/branches/3.1-stable@14802 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/changeset.rb | 2 +- test/unit/changeset_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 13213f3ab..ae42d414e 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -200,7 +200,7 @@ class Changeset < ActiveRecord::Base # Finds an issue that can be referenced by the commit message def find_referenced_issue_by_id(id) return nil if id.blank? - issue = Issue.includes(:project).where(:id => id.to_i).first + issue = Issue.find_by_id(id.to_i) if Setting.commit_cross_project_ref? # all issues can be referenced/fixed elsif issue diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index fbce05cd5..6ba02aa56 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -165,6 +165,18 @@ class ChangesetTest < ActiveSupport::TestCase assert_equal [1,2,3], c.issue_ids.sort end + def test_ref_keywords_with_large_number_should_not_error + Setting.commit_ref_keywords = '*' + c = Changeset.new(:repository => Project.find(1).repository, + :committed_on => Time.now, + :comments => 'Out of range #2010021810000121', + :revision => '12345') + assert_nothing_raised do + assert c.save + end + assert_equal [], c.issue_ids.sort + end + def test_update_keywords_with_changes_should_create_journal issue = Issue.generate!(:project_id => 1, :status_id => 1) -- 2.39.5