@@ -21,8 +21,8 class IssueRelationsController < ApplicationController | |||
|
21 | 21 | def new |
|
22 | 22 | @relation = IssueRelation.new(params[:relation]) |
|
23 | 23 | @relation.issue_from = @issue |
|
24 |
if params[:relation] && |
|
|
25 |
@relation.issue_to = Issue.visible.find_by_id( |
|
|
24 | if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/) | |
|
25 | @relation.issue_to = Issue.visible.find_by_id(m[1].to_i) | |
|
26 | 26 | end |
|
27 | 27 | @relation.save if request.post? |
|
28 | 28 | respond_to do |format| |
@@ -40,6 +40,24 class IssueRelationsControllerTest < ActionController::TestCase | |||
|
40 | 40 | end |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | def test_new_should_accept_id_with_hash | |
|
44 | assert_difference 'IssueRelation.count' do | |
|
45 | @request.session[:user_id] = 3 | |
|
46 | post :new, :issue_id => 1, | |
|
47 | :relation => {:issue_to_id => '#2', :relation_type => 'relates', :delay => ''} | |
|
48 | end | |
|
49 | end | |
|
50 | ||
|
51 | def test_new_should_not_break_with_non_numerical_id | |
|
52 | assert_no_difference 'IssueRelation.count' do | |
|
53 | assert_nothing_raised do | |
|
54 | @request.session[:user_id] = 3 | |
|
55 | post :new, :issue_id => 1, | |
|
56 | :relation => {:issue_to_id => 'foo', :relation_type => 'relates', :delay => ''} | |
|
57 | end | |
|
58 | end | |
|
59 | end | |
|
60 | ||
|
43 | 61 | def test_should_create_relations_with_visible_issues_only |
|
44 | 62 | Setting.cross_project_issue_relations = '1' |
|
45 | 63 | assert_nil Issue.visible(User.find(3)).find_by_id(4) |
General Comments 0
You need to be logged in to leave comments.
Login now