fix_updated_on_by_none_or_any_v2.patch

Marius BALTEANU, 2017-01-17 09:33

Download (1.7 KB)

View differences:

app/models/issue_query.rb
449 449
    end
450 450
  end
451 451

  
452
  def sql_for_updated_on_field(field, operator, value)
453
    case operator
454
    when "!*"
455
      "#{Issue.table_name}.updated_on = #{Issue.table_name}.created_on"
456
    when "*"
457
      "#{Issue.table_name}.updated_on > #{Issue.table_name}.created_on"
458
    else
459
      sql_for_field("updated_on", operator, value, Issue.table_name, "updated_on")
460
    end
461
  end
462

  
452 463
  def sql_for_issue_id_field(field, operator, value)
453 464
    if operator == "="
454 465
      # accepts a comma separated list of ids
test/unit/query_test.rb
1892 1892
    assert_equal [1, 2, 3, 6, 7, 8, 9, 10, 11, 12], issues.map(&:id).sort
1893 1893
  end
1894 1894

  
1895
  def test_filter_updated_on_none_should_return_issues_with_updated_on_equal_with_created_on
1896
    query = IssueQuery.new(:name => '_', :project => Project.find(1))
1897

  
1898
    query.filters = {'updated_on' => {:operator => '!*', :values => ['']}}
1899
    issues = find_issues_with_query(query)
1900
    assert_equal [3, 6, 7, 8, 9, 10, 14], issues.map(&:id).sort
1901
  end
1902

  
1903
  def test_filter_updated_on_any_should_return_issues_with_updated_on_greater_than_created_on
1904
    query = IssueQuery.new(:name => '_', :project => Project.find(1))
1905

  
1906
    query.filters = {'updated_on' => {:operator => '*', :values => ['']}}
1907
    issues = find_issues_with_query(query)
1908
    assert_equal [1, 2, 5, 11, 12, 13], issues.map(&:id).sort
1909
  end
1895 1910
end