0003-Filter-our-issues-from-closed-projects-in-the-follow.patch

Marius BALTEANU, 2018-10-22 00:14

Download (6.99 KB)

View differences:

app/helpers/my_helper.rb
96 96
  def render_issuesassignedtome_block(block, settings)
97 97
    query = IssueQuery.new(:name => l(:label_assigned_to_me_issues), :user => User.current)
98 98
    query.add_filter 'assigned_to_id', '=', ['me']
99
    query.add_filter 'project.status', '=', ['1']
99 100
    query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
100 101
    query.sort_criteria = settings[:sort].presence || [['priority', 'desc'], ['updated_on', 'desc']]
101 102
    issues = query.issues(:limit => 10)
......
106 107
  def render_issuesreportedbyme_block(block, settings)
107 108
    query = IssueQuery.new(:name => l(:label_reported_issues), :user => User.current)
108 109
    query.add_filter 'author_id', '=', ['me']
110
    query.add_filter 'project.status', '=', ['1']
109 111
    query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
110 112
    query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']]
111 113
    issues = query.issues(:limit => 10)
......
116 118
  def render_issueswatched_block(block, settings)
117 119
    query = IssueQuery.new(:name => l(:label_watched_issues), :user => User.current)
118 120
    query.add_filter 'watcher_id', '=', ['me']
121
    query.add_filter 'project.status', '=', ['1']
119 122
    query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject']
120 123
    query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']]
121 124
    issues = query.issues(:limit => 10)
test/functional/my_controller_test.rb
95 95
      assert_select 'table.issues.sort-by-due-date'
96 96
    end
97 97
  end
98
 
98

  
99 99
  def test_page_with_issuequery_block_and_no_settings
100 100
    user = User.find(2)
101 101
    user.pref.my_page_layout = {'top' => ['issuequery']}
......
227 227
    assert_select 'div.mypage-box', blocks.size
228 228
  end
229 229

  
230
  def test_page_with_assigned_issues_block_should_not_show_issues_from_closed_projects
231
    preferences = User.find(2).pref
232
    preferences.my_page_layout = {'top' => ['issuesassignedtome']}
233
    preferences.my_page_settings = {'issuesassignedtome' => {}}
234
    preferences.save!
235

  
236
    issue = Issue.find(1)
237
    issue.assigned_to = User.find(2)
238
    issue.save!
239

  
240
    project = Project.find(2)
241
    project.close
242
    project.save
243

  
244
    get :page
245

  
246
    assert_response :success
247
    assert_select '#block-issuesassignedtome table.issues tbody' do
248
      report_url = css_select('h3 a').map {|e| e.attr('href')}.first
249
      assert_match 'f%5B%5D=project.status', report_url
250
      assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
251

  
252
      assert_select 'tr', 1
253
      assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
254
      assert_select 'tr[id=?]', 'issue-4', 0
255
    end
256
  end
257

  
258
  def test_page_with_reported_issues_block_should_not_show_issues_from_closed_projects
259
    preferences = User.find(2).pref
260
    preferences.my_page_layout = {'top' => ['issuesreportedbyme']}
261
    preferences.my_page_settings = {'issuesreportedbyme' => {}}
262
    preferences.save!
263

  
264
    issue = Issue.find(1)
265
    issue.assigned_to = User.find(2)
266
    issue.save!
267

  
268
    project = Project.find(2)
269
    project.close
270
    project.save
271

  
272
    get :page
273

  
274
    assert_response :success
275
    assert_select '#block-issuesreportedbyme' do
276
      report_url = css_select('h3 a').map {|e| e.attr('href')}.first
277
      assert_match 'f%5B%5D=project.status', report_url
278
      assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
279

  
280
      assert_select 'table.issues tbody tr', 10
281
      assert_select 'table.issues tbody tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
282
      assert_select 'table.issues tbody tr[id=?]', 'issue-4', 0
283
    end
284
  end
285

  
286
  def test_page_with_watched_issues_block_should_not_show_issues_from_closed_projects
287
    preferences = User.find(2).pref
288
    preferences.my_page_layout = {'top' => ['issueswatched']}
289
    preferences.my_page_settings = {'issueswatched' => {}}
290
    preferences.save!
291

  
292
    issue = Issue.find(1)
293
    issue.watcher_user_ids = ['1', '2']
294
    issue.save!
295

  
296
    issue2 = Issue.find(4)
297
    issue2.watcher_user_ids = ['2']
298
    issue2.save!
299

  
300
    project = Project.find(2)
301
    project.close
302
    project.save
303

  
304
    get :page
305

  
306
    assert_response :success
307
    assert_select '#block-issueswatched table.issues tbody' do
308
      report_url = css_select('h3 a').map {|e| e.attr('href')}.first
309
      assert_match 'f%5B%5D=project.status', report_url
310
      assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url
311

  
312
      assert_select 'tr', 1
313
      assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes'
314
      assert_select 'tr[id=?]', 'issue-4', 0
315
    end
316
  end
317

  
230 318
  def test_my_account_should_show_editable_custom_fields
231 319
    get :account
232 320
    assert_response :success
......
272 360
          :group_ids => ['10'],
273 361
          :custom_field_values => {
274 362
            "4" => "0100562500"
275
          }    
276
          
363
          }
364

  
277 365
        }
278 366
      }
279 367

  
......
292 380
    post :account, :params => {
293 381
        :user => {
294 382
          :mail => 'foobar@example.com'
295
          
383

  
296 384
        }
297 385
      }
298 386

  
......
419 507
    post :update_page, :params => {
420 508
        :settings => {
421 509
          'issuesassignedtome' => {
422
          'columns' => ['subject', 'due_date']}    
510
          'columns' => ['subject', 'due_date']}
423 511
        }
424 512
      },
425 513
      :xhr => true
......
476 564
    pref = User.find(2).pref
477 565
    pref.my_page_layout = {'left' => ['news', 'calendar','documents']}
478 566
    pref.save!
479
    
567

  
480 568
    post :order_blocks, :params => {
481 569
        :group => 'left',
482 570
        :blocks => ['documents', 'calendar', 'news']
......
490 578
    pref = User.find(2).pref
491 579
    pref.my_page_layout = {'left' => ['news','documents'], 'right' => ['calendar']}
492 580
    pref.save!
493
    
581

  
494 582
    post :order_blocks, :params => {
495 583
        :group => 'left',
496 584
        :blocks => ['news', 'calendar', 'documents']
497
-