From bae9ffd327d98a2129510a898780d38ddba67b99 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 29 Oct 2018 06:14:56 +0000 Subject: [PATCH] Filter out issues from closed projects in the following widgets (#29449): * Issues assigned to me * Reported issues * Watched issues Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17611 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/my_helper.rb | 3 + test/functional/my_controller_test.rb | 88 +++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/app/helpers/my_helper.rb b/app/helpers/my_helper.rb index df0c4cf1d..91d21736c 100644 --- a/app/helpers/my_helper.rb +++ b/app/helpers/my_helper.rb @@ -96,6 +96,7 @@ module MyHelper def render_issuesassignedtome_block(block, settings) query = IssueQuery.new(:name => l(:label_assigned_to_me_issues), :user => User.current) query.add_filter 'assigned_to_id', '=', ['me'] + query.add_filter 'project.status', '=', ['1'] query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject'] query.sort_criteria = settings[:sort].presence || [['priority', 'desc'], ['updated_on', 'desc']] issues = query.issues(:limit => 10) @@ -106,6 +107,7 @@ module MyHelper def render_issuesreportedbyme_block(block, settings) query = IssueQuery.new(:name => l(:label_reported_issues), :user => User.current) query.add_filter 'author_id', '=', ['me'] + query.add_filter 'project.status', '=', ['1'] query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject'] query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']] issues = query.issues(:limit => 10) @@ -116,6 +118,7 @@ module MyHelper def render_issueswatched_block(block, settings) query = IssueQuery.new(:name => l(:label_watched_issues), :user => User.current) query.add_filter 'watcher_id', '=', ['me'] + query.add_filter 'project.status', '=', ['1'] query.column_names = settings[:columns].presence || ['project', 'tracker', 'status', 'subject'] query.sort_criteria = settings[:sort].presence || [['updated_on', 'desc']] issues = query.issues(:limit => 10) diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index e9123ff68..d8db74ff6 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -227,6 +227,94 @@ class MyControllerTest < Redmine::ControllerTest assert_select 'div.mypage-box', blocks.size end + def test_page_with_assigned_issues_block_should_not_show_issues_from_closed_projects + preferences = User.find(2).pref + preferences.my_page_layout = {'top' => ['issuesassignedtome']} + preferences.my_page_settings = {'issuesassignedtome' => {}} + preferences.save! + + issue = Issue.find(1) + issue.assigned_to = User.find(2) + issue.save! + + project = Project.find(2) + project.close + project.save + + get :page + + assert_response :success + assert_select '#block-issuesassignedtome table.issues tbody' do + report_url = css_select('h3 a').map {|e| e.attr('href')}.first + assert_match 'f%5B%5D=project.status', report_url + assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url + + assert_select 'tr', 1 + assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes' + assert_select 'tr[id=?]', 'issue-4', 0 + end + end + + def test_page_with_reported_issues_block_should_not_show_issues_from_closed_projects + preferences = User.find(2).pref + preferences.my_page_layout = {'top' => ['issuesreportedbyme']} + preferences.my_page_settings = {'issuesreportedbyme' => {}} + preferences.save! + + issue = Issue.find(1) + issue.assigned_to = User.find(2) + issue.save! + + project = Project.find(2) + project.close + project.save + + get :page + + assert_response :success + assert_select '#block-issuesreportedbyme' do + report_url = css_select('h3 a').map {|e| e.attr('href')}.first + assert_match 'f%5B%5D=project.status', report_url + assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url + + assert_select 'table.issues tbody tr', 10 + assert_select 'table.issues tbody tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes' + assert_select 'table.issues tbody tr[id=?]', 'issue-4', 0 + end + end + + def test_page_with_watched_issues_block_should_not_show_issues_from_closed_projects + preferences = User.find(2).pref + preferences.my_page_layout = {'top' => ['issueswatched']} + preferences.my_page_settings = {'issueswatched' => {}} + preferences.save! + + issue = Issue.find(1) + issue.watcher_user_ids = ['1', '2'] + issue.save! + + issue2 = Issue.find(4) + issue2.watcher_user_ids = ['2'] + issue2.save! + + project = Project.find(2) + project.close + project.save + + get :page + + assert_response :success + assert_select '#block-issueswatched table.issues tbody' do + report_url = css_select('h3 a').map {|e| e.attr('href')}.first + assert_match 'f%5B%5D=project.status', report_url + assert_match 'v%5Bproject.status%5D%5B%5D=1', report_url + + assert_select 'tr', 1 + assert_select 'tr[id=?]', 'issue-1', 1, :title => 'Cannot print recipes' + assert_select 'tr[id=?]', 'issue-4', 0 + end + end + def test_my_account_should_show_editable_custom_fields get :account assert_response :success -- 2.39.5