Ability to assign issues to groups (#2964).
Option is disabled by default. It can be turned on in application settings. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6306 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -535,6 +535,28 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_not_nil v
|
||||
assert_equal 'Value for field 2', v.value
|
||||
end
|
||||
|
||||
def test_post_new_with_group_assignment
|
||||
group = Group.find(11)
|
||||
project = Project.find(1)
|
||||
project.members << Member.new(:principal => group, :roles => [Role.first])
|
||||
|
||||
with_settings :issue_group_assignment => '1' do
|
||||
@request.session[:user_id] = 2
|
||||
assert_difference 'Issue.count' do
|
||||
post :create, :project_id => project.id,
|
||||
:issue => {:tracker_id => 3,
|
||||
:status_id => 1,
|
||||
:subject => 'This is the test_new_with_group_assignment issue',
|
||||
:assigned_to_id => group.id}
|
||||
end
|
||||
end
|
||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
||||
|
||||
issue = Issue.find_by_subject('This is the test_new_with_group_assignment issue')
|
||||
assert_not_nil issue
|
||||
assert_equal group, issue.assigned_to
|
||||
end
|
||||
|
||||
def test_post_create_without_start_date
|
||||
@request.session[:user_id] = 2
|
||||
@@ -1309,6 +1331,22 @@ class IssuesControllerTest < ActionController::TestCase
|
||||
assert_equal 1, journal.details.size
|
||||
end
|
||||
|
||||
def test_bulk_update_with_group_assignee
|
||||
group = Group.find(11)
|
||||
project = Project.find(1)
|
||||
project.members << Member.new(:principal => group, :roles => [Role.first])
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
# update issues assignee
|
||||
post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing',
|
||||
:issue => {:priority_id => '',
|
||||
:assigned_to_id => group.id,
|
||||
:custom_field_values => {'2' => ''}}
|
||||
|
||||
assert_response 302
|
||||
assert_equal [group, group], Issue.find_all_by_id([1, 2]).collect {|i| i.assigned_to}
|
||||
end
|
||||
|
||||
def test_bulk_update_on_different_projects
|
||||
@request.session[:user_id] = 2
|
||||
# update issues priority
|
||||
|
||||
+11
-1
@@ -1,5 +1,5 @@
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2009 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@@ -74,4 +74,14 @@ class GroupTest < ActiveSupport::TestCase
|
||||
User.find(8).groups.clear
|
||||
assert !User.find(8).member_of?(Project.find(5))
|
||||
end
|
||||
|
||||
def test_destroy_should_unassign_issues
|
||||
group = Group.first
|
||||
Issue.update_all(["assigned_to_id = ?", group.id], 'id = 1')
|
||||
|
||||
assert group.destroy
|
||||
assert group.destroyed?
|
||||
|
||||
assert_equal nil, Issue.find(1).assigned_to_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@@ -24,6 +24,19 @@ class IssueCategoryTest < ActiveSupport::TestCase
|
||||
@category = IssueCategory.find(1)
|
||||
end
|
||||
|
||||
def test_create
|
||||
assert IssueCategory.new(:project_id => 2, :name => 'New category').save
|
||||
category = IssueCategory.first(:order => 'id DESC')
|
||||
assert_equal 'New category', category.name
|
||||
end
|
||||
|
||||
def test_create_with_group_assignment
|
||||
assert IssueCategory.new(:project_id => 2, :name => 'Group assignment', :assigned_to_id => 11).save
|
||||
category = IssueCategory.first(:order => 'id DESC')
|
||||
assert_kind_of Group, category.assigned_to
|
||||
assert_equal Group.find(11), category.assigned_to
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
issue = @category.issues.first
|
||||
@category.destroy
|
||||
|
||||
@@ -64,6 +64,15 @@ class IssueTest < ActiveSupport::TestCase
|
||||
issue.reload
|
||||
assert_equal 'PostgreSQL', issue.custom_value_for(field).value
|
||||
end
|
||||
|
||||
def test_create_with_group_assignment
|
||||
with_settings :issue_group_assignment => '1' do
|
||||
assert Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1, :subject => 'Group assignment', :assigned_to_id => 11).save
|
||||
issue = Issue.first(:order => 'id DESC')
|
||||
assert_kind_of Group, issue.assigned_to
|
||||
assert_equal Group.find(11), issue.assigned_to
|
||||
end
|
||||
end
|
||||
|
||||
def assert_visibility_match(user, issues)
|
||||
assert_equal issues.collect(&:id).sort, Issue.all.select {|issue| issue.visible?(user)}.collect(&:id).sort
|
||||
@@ -579,6 +588,16 @@ class IssueTest < ActiveSupport::TestCase
|
||||
# author is not a member of project anymore
|
||||
assert !copy.recipients.include?(copy.author.mail)
|
||||
end
|
||||
|
||||
def test_recipients_should_include_the_assigned_group_members
|
||||
group_member = User.generate_with_protected!
|
||||
group = Group.generate!
|
||||
group.users << group_member
|
||||
|
||||
issue = Issue.find(12)
|
||||
issue.assigned_to = group
|
||||
assert issue.recipients.include?(group_member.mail)
|
||||
end
|
||||
|
||||
def test_watcher_recipients_should_not_include_users_that_cannot_view_the_issue
|
||||
user = User.find(3)
|
||||
@@ -682,6 +701,28 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once"
|
||||
end
|
||||
end
|
||||
|
||||
context "with issue_group_assignment" do
|
||||
should "include groups" do
|
||||
issue = Issue.new(:project => Project.find(2))
|
||||
|
||||
with_settings :issue_group_assignment => '1' do
|
||||
assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
|
||||
assert issue.assignable_users.include?(Group.find(11))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "without issue_group_assignment" do
|
||||
should "not include groups" do
|
||||
issue = Issue.new(:project => Project.find(2))
|
||||
|
||||
with_settings :issue_group_assignment => '0' do
|
||||
assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
|
||||
assert !issue.assignable_users.include?(Group.find(11))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_create_should_send_email_notification
|
||||
|
||||
@@ -109,6 +109,18 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
assert_equal 'Urgent', issue.priority.to_s
|
||||
assert issue.description.include?('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
|
||||
end
|
||||
|
||||
def test_add_issue_with_group_assignment
|
||||
with_settings :issue_group_assignment => '1' do
|
||||
issue = submit_email('ticket_on_given_project.eml') do |email|
|
||||
email.gsub!('Assigned to: John Smith', 'Assigned to: B Team')
|
||||
end
|
||||
assert issue.is_a?(Issue)
|
||||
assert !issue.new_record?
|
||||
issue.reload
|
||||
assert_equal Group.find(11), issue.assigned_to
|
||||
end
|
||||
end
|
||||
|
||||
def test_add_issue_with_partial_attributes_override
|
||||
issue = submit_email('ticket_with_attributes.eml', :issue => {:priority => 'High'}, :allow_override => ['tracker'])
|
||||
@@ -446,6 +458,7 @@ class MailHandlerTest < ActiveSupport::TestCase
|
||||
|
||||
def submit_email(filename, options={})
|
||||
raw = IO.read(File.join(FIXTURES_PATH, filename))
|
||||
yield raw if block_given?
|
||||
MailHandler.receive(raw, options)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user