[Rt-commit] rt branch, 4.4/initial-custom-field, repushed

Shawn Moore shawn at bestpractical.com
Wed Apr 20 17:21:57 EDT 2016


The branch 4.4/initial-custom-field was deleted and repushed:
       was 4c6e7f8f31716274dffd5a486d761a9c4207bb9c
       now 2928131f083ca86b334a8c89c31043cd6ac2d82e

1:  60c12a8 = 1:  60c12a8 Add a new SetInitialCustomField right
2:  dd4105f = 2:  dd4105f Hide empty "edit custom fields" panels
3:  fe7ca40 = 3:  fe7ca40 Add a $CF->CurrentUserCanSee method and switch to it
4:  c9c6f35 = 4:  c9c6f35 Support passing the CF directly to CustomFieldValueIsEmpty
-:  ------- > 5:  2a66732 Avoid constantly reloading the OCFV CustomFieldObj
5:  4c6e7f8 ! 6:  2928131 Allow SetInitialCustomFieldValue without SeeCustomField
    @@ -64,6 +64,18 @@
                      my $system_cf = RT::CustomField->new( RT->SystemUser );
                      $system_cf->LoadById($cfid);
     
    +diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
    +--- a/lib/RT/ObjectCustomFieldValue.pm
    ++++ b/lib/RT/ObjectCustomFieldValue.pm
    +@@
    +     my $self = shift;
    + 
    +     my $cf = $self->CustomFieldObj;
    ++    $cf->{include_set_initial} = $self->{include_set_initial};
    + 
    +     return undef unless $cf->CurrentUserCanSee;
    + 
    +
     diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
     --- a/lib/RT/Record.pm
     +++ b/lib/RT/Record.pm
    @@ -76,6 +88,26 @@
          unless ( $cf->Id ) {
              return ( 0, $self->loc( "Custom field [_1] not found", $args{'Field'} ) );
          }
    +@@
    +         }
    + 
    +         my $new_value = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
    ++        $new_value->{include_set_initial} = 1 if $args{'ForCreation'};
    +         $new_value->Load( $new_value_id );
    + 
    +         # now that adding the new value was successful, delete the old one
    +
    +diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
    +--- a/lib/RT/Ticket.pm
    ++++ b/lib/RT/Ticket.pm
    +@@
    +         next unless $arg =~ /^CustomField-(\d+)$/i;
    +         my $cfid = $1;
    +         my $cf = $self->LoadCustomFieldByIdentifier($cfid);
    ++        $cf->{include_set_initial} = 1;
    +         next unless $cf->ObjectTypeFromLookupType($cf->__Value('LookupType'))->isa(ref $self);
    + 
    +         foreach my $value (
     
     diff --git a/share/html/Elements/EditCustomFields b/share/html/Elements/EditCustomFields
     --- a/share/html/Elements/EditCustomFields
    @@ -88,3 +120,98 @@
      
      $CustomFields->LimitToGrouping( $Object => $Grouping ) if defined $Grouping;
      
    +
    +diff --git a/t/web/cf_set_initial.t b/t/web/cf_set_initial.t
    +new file mode 100644
    +--- /dev/null
    ++++ b/t/web/cf_set_initial.t
    +@@
    ++use strict;
    ++use warnings;
    ++
    ++use RT::Test tests => undef;
    ++my ($baseurl, $m) = RT::Test->started_ok;
    ++
    ++ok $m->login, 'logged in';
    ++
    ++my $cf = RT::CustomField->new( RT->SystemUser );
    ++my ($cfid, $msg) = $cf->Create(
    ++    Name => 'Test Set Initial CF',
    ++    Queue => '0',
    ++    Type => 'FreeformSingle',
    ++);
    ++
    ++my $tester = RT::Test->load_or_create_user( Name => 'tester', Password => '123456' );
    ++RT::Test->set_rights(
    ++    { Principal => $tester->PrincipalObj,
    ++      Right => [qw(SeeQueue ShowTicket CreateTicket)],
    ++    },
    ++);
    ++ok $m->login( $tester->Name, 123456, logout => 1), 'logged in';
    ++
    ++diag "check that we have no CF on the create"
    ++    ." ticket page when user has no SetInitialCustomField right";
    ++{
    ++    $m->submit_form(
    ++        form_name => "CreateTicketInQueue",
    ++        fields => { Queue => 'General' },
    ++    );
    ++    $m->content_lacks('Test Set Initial CF', 'has no CF input');
    ++
    ++    my $form = $m->form_name("TicketCreate");
    ++    my $edit_field = "Object-RT::Ticket--CustomField-$cfid-Value"; 
    ++    ok !$form->find_input( $edit_field ), 'no form field on the page';
    ++
    ++    $m->submit_form(
    ++        form_name => "TicketCreate",
    ++        fields => { Subject => 'test' },
    ++    );
    ++    $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
    ++
    ++    $m->content_lacks('Test Set Initial CF', 'has no CF on the page');
    ++    $m->follow_link( text => 'Custom Fields');
    ++    $m->content_lacks('Test Set Initial CF', 'has no CF field');
    ++}
    ++
    ++RT::Test->set_rights(
    ++    { Principal => $tester->PrincipalObj,
    ++      Right => [qw(SeeQueue ShowTicket CreateTicket SetInitialCustomField)],
    ++    },
    ++);
    ++
    ++diag "check that we have the CF on the create"
    ++    ." ticket page when user has SetInitialCustomField but no SeeCustomField";
    ++{
    ++    $m->submit_form(
    ++        form_name => "CreateTicketInQueue",
    ++        fields => { Queue => 'General' },
    ++    );
    ++    $m->content_contains('Test Set Initial CF', 'has CF input');
    ++
    ++    my $form = $m->form_name("TicketCreate");
    ++    my $edit_field = "Object-RT::Ticket--CustomField-$cfid-Value"; 
    ++    ok $form->find_input( $edit_field ), 'has form field on the page';
    ++
    ++    $m->submit_form(
    ++        form_name => "TicketCreate",
    ++        fields => {
    ++            $edit_field => 'yatta',
    ++            Subject => 'test 2',
    ++        },
    ++    );
    ++    $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
    ++    if (my ($id) = $m->content =~ /Ticket (\d+) created/) {
    ++        my $ticket = RT::Ticket->new(RT->SystemUser);
    ++        my ($ok, $msg) = $ticket->Load($id);
    ++        ok($ok, "loaded ticket $id");
    ++        is($ticket->Subject, 'test 2', 'subject is correct');
    ++        is($ticket->FirstCustomFieldValue('Test Set Initial CF'), 'yatta', 'CF was set correctly');
    ++    }
    ++
    ++    $m->content_lacks('Test Set Initial CF', 'has no CF on the page');
    ++    $m->follow_link( text => 'Custom Fields');
    ++    $m->content_lacks('Test Set Initial CF', 'has no CF edit field');
    ++}
    ++
    ++undef $m;
    ++done_testing;



More information about the rt-commit mailing list