diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-12-10 12:02:37 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-12-10 12:02:37 +0000 |
commit | 3a2b6c7c9653ddbd32ea0c2434b0c9b638832b3e (patch) | |
tree | d26c2e0017af9ba1ce3a8767c9dc2f2584a0f776 /test/unit/query_test.rb | |
parent | 575f4032a221c8fc7919c2997c13e1424da8006e (diff) | |
download | redmine-3a2b6c7c9653ddbd32ea0c2434b0c9b638832b3e.tar.gz redmine-3a2b6c7c9653ddbd32ea0c2434b0c9b638832b3e.zip |
Enforce issue assignee validation (#23921).
git-svn-id: http://svn.redmine.org/redmine/trunk@16055 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/query_test.rb')
-rw-r--r-- | test/unit/query_test.rb | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 5c34d58c3..6d27106cc 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -676,19 +676,25 @@ class QueryTest < ActiveSupport::TestCase def test_filter_assigned_to_me user = User.find(2) group = Group.find(10) - User.current = user - i1 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => user) - i2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => group) - i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => Group.find(11)) group.users << user + other_group = Group.find(11) + Member.create!(:project_id => 1, :principal => group, :role_ids => [1]) + Member.create!(:project_id => 1, :principal => other_group, :role_ids => [1]) + User.current = user - query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}}) - result = query.issues - assert_equal Issue.visible.where(:assigned_to_id => ([2] + user.reload.group_ids)).sort_by(&:id), result.sort_by(&:id) - - assert result.include?(i1) - assert result.include?(i2) - assert !result.include?(i3) + with_settings :issue_group_assignment => '1' do + i1 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => user) + i2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => group) + i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => other_group) + + query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}}) + result = query.issues + assert_equal Issue.visible.where(:assigned_to_id => ([2] + user.reload.group_ids)).sort_by(&:id), result.sort_by(&:id) + + assert result.include?(i1) + assert result.include?(i2) + assert !result.include?(i3) + end end def test_user_custom_field_filtered_on_me @@ -1689,7 +1695,7 @@ class QueryTest < ActiveSupport::TestCase @issue1 = Issue.generate!(:project => @project, :assigned_to_id => @manager.id) @issue2 = Issue.generate!(:project => @project, :assigned_to_id => @developer.id) @issue3 = Issue.generate!(:project => @project, :assigned_to_id => @boss.id) - @issue4 = Issue.generate!(:project => @project, :assigned_to_id => @guest.id) + @issue4 = Issue.generate!(:project => @project, :author_id => @guest.id, :assigned_to_id => @guest.id) @issue5 = Issue.generate!(:project => @project) @query = IssueQuery.new(:name => '_', :project => @project) |