[Rt-commit] rt branch, 5.0/rest2-collection-role-fields, repushed

? sunnavy sunnavy at bestpractical.com
Thu May 27 11:07:21 EDT 2021


The branch 5.0/rest2-collection-role-fields was deleted and repushed:
       was 31eea838530d6d0911651931b8fbfe6b59d3d6ed
       now 91e996c28e167829186aeece72412478c10653b7

1: 3906e946db = 1: 3906e946db Support core roles for ticket search result in REST2
2: 1877ce95e2 = 2: 1877ce95e2 Test core role fields for ticket search result in REST2
3: cc30db0aec = 3: cc30db0aec Support core roles for asset search result in REST2
4: e9cdc843ef = 4: e9cdc843ef Test core role fields for asset search result in REST2
5: ae0291ede1 ! 5: 0dc1ba6ee3 Support custom roles for search result in REST2
    @@ -32,6 +32,26 @@
     +            }
     +            return \%data;
     +        }
    ++
    ++    } elsif ($field =~ /^RT::CustomRole-\d+$/) {
    ++        if ( $item->DOES("RT::Record::Role::Roles") ) {
    ++            my $result = [];
    ++
    ++            my $group = $item->RoleGroup($field);
    ++            if ( !$group->Id ) {
    ++                $result = expand_uid( RT->Nobody->UserObj->UID ) if $item->_ROLES->{$field}{Single};
    ++                next;
    ++            }
    ++
    ++            my $gms = $group->MembersObj;
    ++            while ( my $gm = $gms->Next ) {
    ++                push @$result, expand_uid( $gm->MemberObj->Object->UID );
    ++            }
    ++
    ++            # Avoid the extra array ref for single member roles
    ++            $result = shift @$result if $group->SingleMemberRoleGroup;
    ++            return $result;
    ++        }
          } elsif ($field eq 'ContentLength' && $item->can('ContentLength')) {
              $result = $item->ContentLength;
          } elsif ($item->can('_Accessible') && $item->_Accessible($field => 'read')) {
6: 3e86271c57 ! 6: ae8fa4fdbe Test custom role fields for ticket search result in REST2
    @@ -25,12 +25,25 @@
     +    ok( my $ticket_url = $res->header('location') );
     +    ok( my ($ticket_id) = $ticket_url =~ qr[/ticket/(\d+)] );
     +
    -+    $res = $mech->get( "$rest_base_path/tickets?query=id=$ticket_id&fields=CustomRoles", 'Authorization' => $auth, );
    ++    $res = $mech->get(
    ++        "$rest_base_path/tickets?query=id=$ticket_id&fields=" . join( ',', $single->GroupType, $multi->GroupType ),
    ++        'Authorization' => $auth,
    ++    );
     +    is( $res->code, 200 );
     +    my $content = $mech->json_response;
     +    is( scalar @{ $content->{items} }, 1 );
     +
     +    my $ticket = $content->{items}->[0];
    ++    is( $ticket->{ $single->GroupType }{id},   'single2 at example.com', 'Single Member id in search result' );
    ++    is( $ticket->{ $multi->GroupType }[0]{id}, 'multi at example.com',   'Multi Member id in search result' );
    ++    is( $ticket->{ $multi->GroupType }[1]{id}, 'multi2 at example.com',  'Multi Member id in search result' );
    ++
    ++    $res = $mech->get( "$rest_base_path/tickets?query=id=$ticket_id&fields=CustomRoles", 'Authorization' => $auth, );
    ++    is( $res->code, 200 );
    ++    $content = $mech->json_response;
    ++    is( scalar @{ $content->{items} }, 1 );
    ++
    ++    $ticket = $content->{items}->[0];
     +    is( $ticket->{CustomRoles}{ $single->GroupType }{id}, 'single2 at example.com',  'Single Member id in search result' );
     +    is( $ticket->{CustomRoles}{ $multi->GroupType }[0]{id}, 'multi at example.com',  'Multi Member id in search result' );
     +    is( $ticket->{CustomRoles}{ $multi->GroupType }[1]{id}, 'multi2 at example.com', 'Multi Member id in search result' );
7: 948e04763a = 7: 994e4c06e9 Fix typo in REST2 doc
8: 31eea83853 ! 8: 91e996c28e Document role fields for ticket search result
    @@ -10,7 +10,7 @@
      
          XX_RT_URL_XX/REST/2.0/tickets
     -      ?fields=Owner,Status,Created,Subject,Queue,CustomFields
    -+      ?fields=Owner,Status,Created,Subject,Queue,CustomFields,Requestor,Cc,AdminCc,CustomRoles
    ++      ?fields=Owner,Status,Created,Subject,Queue,CustomFields,Requestor,Cc,AdminCc,RT::CustomRole-1
            &fields[Queue]=Name,Description
      
      Says that in the result set for tickets, the extra fields for Owner, Status,
    @@ -29,7 +29,6 @@
                           "CustomField value"
                       ]
                   }
    --         ]
     +         ],
     +         "Requestor" : [
     +            {
    @@ -46,15 +45,12 @@
     +            }
     +         ],
     +         "AdminCc" : [],
    -+         "CustomRoles" : {
    -+            "RT::CustomRole-1" : [
    -+               {
    -+                  "_url" : "XX_RT_URL_XX/REST/2.0/user/foo at example.com",
    -+                  "type" : "user",
    -+                  "id" : "foo at example.com"
    -+               }
    -+            ]
    -+         }
    ++         "RT::CustomRole-1" : [
    ++            {
    ++               "_url" : "XX_RT_URL_XX/REST/2.0/user/foo at example.com",
    ++               "type" : "user",
    ++               "id" : "foo at example.com"
    ++            }
    +          ]
            }
            { … },
    -       …



More information about the rt-commit mailing list