Project

General

Profile

Defect #32168 » 32168.patch

Yuichi HARADA, 2019-10-01 10:28

View differences:

app/models/issue_query.rb
684 684

  
685 685
    joins.any? ? joins.join(' ') : nil
686 686
  end
687

  
688
  def validate_query_filters
689
    super
690

  
691
    idx_issue_id = errors[:base].index{|message| /\A#{label_for('issue_id')}\s/.match?(message)}
692
    return unless idx_issue_id
693
    return if values_for('issue_id').any?{|v| v.blank? || !/\A[#]?\d+(\s*,\s*[#]?\d+)*\z/.match?(v)}
694

  
695
    errors[:base].delete_at(idx_issue_id)
696
  end
687 697
end
test/unit/query_test.rb
273 273
  end
274 274

  
275 275
  def test_operator_is_on_issue_id_should_accept_comma_separated_values
276
    query = IssueQuery.new(:name => '_')
277
    query.add_filter("issue_id", '=', ['1,3'])
278
    issues = find_issues_with_query(query)
279
    assert_equal 2, issues.size
280
    assert_equal [1,3], issues.map(&:id).sort
276
    [
277
      ['1,3'], ['#1,#3'], ['1, 3']
278
    ].each do |issue_ids|
279
      query = IssueQuery.new(:name => '_')
280
      query.add_filter('issue_id', '=', issue_ids)
281
      assert query.valid?, query.errors.full_messages
282

  
283
      issues = find_issues_with_query(query)
284
      assert_equal 2, issues.size
285
      assert_equal [1, 3], issues.map(&:id).sort
286
    end
281 287
  end
282 288

  
283 289
  def test_operator_is_on_parent_id_should_accept_comma_separated_values
(2-2/2)