mirror of
https://github.com/redmine/redmine.git
synced 2025-11-12 16:26:03 +01:00
Fixed create duplicate follow relation fails with 500 internal error (#35655).
git-svn-id: http://svn.redmine.org/redmine/trunk@21150 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -56,10 +56,13 @@ class IssueRelationsController < ApplicationController
|
|||||||
@relation.safe_attributes = params_relation
|
@relation.safe_attributes = params_relation
|
||||||
@relation.init_journals(User.current)
|
@relation.init_journals(User.current)
|
||||||
|
|
||||||
unless saved = @relation.save
|
begin
|
||||||
saved = false
|
saved = @relation.save
|
||||||
unsaved_relations << @relation
|
rescue ActiveRecord::RecordNotUnique
|
||||||
|
@relation.errors.add :base, :taken
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unsaved_relations << @relation unless saved
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|||||||
@@ -216,6 +216,31 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
|||||||
assert_include 'Related issue cannot be blank', response.body
|
assert_include 'Related issue cannot be blank', response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_duplicated_follows_relations_should_not_raise_exception
|
||||||
|
IssueRelation.create(
|
||||||
|
:issue_from => Issue.find(1), :issue_to => Issue.find(2),
|
||||||
|
:relation_type => IssueRelation::TYPE_PRECEDES
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_no_difference 'IssueRelation.count' do
|
||||||
|
post(
|
||||||
|
:create,
|
||||||
|
:params => {
|
||||||
|
:issue_id => 2,
|
||||||
|
:relation => {
|
||||||
|
:issue_to_id => 1,
|
||||||
|
:relation_type => 'follows',
|
||||||
|
:delay => ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
:xhr => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_include 'has already been taken', response.body
|
||||||
|
end
|
||||||
|
|
||||||
def test_bulk_create_with_multiple_issue_to_id_issues
|
def test_bulk_create_with_multiple_issue_to_id_issues
|
||||||
assert_difference 'IssueRelation.count', +3 do
|
assert_difference 'IssueRelation.count', +3 do
|
||||||
post :create, :params => {
|
post :create, :params => {
|
||||||
|
|||||||
Reference in New Issue
Block a user