Project

General

Profile

Defect #8853 » subprojects_query_filter_fix.patch

patch against 1.3-stable to fix filtering by subproject - Jens Krämer, 2012-03-20 13:33

View differences:

app/models/query.rb
469 469
      if has_filter?("subproject_id")
470 470
        case operator_for("subproject_id")
471 471
        when '='
472
          # include the selected subprojects
473
          ids += values_for("subproject_id").each(&:to_i)
472
          # include the selected subprojects, but not the parent project.
473
          ids = values_for("subproject_id").each(&:to_i)
474 474
        when '!*'
475 475
          # main project only
476 476
        else
config/locales/de.yml
293 293
  field_comments: Kommentar
294 294
  field_url: URL
295 295
  field_start_page: Hauptseite
296
  field_subproject: Unterprojekt von
296
  field_subproject: Unterprojekt
297 297
  field_hours: Stunden
298 298
  field_activity: Aktivität
299 299
  field_spent_on: Datum
test/unit/query_test.rb
62 62
  def assert_query_statement_includes(query, condition)
63 63
    assert query.statement.include?(condition), "Query statement condition not found in: #{query.statement}"
64 64
  end
65

  
66
  def test_filter_subproject_should_not_include_parent_issues
67
    User.current = User.find(1)
68
    project = Project.find(1)
69
    assert project.issues.any?
70
    subproject = project.children.find(3)
71
    assert subproject.issues.any?
72
    query = Query.new(:name => '_',
73
                      :project => project,
74
                      :filters => { 'subproject_id' => {:operator => '=', :values => [3]}})
75
    result = find_issues_with_query(query)
76
    assert_not_nil result
77
    assert_equal subproject.issues.size, result.size
78
    result.each do |issue|
79
      assert_equal 3, issue.project_id
80
    end
81
    User.current = nil
82
  end
65 83
  
66 84
  def assert_query_result(expected, query)
67 85
    assert_nothing_raised do
    (1-1/1)