fixed-34185.patch

Yuichi HARADA, 2020-10-29 07:51

Download (8.64 KB)

View differences:

app/controllers/reports_controller.rb
22 22
  before_action :find_project, :authorize, :find_issue_statuses
23 23

  
24 24
  def issue_report
25
    @trackers = @project.rolled_up_trackers(false).visible
25
    with_subprojects = Setting.display_subprojects_issues?
26
    @trackers = @project.rolled_up_trackers(with_subprojects).visible
26 27
    @versions = @project.shared_versions.sorted
27 28
    @priorities = IssuePriority.all.reverse
28 29
    @categories = @project.issue_categories
29 30
    @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
30 31
    @authors = @project.users.sorted
31 32
    @subprojects = @project.descendants.visible
32
    with_subprojects = Setting.display_subprojects_issues?
33 33
    @issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
34 34
    @issues_by_version = Issue.by_version(@project, with_subprojects)
35 35
    @issues_by_priority = Issue.by_priority(@project, with_subprojects)
......
46 46
    case params[:detail]
47 47
    when "tracker"
48 48
      @field = "tracker_id"
49
      @rows = @project.rolled_up_trackers(false).visible
49
      @rows = @project.rolled_up_trackers(with_subprojects).visible
50 50
      @data = Issue.by_tracker(@project, with_subprojects)
51 51
      @report_title = l(:field_tracker)
52 52
    when "version"
test/functional/reports_controller_test.rb
41 41
  end
42 42

  
43 43
  def test_issue_report_with_subprojects_issues
44
    Setting.stubs(:display_subprojects_issues?).returns(true)
45
    get(
46
      :issue_report,
47
      :params => {
48
        :id => 1
49
      }
50
    )
51
    assert_response :success
52
    # Count subprojects issues
53
    assert_select 'table.list tbody :nth-child(1):first' do
54
      assert_select 'td', :text => 'Bug'
55
      assert_select ':nth-child(2)', :text => '5' # open
56
      assert_select ':nth-child(3)', :text => '3' # closed
57
      assert_select ':nth-child(4)', :text => '8' # total
44
    project = Project.find(1)
45
    tracker = project.trackers.find_by_name('Support request')
46
    project.trackers.delete(tracker)
47

  
48
    with_settings :display_subprojects_issues => '1' do
49
      get(
50
        :issue_report,
51
        :params => {
52
          :id => 1
53
        }
54
      )
55
      assert_response :success
56
      # Count subprojects issues
57
      assert_select 'table.list tbody :nth-child(1):first' do
58
        assert_select 'td', :text => 'Bug'
59
        assert_select ':nth-child(2)', :text => '5' # open
60
        assert_select ':nth-child(3)', :text => '3' # closed
61
        assert_select ':nth-child(4)', :text => '8' # total
62
      end
63
      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 1
58 64
    end
59 65
  end
60 66

  
61 67
  def test_issue_report_without_subprojects_issues
62
    Setting.stubs(:display_subprojects_issues?).returns(false)
63
    get(
64
      :issue_report,
65
      :params => {
66
        :id => 1
67
      }
68
    )
69
    assert_response :success
70
    # Do not count subprojects issues
71
    assert_select 'table.list tbody :nth-child(1):first' do
72
      assert_select 'td', :text => 'Bug'
73
      assert_select ':nth-child(2)', :text => '3' # open
74
      assert_select ':nth-child(3)', :text => '3' # closed
75
      assert_select ':nth-child(4)', :text => '6' # total
68
    project = Project.find(1)
69
    tracker = project.trackers.find_by_name('Support request')
70
    project.trackers.delete(tracker)
71

  
72
    with_settings :display_subprojects_issues => '0' do
73
      get(
74
        :issue_report,
75
        :params => {
76
          :id => 1
77
        }
78
      )
79
      assert_response :success
80
      # Do not count subprojects issues
81
      assert_select 'table.list tbody :nth-child(1):first' do
82
        assert_select 'td', :text => 'Bug'
83
        assert_select ':nth-child(2)', :text => '3' # open
84
        assert_select ':nth-child(3)', :text => '3' # closed
85
        assert_select ':nth-child(4)', :text => '6' # total
86
      end
87
      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 0
76 88
    end
77 89
  end
78 90

  
......
117 129
  end
118 130

  
119 131
  def test_get_issue_report_details_by_tracker_with_subprojects_issues
120
    Setting.stubs(:display_subprojects_issues?).returns(true)
121
    get(
122
      :issue_report_details,
123
      :params => {
124
        :id => 1,
125
        :detail => 'tracker'
126
      }
127
    )
128
    assert_response :success
129
    # Count subprojects issues
130
    assert_select 'table.list tbody :nth-child(1)' do
131
      assert_select 'td', :text => 'Bug'
132
      assert_select ':nth-child(2)', :text => '5' # status:1
133
      assert_select ':nth-child(3)', :text => '-' # status:2
134
      assert_select ':nth-child(4)', :text => '-' # status:3
135
      assert_select ':nth-child(5)', :text => '-' # status:4
136
      assert_select ':nth-child(6)', :text => '3' # status:5
137
      assert_select ':nth-child(7)', :text => '-' # status:6
138
      assert_select ':nth-child(8)', :text => '5' # open
139
      assert_select ':nth-child(9)', :text => '3' # closed
140
      assert_select ':nth-child(10)', :text => '8' # total
132
    project = Project.find(1)
133
    tracker = project.trackers.find_by_name('Support request')
134
    project.trackers.delete(tracker)
135

  
136
    with_settings :display_subprojects_issues => '1' do
137
      get(
138
        :issue_report_details,
139
        :params => {
140
          :id => 1,
141
          :detail => 'tracker'
142
        }
143
      )
144
      assert_response :success
145
      # Count subprojects issues
146
      assert_select 'table.list tbody :nth-child(1)' do
147
        assert_select 'td', :text => 'Bug'
148
        assert_select ':nth-child(2)', :text => '5' # status:1
149
        assert_select ':nth-child(3)', :text => '-' # status:2
150
        assert_select ':nth-child(4)', :text => '-' # status:3
151
        assert_select ':nth-child(5)', :text => '-' # status:4
152
        assert_select ':nth-child(6)', :text => '3' # status:5
153
        assert_select ':nth-child(7)', :text => '-' # status:6
154
        assert_select ':nth-child(8)', :text => '5' # open
155
        assert_select ':nth-child(9)', :text => '3' # closed
156
        assert_select ':nth-child(10)', :text => '8' # total
157
      end
158
      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 1
141 159
    end
142 160
  end
143 161

  
144 162
  def test_get_issue_report_details_by_tracker_without_subprojects_issues
145
    Setting.stubs(:display_subprojects_issues?).returns(false)
146
    get :issue_report_details, :params => {
147
      :id => 1,
148
      :detail => 'tracker'
149
    }
163
    project = Project.find(1)
164
    tracker = project.trackers.find_by_name('Support request')
165
    project.trackers.delete(tracker)
150 166

  
151
    assert_response :success
152
    # Do not count subprojects issues
153
    assert_select 'table.list tbody :nth-child(1)' do
154
      assert_select 'td', :text => 'Bug'
155
      assert_select ':nth-child(2)', :text => '3' # status:1
156
      assert_select ':nth-child(3)', :text => '-' # status:2
157
      assert_select ':nth-child(4)', :text => '-' # status:3
158
      assert_select ':nth-child(5)', :text => '-' # status:4
159
      assert_select ':nth-child(6)', :text => '3' # status:5
160
      assert_select ':nth-child(7)', :text => '-' # status:6
161
      assert_select ':nth-child(8)', :text => '3' # open
162
      assert_select ':nth-child(9)', :text => '3' # closed
163
      assert_select ':nth-child(10)', :text => '6' # total
167
    with_settings :display_subprojects_issues => '0' do
168
      get :issue_report_details, :params => {
169
        :id => 1,
170
        :detail => 'tracker'
171
      }
172

  
173
      assert_response :success
174
      # Do not count subprojects issues
175
      assert_select 'table.list tbody :nth-child(1)' do
176
        assert_select 'td', :text => 'Bug'
177
        assert_select ':nth-child(2)', :text => '3' # status:1
178
        assert_select ':nth-child(3)', :text => '-' # status:2
179
        assert_select ':nth-child(4)', :text => '-' # status:3
180
        assert_select ':nth-child(5)', :text => '-' # status:4
181
        assert_select ':nth-child(6)', :text => '3' # status:5
182
        assert_select ':nth-child(7)', :text => '-' # status:6
183
        assert_select ':nth-child(8)', :text => '3' # open
184
        assert_select ':nth-child(9)', :text => '3' # closed
185
        assert_select ':nth-child(10)', :text => '6' # total
186
      end
187
      assert_select 'table.issue-report td.name', :text => 'Support request', :count => 0
164 188
    end
165 189
  end
166 190