[Rt-commit] rt branch, 4.0/no-resolve-actions-with-dependencies, created. rt-4.0.4-110-geb04675

Ruslan Zakirov ruz at bestpractical.com
Tue Dec 6 17:38:03 EST 2011


The branch, 4.0/no-resolve-actions-with-dependencies has been created
        at  eb04675af9b9e713fc285c732994eaf9bee0130e (commit)

- Log -----------------------------------------------------------------
commit a7f6eb4284a50f7ba4419a63ca752f0fafb1ee8f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 7 02:10:33 2011 +0400

    ::Test::Web::check_links - test if page has or has_no links

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index aaad882..7dc9679 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -336,6 +336,33 @@ sub custom_field_input {
     return $res;
 }
 
+sub check_links {
+    my $self = shift;
+    my %args = @_;
+
+    my %has = map {$_ => 1} @{ $args{'has'} };
+    my %has_no = map {$_ => 1} @{ $args{'has_no'} };
+
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+    my @found;
+
+    my @links = $self->followable_links;
+    foreach my $text ( grep defined && length, map $_->text, @links ) {
+        push @found, $text if $has_no{ $text };
+        delete $has{ $text };
+    }
+    if ( @found || keys %has ) {
+        Test::More::ok( 0, "expected links" );
+        Test::More::diag( "didn't expect, but found: ". join ', ', map "'$_'", @found )
+            if @found;
+        Test::More::diag( "didn't find, but expected: ". join ', ', map "'$_'", keys %has )
+            if keys %has;
+        return 0;
+    }
+    return Test::More::ok( 1, "expected links" );
+}
+
 sub DESTROY {
     my $self = shift;
     if ( !$RT::Test::Web::DESTROY++ ) {
diff --git a/t/lifecycles/basics.t b/t/lifecycles/basics.t
index 2f3d55a..72d3f57 100644
--- a/t/lifecycles/basics.t
+++ b/t/lifecycles/basics.t
@@ -102,22 +102,10 @@ my $tid;
 diag "new ->(open it)-> open";
 {
     ok $m->goto_ticket( $tid ), 'opened a ticket';
-
-    {
-        my @links = $m->followable_links;
-        ok scalar @links, 'found links';
-        my $found = 1;
-        foreach my $t ('Open It', 'Resolve', 'Reject', 'Delete') {
-            $found = 0 unless grep {($_->text ||'') eq $t} @links;
-        }
-        ok $found, 'found all transitions';
-
-        $found = 0;
-        foreach my $t ('Stall', 'Re-open', 'Undelete') {
-            $found = 1 if grep {($_->text||'') eq $t} @links;
-        }
-        ok !$found, 'no unwanted transitions';
-    }
+    $m->check_links(
+        has => ['Open It', 'Resolve', 'Reject', 'Delete'],
+        has_no => ['Stall', 'Re-open', 'Undelete'],
+    );
 
     $m->follow_link_ok({text => 'Open It'});
     $m->form_name('TicketUpdate');
@@ -132,21 +120,10 @@ diag "open ->(stall)-> stalled";
 
     ok $m->goto_ticket( $tid ), 'opened a ticket';
 
-    {
-        my @links = $m->followable_links;
-        ok scalar @links, 'found links';
-        my $found = 1;
-        foreach my $t ('Stall', 'Resolve', 'Reject') {
-            $found = 0 unless grep { ($_->text ||'') eq $t} @links;
-        }
-        ok $found, 'found all transitions';
-
-        $found = 0;
-        foreach my $t ('Open It', 'Delete', 'Re-open', 'Undelete') {
-            $found = 1 if grep { ($_->text ||'') eq $t} @links;
-        }
-        ok !$found, 'no unwanted transitions';
-    }
+    $m->check_links(
+        has => ['Stall', 'Resolve', 'Reject'],
+        has_no => ['Open It', 'Delete', 'Re-open', 'Undelete'],
+    );
 
     $m->follow_link_ok({text => 'Stall'});
     $m->form_name('TicketUpdate');
@@ -160,22 +137,10 @@ diag "stall ->(open it)-> open";
     is $tstatus->($tid), 'stalled', 'ticket is stalled';
 
     ok $m->goto_ticket( $tid ), 'opened a ticket';
-
-    {
-        my @links = $m->followable_links;
-        ok scalar @links, 'found links';
-        my $found = 1;
-        foreach my $t ('Open It') {
-            $found = 0 unless grep {($_->text ||'')eq $t} @links;
-        }
-        ok $found, 'found all transitions';
-
-        $found = 0;
-        foreach my $t ('Delete', 'Re-open', 'Undelete', 'Stall', 'Resolve', 'Reject') {
-            $found = 1 if grep { ($_->text ||'') eq $t} @links;
-        }
-        ok !$found, 'no unwanted transitions';
-    }
+    $m->check_links(
+        has => ['Open It'],
+        has_no => ['Delete', 'Re-open', 'Undelete', 'Stall', 'Resolve', 'Reject'],
+    );
 
     $m->follow_link_ok({text => 'Open It'});
 

commit eb04675af9b9e713fc285c732994eaf9bee0130e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Dec 7 02:33:21 2011 +0400

    HideResolveActionsWithDependencies option
    
    If ticket has unresolved dependencies then resolving
    is denied, but by default actions for such transitions
    are displayed in the UI. New option allows to hide such
    action.

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 795f8f8..0f65c5b 100755
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -499,6 +499,9 @@ my $build_admin_menu = sub {
                 $actions->child( forward => title => loc('Forward'), path => "/Ticket/Forward.html?id=" . $id, );
             }
 
+            my $hide_resolve_with_deps = RT->Config->Get('HideResolveActionsWithDependencies')
+                && $obj->HasUnresolvedDependencies;
+
             my $current   = $obj->Status;
             my $lifecycle = $obj->QueueObj->Lifecycle;
             my $i         = 1;
@@ -509,6 +512,9 @@ my $build_admin_menu = sub {
                 my $check = $lifecycle->CheckRight( $current => $next );
                 next unless $can->($check);
 
+                next if $hide_resolve_with_deps
+                    && $lifecycle->IsInactive($next)
+                    && !$lifecycle->IsInactive($current);
 
                 my $action = $info->{'update'} || '';
 
diff --git a/t/lifecycles/basics.t b/t/lifecycles/basics.t
index 72d3f57..40e2391 100644
--- a/t/lifecycles/basics.t
+++ b/t/lifecycles/basics.t
@@ -218,3 +218,30 @@ diag "check illegal values and transitions";
         is $ticket->Status, 'new', 'status is steal the same';
     }
 }
+
+diag "'!inactive -> inactive' actions are shown even if ticket has unresolved dependencies";
+{
+    my $child_ticket = RT::Test->create_ticket(
+        Queue => $general->id,
+        Subject => 'child',
+    );
+    my $cid = $child_ticket->id;
+    my $parent_ticket = RT::Test->create_ticket(
+        Queue => $general->id,
+        Subject => 'parent',
+        DependsOn => $child_ticket->id,
+    );
+    my $pid = $parent_ticket->id;
+
+    ok $m->goto_ticket( $pid ), 'opened a ticket';
+    $m->check_links(
+        has => ['Open It', 'Resolve', 'Reject', 'Delete' ],
+        has_no => ['Stall', 'Re-open', 'Undelete', ],
+    );
+    ok $m->goto_ticket( $cid ), 'opened a ticket';
+    $m->check_links(
+        has => ['Open It', 'Resolve', 'Reject', 'Delete'],
+        has_no => ['Stall', 'Re-open', 'Undelete'],
+    );
+}
+
diff --git a/t/lifecycles/unresolved-deps.t b/t/lifecycles/unresolved-deps.t
new file mode 100644
index 0000000..aff9a1a
--- /dev/null
+++ b/t/lifecycles/unresolved-deps.t
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+use Test::More tests => 15;
+BEGIN {require  't/lifecycles/utils.pl'};
+
+my $general = RT::Test->load_or_create_queue(
+    Name => 'General',
+);
+ok $general && $general->id, 'loaded or created a queue';
+
+# different value tested in basics
+RT->Config->Set('HideResolveActionsWithDependencies' => 1);
+
+my ($baseurl, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+{
+    my $child_ticket = RT::Test->create_ticket(
+        Queue => $general->id,
+        Subject => 'child',
+    );
+    my $cid = $child_ticket->id;
+    my $parent_ticket = RT::Test->create_ticket(
+        Queue => $general->id,
+        Subject => 'parent',
+        DependsOn => $child_ticket->id,
+    );
+    my $pid = $parent_ticket->id;
+
+    ok $m->goto_ticket( $pid ), 'opened a ticket';
+    $m->check_links(
+        has => ['Open It'],
+        has_no => ['Stall', 'Re-open', 'Undelete', 'Resolve', 'Reject', 'Delete'],
+    );
+    ok $m->goto_ticket( $cid ), 'opened a ticket';
+    $m->check_links(
+        has => ['Open It', 'Resolve', 'Reject', 'Delete'],
+        has_no => ['Stall', 'Re-open', 'Undelete'],
+    );
+}
+

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


More information about the Rt-commit mailing list