[Rt-commit] rt branch, 4.0/apply-scrips-to-multiple-queues, updated. rt-4.0.4-203-g17ac6e1

Ruslan Zakirov ruz at bestpractical.com
Tue Jan 24 13:44:14 EST 2012


The branch, 4.0/apply-scrips-to-multiple-queues has been updated
       via  17ac6e1c933fafa0138403b92fa9d10180f46e2d (commit)
       via  f621d10970e56bb4b35154d8838fd7bb03cab439 (commit)
       via  c98ca2a49998023c091aace183a4510f2aff2753 (commit)
      from  b900a61804d2d8a6a87023c4cc0006af199d42cc (commit)

Summary of changes:
 lib/RT/SearchBuilder/ApplyAndSort.pm |    4 +-
 lib/RT/Test/Web.pm                   |   18 +++++++
 share/html/Admin/Scrips/Modify.html  |    3 +-
 share/html/Admin/Scrips/Objects.html |    2 +-
 t/web/scrips.t                       |   87 +++++++++++++++++++++++++++++++++-
 5 files changed, 110 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit c98ca2a49998023c091aace183a4510f2aff2753
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 24 20:28:57 2012 +0400

    test basics of administrating scrips

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 7dc9679..0d044cd 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -336,6 +336,24 @@ sub custom_field_input {
     return $res;
 }
 
+sub value_name {
+    my $self = shift;
+    my $field = shift;
+
+    my $input = $self->current_form->find_input( $field )
+        or return undef;
+
+    my @names = $input->value_names;
+    return $input->value unless @names;
+
+    my @values = $input->possible_values;
+    for ( my $i = 0; $i < @values; $i++ ) {
+        return $names[ $i ] if $values[ $i ] eq $input->value;
+    }
+    return undef;
+}
+
+
 sub check_links {
     my $self = shift;
     my %args = @_;
diff --git a/t/web/scrips.t b/t/web/scrips.t
index 7d18a50..7d02886 100644
--- a/t/web/scrips.t
+++ b/t/web/scrips.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 14;
+use RT::Test tests => 41;
 
 # TODO:
 # Test the rest of the conditions.
@@ -103,3 +103,51 @@ sub prepare_code_with_value {
 
     RT::Test->clean_caught_mails;
 }
+
+note "check basics in scrip's admin interface";
+{
+    $m->follow_link_ok( { id => 'tools-config-global-scrips-create' } );
+    ok $m->form_name('CreateScrip');
+    is $m->value_name('Description'), '', 'empty value';
+    is $m->value_name('ScripAction'), '-', 'empty value';
+    is $m->value_name('ScripCondition'), '-', 'empty value';
+    is $m->value_name('Template'), '-', 'empty value';
+    $m->field('Description' => 'test');
+    $m->click('Create');
+    $m->content_contains("Action is mandatory argument");
+
+    ok $m->form_name('CreateScrip');
+    is $m->value_name('Description'), 'test', 'value stays on the page';
+    $m->select('ScripAction' => 'Notify Ccs');
+    $m->click('Create');
+    $m->content_contains("Template is mandatory argument");
+
+    ok $m->form_name('CreateScrip');
+    is $m->value_name('Description'), 'test', 'value stays on the page';
+    is $m->value_name('ScripAction'), 'Notify Ccs', 'value stays on the page';
+    $m->select('Template' => 'Blank');
+    $m->click('Create');
+    $m->content_contains("Condition is mandatory argument");
+
+    ok $m->form_name('CreateScrip');
+    is $m->value_name('Description'), 'test', 'value stays on the page';
+    is $m->value_name('ScripAction'), 'Notify Ccs', 'value stays on the page';
+    $m->select('ScripCondition' => 'On Close');
+    $m->click('Create');
+    $m->content_contains("Scrip Created");
+
+    ok $m->form_name('ModifyScrip');
+    is $m->value_name('Description'), 'test', 'correct value';
+    is $m->value_name('ScripCondition'), 'On Close', 'correct value';
+    is $m->value_name('ScripAction'), 'Notify Ccs', 'correct value';
+    is $m->value_name('Template'), 'Blank', 'correct value';
+    $m->field('Description' => 'test test');
+    $m->click('Update');
+    # regression
+    $m->content_lacks("Template is mandatory argument");
+
+    ok $m->form_name('ModifyScrip');
+    is $m->value_name('Description'), 'test test', 'correct value';
+    $m->content_contains("The new value has been set.");
+}
+

commit f621d10970e56bb4b35154d8838fd7bb03cab439
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 24 20:32:08 2012 +0400

    treat empty value as no update

diff --git a/share/html/Admin/Scrips/Modify.html b/share/html/Admin/Scrips/Modify.html
index 2aa8564..7167ee1 100755
--- a/share/html/Admin/Scrips/Modify.html
+++ b/share/html/Admin/Scrips/Modify.html
@@ -112,9 +112,10 @@ $added_to_any = 1 if defined $disabled;
 if ( $Update ) {
     my @attribs = qw(
         Description
-        ScripAction ScripCondition Template
         CustomPrepareCode CustomCommitCode CustomIsApplicableCode
     );
+    push @attribs, grep defined $ARGS{$_} && length $ARGS{$_},
+        qw(ScripAction ScripCondition Template);
     if ( $ARGS{'SetEnabled'} && $added_to_any ) {
         push @attribs, 'Disabled';
         $ARGS{"Disabled"} = $ARGS{"Enabled"}? 0 : 1;

commit 17ac6e1c933fafa0138403b92fa9d10180f46e2d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Jan 24 22:42:55 2012 +0400

    make sure limiting by stage works with OID limit

diff --git a/lib/RT/SearchBuilder/ApplyAndSort.pm b/lib/RT/SearchBuilder/ApplyAndSort.pm
index a45a3e6..8d335da 100644
--- a/lib/RT/SearchBuilder/ApplyAndSort.pm
+++ b/lib/RT/SearchBuilder/ApplyAndSort.pm
@@ -54,6 +54,7 @@ sub LimitTargetToNotApplied {
         OPERATOR => 'IS',
         VALUE    => 'NULL',
     );
+    return $alias;
 }
 
 =head2 LimitTargetToApplied
@@ -77,6 +78,7 @@ sub LimitTargetToApplied {
         OPERATOR => 'IS NOT',
         VALUE    => 'NULL',
     );
+    return $alias;
 }
 
 sub JoinTargetToApplied {
@@ -84,7 +86,7 @@ sub JoinTargetToApplied {
     my $collection = shift;
     my @ids = @_;
 
-    my $alias = $self->JoinTargetToThis( $collection, New => 1, Left => 1 );
+    my $alias = $self->JoinTargetToThis( $collection, New => 0, Left => 1 );
     return $alias unless @ids;
 
     # XXX: we need different EA in join clause, but DBIx::SB
diff --git a/share/html/Admin/Scrips/Objects.html b/share/html/Admin/Scrips/Objects.html
index 0324ab8..12e6cc4 100644
--- a/share/html/Admin/Scrips/Objects.html
+++ b/share/html/Admin/Scrips/Objects.html
@@ -49,7 +49,7 @@
 <& /Elements/Tabs &>
 <& /Elements/ListActions &>
 
-<form action="Objects.html" method="post">
+<form action="Objects.html" method="post" name="AddRemoveScrip">
 <input type="hidden" class="hidden" name="id" value="<% $id %>" />
 
 % if ( $is_global ) {
diff --git a/t/web/scrips.t b/t/web/scrips.t
index 7d02886..daca113 100644
--- a/t/web/scrips.t
+++ b/t/web/scrips.t
@@ -3,7 +3,9 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 41;
+use RT::Test tests => 54;
+
+RT->Config->Set( UseTransactionBatch => 1 );
 
 # TODO:
 # Test the rest of the conditions.
@@ -151,3 +153,38 @@ note "check basics in scrip's admin interface";
     $m->content_contains("The new value has been set.");
 }
 
+note "apply scrip in different stage to different queues";
+{
+    my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
+    ok $queue && $queue->id, 'loaded or created queue';
+
+    $m->follow_link_ok( { id => 'tools-config-queues' } );
+    $m->follow_link_ok( { text => 'General' } );
+    $m->follow_link_ok( { id => 'page-scrips-create'});
+
+    ok $m->form_name('CreateScrip');
+    $m->field('Description' => 'test stage');
+    $m->select('ScripCondition' => 'On Close');
+    $m->select('ScripAction' => 'Notify Ccs');
+    $m->select('Template' => 'Blank');
+    $m->click('Create');
+    $m->content_contains("Scrip Created");
+
+    my ($sid) = ($m->content =~ /Modify scrip #(\d+)/);
+    ok $sid, "found scrip id on the page";
+
+    $m->follow_link_ok({ text => 'Added to' });
+    ok $m->form_name('AddRemoveScrip');
+    $m->select('Stage' => 'Batch');
+    $m->tick( "AddScrip-$sid" => $queue->id );
+    $m->click('Update');
+    $m->content_contains("Object created");
+
+    $m->follow_link_ok({ text => 'General' });
+    $m->follow_link_ok({ id => 'page-scrips' });
+
+    my (@matches) = $m->content =~ /test stage/g;
+    # regression
+    is scalar @matches, 1, 'scrip mentioned only once';
+}
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list