Project

General

Profile

Feature #15201 » 15201_include_locked_members_in_assignee_users.patch

Marius BĂLTEANU, 2017-05-14 08:48

View differences:

app/models/principal.rb
where("1=0")
else
ids = projects.map(&:id)
active.where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
# include active and locked users
where(:status => [STATUS_LOCKED, STATUS_ACTIVE]).
where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
end
}
# Principals that are not members of projects
app/models/query.rb
@principal ||= begin
principals = []
if project
principals += project.principals.visible
principals += Principal.member_of(project).visible
unless project.leaf?
principals += Principal.member_of(project.descendants.visible).visible
end
test/unit/principal_test.rb
assert_equal expected.map(&:id).sort, Principal.visible(user).pluck(:id).sort
end
def test_member_of_scope_should_return_the_union_of_all_members
def test_member_of_scope_should_return_the_union_of_all_active_and_locked_members
projects = Project.find([1])
assert_equal [3, 2], Principal.member_of(projects).sort.map(&:id)
assert_equal [3, 5, 2], Principal.member_of(projects).sort.map(&:id)
projects = Project.find([1, 2])
assert_equal [3, 2, 8, 11], Principal.member_of(projects).sort.map(&:id)
assert_equal [3, 5, 2, 8, 11], Principal.member_of(projects).sort.map(&:id)
end
def test_member_of_scope_should_be_empty_for_no_projects
(1-1/6)