Feature #15201 » 15201_include_locked_members_in_assignee_users.patch
| app/models/principal.rb | ||
|---|---|---|
| 89 | 89 | 
          where("1=0")
   | 
| 90 | 90 | 
    else  | 
| 91 | 91 | 
    ids = projects.map(&:id)  | 
| 92 | 
          active.where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
   | 
|
| 92 | 
    # include active and locked users  | 
|
| 93 | 
    where(:status => [STATUS_LOCKED, STATUS_ACTIVE]).  | 
|
| 94 | 
          where("#{Principal.table_name}.id IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
   | 
|
| 93 | 95 | 
    end  | 
| 94 | 96 | 
    }  | 
| 95 | 97 | 
    # Principals that are not members of projects  | 
| app/models/query.rb | ||
|---|---|---|
| 509 | 509 | 
    @principal ||= begin  | 
| 510 | 510 | 
    principals = []  | 
| 511 | 511 | 
    if project  | 
| 512 | 
            principals += project.principals.visible
   | 
|
| 512 | 
            principals += Principal.member_of(project).visible
   | 
|
| 513 | 513 | 
    unless project.leaf?  | 
| 514 | 514 | 
    principals += Principal.member_of(project.descendants.visible).visible  | 
| 515 | 515 | 
    end  | 
| test/unit/principal_test.rb | ||
|---|---|---|
| 52 | 52 | 
    assert_equal expected.map(&:id).sort, Principal.visible(user).pluck(:id).sort  | 
| 53 | 53 | 
    end  | 
| 54 | 54 | |
| 55 | 
    def test_member_of_scope_should_return_the_union_of_all_members  | 
|
| 55 | 
      def test_member_of_scope_should_return_the_union_of_all_active_and_locked_members
   | 
|
| 56 | 56 | 
    projects = Project.find([1])  | 
| 57 | 
    assert_equal [3, 2], Principal.member_of(projects).sort.map(&:id)  | 
|
| 57 | 
        assert_equal [3, 5, 2], Principal.member_of(projects).sort.map(&:id)
   | 
|
| 58 | 58 | 
    projects = Project.find([1, 2])  | 
| 59 | 
    assert_equal [3, 2, 8, 11], Principal.member_of(projects).sort.map(&:id)  | 
|
| 59 | 
        assert_equal [3, 5, 2, 8, 11], Principal.member_of(projects).sort.map(&:id)
   | 
|
| 60 | 60 | 
    end  | 
| 61 | 61 | |
| 62 | 62 | 
    def test_member_of_scope_should_be_empty_for_no_projects  |