mirror of
https://github.com/redmine/redmine.git
synced 2025-11-11 15:56:03 +01:00
Bulk addition of related issues (#33418).
Patch by Dmitry Makurin and Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20689 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -216,6 +216,53 @@ class IssueRelationsControllerTest < Redmine::ControllerTest
|
||||
assert_include 'Related issue cannot be blank', response.body
|
||||
end
|
||||
|
||||
def test_bulk_create_with_multiple_issue_to_id_issues
|
||||
assert_difference 'IssueRelation.count', +3 do
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
# js autocomplete adds a comma at the end
|
||||
# issue to id should accept both id and hash with id
|
||||
:issue_to_id => '2,3,#7, ',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
},
|
||||
:xhr => true
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
relations = IssueRelation.where(:issue_from_id => 1, :issue_to_id => [2, 3, 7])
|
||||
assert_equal 3, relations.count
|
||||
# all relations types should be 'relates'
|
||||
relations.map {|r| assert_equal 'relates', r.relation_type}
|
||||
|
||||
# no error messages should be returned in the response
|
||||
assert_not_include 'id=\"errorExplanation\"', response.body
|
||||
end
|
||||
|
||||
def test_bulk_create_should_show_errors
|
||||
assert_difference 'IssueRelation.count', +3 do
|
||||
post :create, :params => {
|
||||
:issue_id => 1,
|
||||
:relation => {
|
||||
:issue_to_id => '1,2,3,4,5,7',
|
||||
:relation_type => 'relates',
|
||||
:delay => ''
|
||||
}
|
||||
},
|
||||
:xhr => true
|
||||
end
|
||||
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.media_type
|
||||
# issue #1 is invalid
|
||||
assert_include 'Related issue is invalid: #1', response.body
|
||||
# issues #4 and #5 can't be related by default
|
||||
assert_include 'Related issue cannot be blank', response.body
|
||||
assert_include 'Related issue doesn't belong to the same project', response.body
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
assert_difference 'IssueRelation.count', -1 do
|
||||
delete(:destroy, :params => {:id => '2'})
|
||||
|
||||
Reference in New Issue
Block a user