Defect #28180 ยป 0001-Ignore-archived-project-memberships-when-calculating.patch
app/models/query.rb | ||
---|---|---|
319 | 319 |
" INNER JOIN #{table_name_prefix}queries_roles#{table_name_suffix} qr on qr.query_id = q.id" + |
320 | 320 |
" INNER JOIN #{MemberRole.table_name} mr ON mr.role_id = qr.role_id" + |
321 | 321 |
" INNER JOIN #{Member.table_name} m ON m.id = mr.member_id AND m.user_id = ?" + |
322 |
" INNER JOIN #{Project.table_name} p ON p.id = m.project_id AND p.status <> ?" + |
|
322 | 323 |
" WHERE q.project_id IS NULL OR q.project_id = m.project_id))" + |
323 | 324 |
" OR #{table_name}.user_id = ?", |
324 |
VISIBILITY_PUBLIC, VISIBILITY_ROLES, user.id, user.id) |
|
325 |
VISIBILITY_PUBLIC, VISIBILITY_ROLES, user.id, Project::STATUS_ARCHIVED, user.id)
|
|
325 | 326 |
elsif user.logged? |
326 | 327 |
scope.where("#{table_name}.visibility = ? OR #{table_name}.user_id = ?", VISIBILITY_PUBLIC, user.id) |
327 | 328 |
else |
... | ... | |
340 | 341 |
if project |
341 | 342 |
(user.roles_for_project(project) & roles).any? |
342 | 343 |
else |
343 |
Member.where(:user_id => user.id).joins(:roles).where(:member_roles => {:role_id => roles.map(&:id)}).any?
|
|
344 |
user.memberships.joins(:member_roles).where(:member_roles => {:role_id => roles.map(&:id)}).any?
|
|
344 | 345 |
end |
345 | 346 |
else |
346 | 347 |
user == self.user |
test/unit/query_test.rb | ||
---|---|---|
1790 | 1790 | |
1791 | 1791 |
assert q.visible?(User.find(1)) |
1792 | 1792 |
assert IssueQuery.visible(User.find(1)).find_by_id(q.id) |
1793 | ||
1794 |
# Should ignore archived project memberships |
|
1795 |
Project.find(1).archive |
|
1796 |
assert !q.visible?(User.find(3)) |
|
1797 |
assert_nil IssueQuery.visible(User.find(3)).find_by_id(q.id) |
|
1793 | 1798 |
end |
1794 | 1799 | |
1795 | 1800 |
def test_query_with_private_visibility_should_be_visible_to_owner |