From d89c968bb116e525ca5c8597037086b5b565dadf Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 9 Nov 2013 11:09:50 +0000 Subject: [PATCH] Accept issue id with leading sharp when adding a related issue. git-svn-id: http://svn.redmine.org/redmine/trunk@12250 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/repositories_controller.rb | 3 ++- test/functional/repositories_controller_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 2db9c3f92..ad0ff7f13 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -229,7 +229,8 @@ class RepositoriesController < ApplicationController # Adds a related issue to a changeset # POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues def add_related_issue - @issue = @changeset.find_referenced_issue_by_id(params[:issue_id]) + issue_id = params[:issue_id].to_s.sub(/^#/,'') + @issue = @changeset.find_referenced_issue_by_id(issue_id) if @issue && (!@issue.visible? || @changeset.issues.include?(@issue)) @issue = nil end diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index ec1847fcd..18558cde1 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -199,6 +199,14 @@ class RepositoriesControllerTest < ActionController::TestCase assert_include 'Feature request #2', response.body end + def test_add_related_issue_should_accept_issue_id_with_sharp + @request.session[:user_id] = 2 + assert_difference 'Changeset.find(103).issues.size' do + xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => "#2", :format => 'js' + end + assert_equal [2], Changeset.find(103).issue_ids + end + def test_add_related_issue_with_invalid_issue_id @request.session[:user_id] = 2 assert_no_difference 'Changeset.find(103).issues.size' do -- 2.39.5