mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 14:26:04 +01:00
Enforce issue assignee validation (#23921).
git-svn-id: http://svn.redmine.org/redmine/trunk@16055 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -377,6 +377,11 @@ class Issue < ActiveRecord::Base
|
|||||||
if category
|
if category
|
||||||
self.category = project.issue_categories.find_by_name(category.name)
|
self.category = project.issue_categories.find_by_name(category.name)
|
||||||
end
|
end
|
||||||
|
# Clear the assignee if not available in the new project for new issues (eg. copy)
|
||||||
|
# For existing issue, the previous assignee is still valid, so we keep it
|
||||||
|
if new_record? && assigned_to && !assignable_users.include?(assigned_to)
|
||||||
|
self.assigned_to_id = nil
|
||||||
|
end
|
||||||
# Keep the fixed_version if it's still valid in the new_project
|
# Keep the fixed_version if it's still valid in the new_project
|
||||||
if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
|
if fixed_version && fixed_version.project != project && !project.shared_versions.include?(fixed_version)
|
||||||
self.fixed_version = nil
|
self.fixed_version = nil
|
||||||
@@ -538,15 +543,8 @@ class Issue < ActiveRecord::Base
|
|||||||
self.status = statuses_allowed.first || default_status
|
self.status = statuses_allowed.first || default_status
|
||||||
end
|
end
|
||||||
if (u = attrs.delete('assigned_to_id')) && safe_attribute?('assigned_to_id')
|
if (u = attrs.delete('assigned_to_id')) && safe_attribute?('assigned_to_id')
|
||||||
if u.blank?
|
|
||||||
self.assigned_to_id = nil
|
|
||||||
else
|
|
||||||
u = u.to_i
|
|
||||||
if assignable_users.any?{|assignable_user| assignable_user.id == u}
|
|
||||||
self.assigned_to_id = u
|
self.assigned_to_id = u
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
attrs = delete_unsafe_attributes(attrs, user)
|
attrs = delete_unsafe_attributes(attrs, user)
|
||||||
@@ -708,6 +706,12 @@ class Issue < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if assigned_to_id_changed? && assigned_to_id.present?
|
||||||
|
unless assignable_users.include?(assigned_to)
|
||||||
|
errors.add :assigned_to_id, :invalid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Checks parent issue assignment
|
# Checks parent issue assignment
|
||||||
if @invalid_parent_issue_id.present?
|
if @invalid_parent_issue_id.present?
|
||||||
errors.add :parent_issue_id, :invalid
|
errors.add :parent_issue_id, :invalid
|
||||||
@@ -868,7 +872,9 @@ class Issue < ActiveRecord::Base
|
|||||||
def assignable_users
|
def assignable_users
|
||||||
users = project.assignable_users(tracker).to_a
|
users = project.assignable_users(tracker).to_a
|
||||||
users << author if author && author.active?
|
users << author if author && author.active?
|
||||||
users << assigned_to if assigned_to
|
if assigned_to_id_was.present? && assignee = Principal.find_by_id(assigned_to_id_was)
|
||||||
|
users << assignee
|
||||||
|
end
|
||||||
users.uniq.sort
|
users.uniq.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ class Project < ActiveRecord::Base
|
|||||||
def copy(project, options={})
|
def copy(project, options={})
|
||||||
project = project.is_a?(Project) ? project : Project.find(project)
|
project = project.is_a?(Project) ? project : Project.find(project)
|
||||||
|
|
||||||
to_be_copied = %w(wiki versions issue_categories issues members queries boards)
|
to_be_copied = %w(members wiki versions issue_categories issues queries boards)
|
||||||
to_be_copied = to_be_copied & Array.wrap(options[:only]) unless options[:only].nil?
|
to_be_copied = to_be_copied & Array.wrap(options[:only]) unless options[:only].nil?
|
||||||
|
|
||||||
Project.transaction do
|
Project.transaction do
|
||||||
|
|||||||
@@ -4440,7 +4440,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
:assigned_to_id => nil),
|
:assigned_to_id => nil),
|
||||||
Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2,
|
Issue.create!(:project_id => 2, :tracker_id => 3, :status_id => 2,
|
||||||
:priority_id => 1, :subject => 'issue 2', :author_id => 2,
|
:priority_id => 1, :subject => 'issue 2', :author_id => 2,
|
||||||
:assigned_to_id => 3)
|
:assigned_to_id => 2)
|
||||||
]
|
]
|
||||||
assert_difference 'Issue.count', issues.size do
|
assert_difference 'Issue.count', issues.size do
|
||||||
post :bulk_update, :ids => issues.map(&:id), :copy => '1',
|
post :bulk_update, :ids => issues.map(&:id), :copy => '1',
|
||||||
@@ -4496,7 +4496,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
post :bulk_update, :ids => [1], :copy => '1',
|
post :bulk_update, :ids => [1], :copy => '1',
|
||||||
:notes => 'Copying one issue',
|
:notes => 'Copying one issue',
|
||||||
:issue => {
|
:issue => {
|
||||||
:project_id => '', :tracker_id => '', :assigned_to_id => '4',
|
:project_id => '', :tracker_id => '',
|
||||||
:status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
|
:status_id => '3', :start_date => '2009-12-01', :due_date => '2009-12-31'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -689,6 +689,14 @@ JSON
|
|||||||
assert_select 'errors error', :text => "Subject cannot be blank"
|
assert_select 'errors error', :text => "Subject cannot be blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "PUT /issues/:id.xml with invalid assignee should return error" do
|
||||||
|
user = User.generate!
|
||||||
|
put '/issues/6.xml', {:issue => {:assigned_to_id => user.id}}, credentials('jsmith')
|
||||||
|
|
||||||
|
assert_response :unprocessable_entity
|
||||||
|
assert_select 'errors error', :text => "Assignee is invalid"
|
||||||
|
end
|
||||||
|
|
||||||
test "PUT /issues/:id.json" do
|
test "PUT /issues/:id.json" do
|
||||||
assert_difference('Journal.count') do
|
assert_difference('Journal.count') do
|
||||||
put '/issues/6.json',
|
put '/issues/6.json',
|
||||||
|
|||||||
@@ -243,14 +243,14 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
|
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
|
||||||
Role.anonymous.update!(:issues_visibility => 'default')
|
Role.anonymous.update!(:issues_visibility => 'default')
|
||||||
issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
|
issue = Issue.generate!(:author => User.anonymous, :is_private => true)
|
||||||
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
|
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
|
||||||
assert !issue.visible?(User.anonymous)
|
assert !issue.visible?(User.anonymous)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
|
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
|
||||||
assert Role.anonymous.update!(:issues_visibility => 'own')
|
assert Role.anonymous.update!(:issues_visibility => 'own')
|
||||||
issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
|
issue = Issue.generate!(:author => User.anonymous, :is_private => true)
|
||||||
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
|
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
|
||||||
assert !issue.visible?(User.anonymous)
|
assert !issue.visible?(User.anonymous)
|
||||||
end
|
end
|
||||||
@@ -344,13 +344,15 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
def test_visible_scope_for_member_with_groups_should_return_assigned_issues
|
def test_visible_scope_for_member_with_groups_should_return_assigned_issues
|
||||||
user = User.find(8)
|
user = User.find(8)
|
||||||
assert user.groups.any?
|
assert user.groups.any?
|
||||||
Member.create!(:principal => user.groups.first, :project_id => 1, :role_ids => [2])
|
group = user.groups.first
|
||||||
|
Member.create!(:principal => group, :project_id => 1, :role_ids => [2])
|
||||||
Role.non_member.remove_permission!(:view_issues)
|
Role.non_member.remove_permission!(:view_issues)
|
||||||
|
|
||||||
|
with_settings :issue_group_assignment => '1' do
|
||||||
issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3,
|
issue = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 3,
|
||||||
:status_id => 1, :priority => IssuePriority.all.first,
|
:status_id => 1, :priority => IssuePriority.all.first,
|
||||||
:subject => 'Assignment test',
|
:subject => 'Assignment test',
|
||||||
:assigned_to => user.groups.first,
|
:assigned_to => group,
|
||||||
:is_private => true)
|
:is_private => true)
|
||||||
|
|
||||||
Role.find(2).update! :issues_visibility => 'default'
|
Role.find(2).update! :issues_visibility => 'default'
|
||||||
@@ -363,6 +365,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert issues.any?
|
assert issues.any?
|
||||||
assert_include issue, issues
|
assert_include issue, issues
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_visible_scope_for_member_with_limited_tracker_ids
|
def test_visible_scope_for_member_with_limited_tracker_ids
|
||||||
role = Role.find(1)
|
role = Role.find(1)
|
||||||
@@ -458,6 +461,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_visible_and_nested_set_scopes
|
def test_visible_and_nested_set_scopes
|
||||||
user = User.generate!
|
user = User.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => user, :role_ids => [1])
|
||||||
parent = Issue.generate!(:assigned_to => user)
|
parent = Issue.generate!(:assigned_to => user)
|
||||||
assert parent.visible?(user)
|
assert parent.visible?(user)
|
||||||
child1 = Issue.generate!(:parent_issue_id => parent.id, :assigned_to => user)
|
child1 = Issue.generate!(:parent_issue_id => parent.id, :assigned_to => user)
|
||||||
@@ -761,13 +765,6 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
:project_id => 1, :author => user,
|
:project_id => 1, :author => user,
|
||||||
:assigned_to => user)
|
:assigned_to => user)
|
||||||
assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
|
assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
|
||||||
|
|
||||||
group = Group.generate!
|
|
||||||
group.users << user
|
|
||||||
issue = Issue.generate!(:tracker => tracker, :status => status,
|
|
||||||
:project_id => 1, :author => user,
|
|
||||||
:assigned_to => group)
|
|
||||||
assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_statuses_allowed_to_should_consider_group_assignment
|
def test_new_statuses_allowed_to_should_consider_group_assignment
|
||||||
@@ -775,13 +772,17 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1,
|
||||||
:old_status_id => 1, :new_status_id => 4,
|
:old_status_id => 1, :new_status_id => 4,
|
||||||
:author => false, :assignee => true)
|
:author => false, :assignee => true)
|
||||||
user = User.find(2)
|
|
||||||
group = Group.generate!
|
group = Group.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => group, :role_ids => [1])
|
||||||
|
|
||||||
|
user = User.find(2)
|
||||||
group.users << user
|
group.users << user
|
||||||
|
|
||||||
|
with_settings :issue_group_assignment => '1' do
|
||||||
issue = Issue.generate!(:author_id => 1, :assigned_to => group)
|
issue = Issue.generate!(:author_id => 1, :assigned_to => group)
|
||||||
assert_include 4, issue.new_statuses_allowed_to(user).map(&:id)
|
assert_include 4, issue.new_statuses_allowed_to(user).map(&:id)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
|
def test_new_statuses_allowed_to_should_return_all_transitions_for_admin
|
||||||
admin = User.find(1)
|
admin = User.find(1)
|
||||||
@@ -895,40 +896,6 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_nil issue.custom_field_value(cf2)
|
assert_nil issue.custom_field_value(cf2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_safe_attributes_should_ignore_unassignable_assignee
|
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
|
|
||||||
:status_id => 1, :priority => IssuePriority.all.first,
|
|
||||||
:subject => 'test_create')
|
|
||||||
assert issue.valid?
|
|
||||||
|
|
||||||
# locked user, not allowed
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '5'})
|
|
||||||
assert_nil issue.assigned_to_id
|
|
||||||
# no member
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '1'})
|
|
||||||
assert_nil issue.assigned_to_id
|
|
||||||
# user 2 is ok
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '2'})
|
|
||||||
assert_equal 2, issue.assigned_to_id
|
|
||||||
assert issue.save
|
|
||||||
|
|
||||||
issue.reload
|
|
||||||
assert_equal 2, issue.assigned_to_id
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '5'})
|
|
||||||
assert_equal 2, issue.assigned_to_id
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '1'})
|
|
||||||
assert_equal 2, issue.assigned_to_id
|
|
||||||
# user 3 is also ok
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => '3'})
|
|
||||||
assert_equal 3, issue.assigned_to_id
|
|
||||||
assert issue.save
|
|
||||||
|
|
||||||
# removal of assignee
|
|
||||||
issue.safe_attributes=({'assigned_to_id' => ''})
|
|
||||||
assert_nil issue.assigned_to_id
|
|
||||||
assert issue.save
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_editable_custom_field_values_should_return_non_readonly_custom_values
|
def test_editable_custom_field_values_should_return_non_readonly_custom_values
|
||||||
cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string',
|
cf1 = IssueCustomField.create!(:name => 'Writable field', :field_format => 'string',
|
||||||
:is_for_all => true, :tracker_ids => [1, 2])
|
:is_for_all => true, :tracker_ids => [1, 2])
|
||||||
@@ -1250,6 +1217,15 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal "125", issue.custom_value_for(2).value
|
assert_equal "125", issue.custom_value_for(2).value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_copy_to_another_project_should_clear_assignee_if_not_valid
|
||||||
|
issue = Issue.generate!(:project_id => 1, :assigned_to_id => 2)
|
||||||
|
project = Project.generate!
|
||||||
|
|
||||||
|
issue = Issue.new.copy_from(1)
|
||||||
|
issue.project = project
|
||||||
|
assert_nil issue.assigned_to
|
||||||
|
end
|
||||||
|
|
||||||
def test_copy_should_copy_status
|
def test_copy_should_copy_status
|
||||||
orig = Issue.find(8)
|
orig = Issue.find(8)
|
||||||
assert orig.status != orig.default_status
|
assert orig.status != orig.default_status
|
||||||
@@ -1759,14 +1735,16 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "#copy should not create a journal" do
|
test "#copy should not create a journal" do
|
||||||
copy = Issue.find(1).copy({:project_id => 3, :tracker_id => 2, :assigned_to_id => 3}, :link => false)
|
copy = Issue.find(1).copy({:project_id => 3, :tracker_id => 2}, :link => false)
|
||||||
copy.save!
|
copy.save!
|
||||||
assert_equal 0, copy.reload.journals.size
|
assert_equal 0, copy.reload.journals.size
|
||||||
end
|
end
|
||||||
|
|
||||||
test "#copy should allow assigned_to changes" do
|
test "#copy should allow assigned_to changes" do
|
||||||
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
|
user = User.generate!
|
||||||
assert_equal 3, copy.assigned_to_id
|
Member.create!(:project_id => 3, :principal => user, :role_ids => [1])
|
||||||
|
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => user.id)
|
||||||
|
assert_equal user.id, copy.assigned_to_id
|
||||||
end
|
end
|
||||||
|
|
||||||
test "#copy should allow status changes" do
|
test "#copy should allow status changes" do
|
||||||
@@ -2297,8 +2275,9 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert !issue.assignable_users.include?(user)
|
assert !issue.assignable_users.include?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "#assignable_users should include the current assignee" do
|
def test_assignable_users_should_include_the_current_assignee
|
||||||
user = User.generate!
|
user = User.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => user, :role_ids => [1])
|
||||||
issue = Issue.generate!(:assigned_to => user)
|
issue = Issue.generate!(:assigned_to => user)
|
||||||
user.lock!
|
user.lock!
|
||||||
|
|
||||||
@@ -2674,7 +2653,9 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "Issue#recipients should include the assigned to user if the assigned to user is active" do
|
test "Issue#recipients should include the assigned to user if the assigned to user is active" do
|
||||||
issue = Issue.generate!(:assigned_to => User.generate!)
|
user = User.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => user, :role_ids => [1])
|
||||||
|
issue = Issue.generate!(:assigned_to => user)
|
||||||
assert issue.assigned_to, "No assigned_to set for Issue"
|
assert issue.assigned_to, "No assigned_to set for Issue"
|
||||||
assert issue.recipients.include?(issue.assigned_to.mail)
|
assert issue.recipients.include?(issue.assigned_to.mail)
|
||||||
end
|
end
|
||||||
@@ -2692,7 +2673,9 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
|
test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
|
||||||
issue = Issue.generate!(:assigned_to => User.generate!)
|
user = User.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => user, :role_ids => [1])
|
||||||
|
issue = Issue.generate!(:assigned_to => user)
|
||||||
issue.assigned_to.update!(:mail_notification => :only_owner)
|
issue.assigned_to.update!(:mail_notification => :only_owner)
|
||||||
assert !issue.recipients.include?(issue.assigned_to.mail)
|
assert !issue.recipients.include?(issue.assigned_to.mail)
|
||||||
end
|
end
|
||||||
@@ -2980,11 +2963,14 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_assigned_to_was_with_a_group
|
def test_assigned_to_was_with_a_group
|
||||||
group = Group.find(10)
|
group = Group.find(10)
|
||||||
|
Member.create!(:project_id => 1, :principal => group, :role_ids => [1])
|
||||||
|
|
||||||
|
with_settings :issue_group_assignment => '1' do
|
||||||
issue = Issue.generate!(:assigned_to => group)
|
issue = Issue.generate!(:assigned_to => group)
|
||||||
issue.reload.assigned_to = nil
|
issue.reload.assigned_to = nil
|
||||||
assert_equal group, issue.assigned_to_was
|
assert_equal group, issue.assigned_to_was
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_issue_overdue_should_respect_user_timezone
|
def test_issue_overdue_should_respect_user_timezone
|
||||||
user_in_europe = users(:users_001)
|
user_in_europe = users(:users_001)
|
||||||
|
|||||||
@@ -627,8 +627,9 @@ class MailerTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_reminder_should_include_issues_assigned_to_groups
|
def test_reminder_should_include_issues_assigned_to_groups
|
||||||
with_settings :default_language => 'en' do
|
with_settings :default_language => 'en', :issue_group_assignment => '1' do
|
||||||
group = Group.generate!
|
group = Group.generate!
|
||||||
|
Member.create!(:project_id => 1, :principal => group, :role_ids => [1])
|
||||||
group.users << User.find(2)
|
group.users << User.find(2)
|
||||||
group.users << User.find(3)
|
group.users << User.find(3)
|
||||||
|
|
||||||
|
|||||||
@@ -676,11 +676,16 @@ class QueryTest < ActiveSupport::TestCase
|
|||||||
def test_filter_assigned_to_me
|
def test_filter_assigned_to_me
|
||||||
user = User.find(2)
|
user = User.find(2)
|
||||||
group = Group.find(10)
|
group = Group.find(10)
|
||||||
|
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
|
User.current = user
|
||||||
|
|
||||||
|
with_settings :issue_group_assignment => '1' do
|
||||||
i1 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => 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)
|
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))
|
i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => other_group)
|
||||||
group.users << user
|
|
||||||
|
|
||||||
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
||||||
result = query.issues
|
result = query.issues
|
||||||
@@ -690,6 +695,7 @@ class QueryTest < ActiveSupport::TestCase
|
|||||||
assert result.include?(i2)
|
assert result.include?(i2)
|
||||||
assert !result.include?(i3)
|
assert !result.include?(i3)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_user_custom_field_filtered_on_me
|
def test_user_custom_field_filtered_on_me
|
||||||
User.current = User.find(2)
|
User.current = User.find(2)
|
||||||
@@ -1689,7 +1695,7 @@ class QueryTest < ActiveSupport::TestCase
|
|||||||
@issue1 = Issue.generate!(:project => @project, :assigned_to_id => @manager.id)
|
@issue1 = Issue.generate!(:project => @project, :assigned_to_id => @manager.id)
|
||||||
@issue2 = Issue.generate!(:project => @project, :assigned_to_id => @developer.id)
|
@issue2 = Issue.generate!(:project => @project, :assigned_to_id => @developer.id)
|
||||||
@issue3 = Issue.generate!(:project => @project, :assigned_to_id => @boss.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)
|
@issue5 = Issue.generate!(:project => @project)
|
||||||
|
|
||||||
@query = IssueQuery.new(:name => '_', :project => @project)
|
@query = IssueQuery.new(:name => '_', :project => @project)
|
||||||
|
|||||||
@@ -1140,6 +1140,7 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
author = User.generate!
|
author = User.generate!
|
||||||
assignee = User.generate!
|
assignee = User.generate!
|
||||||
|
Member.create!(:user => assignee, :project => project, :role_ids => [1])
|
||||||
member = User.generate!
|
member = User.generate!
|
||||||
Member.create!(:user => member, :project => project, :role_ids => [1])
|
Member.create!(:user => member, :project => project, :role_ids => [1])
|
||||||
issue = Issue.generate!(:project => project, :assigned_to => assignee, :author => author)
|
issue = Issue.generate!(:project => project, :assigned_to => assignee, :author => author)
|
||||||
@@ -1160,7 +1161,9 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
def test_notify_about_issue_for_previous_assignee
|
def test_notify_about_issue_for_previous_assignee
|
||||||
assignee = User.generate!(:mail_notification => 'only_assigned')
|
assignee = User.generate!(:mail_notification => 'only_assigned')
|
||||||
|
Member.create!(:user => assignee, :project_id => 1, :role_ids => [1])
|
||||||
new_assignee = User.generate!(:mail_notification => 'only_assigned')
|
new_assignee = User.generate!(:mail_notification => 'only_assigned')
|
||||||
|
Member.create!(:user => new_assignee, :project_id => 1, :role_ids => [1])
|
||||||
issue = Issue.generate!(:assigned_to => assignee)
|
issue = Issue.generate!(:assigned_to => assignee)
|
||||||
|
|
||||||
assert assignee.notify_about?(issue)
|
assert assignee.notify_about?(issue)
|
||||||
|
|||||||
Reference in New Issue
Block a user