[Rt-commit] [rtir] 02/03: remove constituency email tests

Dustin Graves dustin at bestpractical.com
Fri May 13 19:11:34 EDT 2016


This is an automated email from the git hooks/post-receive script.

dustin pushed a commit to branch 3.4/rewrite-constituency-tests
in repository rtir.

commit bdb04dd50b979b5c4ffbed9a947a62ddaf4b5008
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri May 13 23:07:37 2016 +0000

    remove constituency email tests
    
    constituencies are normal queues now, and all email behavior is covered
    by standard RT queue tests
---
 t/constituency/email.t          | 125 ------------------------------
 t/constituency/email_outgoing.t | 163 ----------------------------------------
 2 files changed, 288 deletions(-)

diff --git a/t/constituency/email.t b/t/constituency/email.t
deleted file mode 100644
index 49cd172..0000000
--- a/t/constituency/email.t
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/usr/bin/perl
-
-use Test::More skip_all => 'constituencies being rebuilt';
-use strict;
-use warnings;
-
-use RT::IR::Test tests => undef;
-
-# Test must be run wtih RT_SiteConfig:
-# Set(@MailPlugins, 'Auth::MailFrom');
-
-use_ok('RT::IR');
-
-my $cf;
-diag "load the field" if $ENV{'TEST_VERBOSE'};
-{
-    my $cfs = RT::CustomFields->new( $RT::SystemUser );
-    $cfs->Limit( FIELD => 'Name', VALUE => 'Constituency', CASESENSITIVE => 0 );
-    $cf = $cfs->First;
-    ok $cf, 'have a field';
-    ok $cf->id, 'with some ID';
-}
-
-diag "get list of values" if $ENV{'TEST_VERBOSE'};
-my @values = map $_->Name, @{ $cf->Values->ItemsArrayRef };
-
-RT::Test->started_ok;
-my $agent = default_agent();
-my $rtir_user = rtir_user();
-
-diag "create a ticket via email from an unprivileged user" if $ENV{'TEST_VERBOSE'};
-{
-    my $i = 0;
-    my $val = RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'}; # we have one default
-
-    my $text = <<EOF;
-From: someone\@example.com
-To: rt\@@{[RT->Config->Get('rtname')]}
-Subject: This is a test of constituency functionality
-
-Foob!
-EOF
-    # Only test IR, random end users don't have permissions to create in other Queues
-    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
-    is $status >> 8, 0, "The mail gateway exited ok";
-    ok $id, "created ticket $id";
-
-    $agent->display_ticket( $id);
-    $agent->content_like( qr/\Q$val/, "value on the page" );
-
-    my $ticket = RT::Ticket->new( $RT::SystemUser );
-    $ticket->Load( $id );
-    ok $ticket->id, 'loaded ticket';
-    is $ticket->FirstCustomFieldValue('Constituency'), $val, 'correct value';
-}
-
-diag "create a ticket via gate" if $ENV{'TEST_VERBOSE'};
-{
-    my $i = 0;
-    my $val = RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'}; # we have one default
-    foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
-        diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
-
-        my $text = <<EOF;
-From: @{[ $rtir_user->EmailAddress ]}
-To: rt\@@{[RT->Config->Get('rtname')]}
-Subject: This is a test of constituency functionality
-
-Foob!
-EOF
-        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue);
-        is $status >> 8, 0, "The mail gateway exited ok";
-        ok $id, "created ticket $id";
-
-        $agent->display_ticket( $id);
-        $agent->content_like( qr/\Q$val/, "value on the page" );
-
-        my $ticket = RT::Ticket->new( $RT::SystemUser );
-        $ticket->Load( $id );
-        ok $ticket->id, 'loaded ticket';
-        is $ticket->QueueObj->Name, $queue, 'correct queue';
-        is $ticket->FirstCustomFieldValue('Constituency'), $val, 'correct value';
-    }
-}
-
-diag "create a ticket via gate using Extension header" if $ENV{'TEST_VERBOSE'};
-{
-    my $i = 0;
-
-    my $default = RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'};
-    my $val = (grep lc($_) ne lc($default), @values)[0];
-    ok $val, 'find not default value';
-
-    my $incident_id; # block couldn't be created without incident id
-    foreach my $queue( 'Incidents', 'Incident Reports', 'Investigations', 'Blocks' ) {
-        diag "create a ticket in the '$queue' queue" if $ENV{'TEST_VERBOSE'};
-
-        my $text = <<EOF;
-From: @{[ $rtir_user->EmailAddress ]}
-To: rt\@@{[RT->Config->Get('rtname')]}
-X-RT-Mail-Extension: $val
-Subject: This is a test of constituency functionality
-
-Foob!
-EOF
-        my ($status, $id) = RT::Test->send_via_mailgate($text, queue => $queue );
-        is $status >> 8, 0, "The mail gateway exited ok";
-        ok $id, "created ticket $id";
-        $incident_id = $id if $queue eq 'Incidents';
-
-        $agent->display_ticket( $id);
-        $agent->content_like( qr/\Q$val/, "value on the page" );
-
-        my $ticket = RT::Ticket->new( $RT::SystemUser );
-        $ticket->Load( $id );
-        ok( $ticket->id, 'loaded ticket' );
-        is( $ticket->QueueObj->Name, $queue, 'correct queue' );
-        is( $ticket->FirstCustomFieldValue('Constituency'), $val, 'correct value' );
-    }
-}
-
-
-
-undef $agent;
-done_testing;
diff --git a/t/constituency/email_outgoing.t b/t/constituency/email_outgoing.t
deleted file mode 100644
index 353a7bb..0000000
--- a/t/constituency/email_outgoing.t
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::More skip_all => 'constituencies being rebuilt';
-use RT::IR::Test tests => undef;
-
-RT->Config->Get('RTIR_CustomFieldsDefaults')->{'Constituency'} = 'EDUNET';
-
-my ($queue_ir, $queue_ir_edunet, $queue_ir_govnet);
-diag "create or update queues";
-{
-    $queue_ir = RT::Test->load_or_create_queue(
-        Name              => 'Incident Reports',
-        CorrespondAddress => 'reports at example.com',
-        CommentAddress    => 'reports-comment at example.com',
-    );
-    ok $queue_ir && $queue_ir->id, 'loaded or created queue_ir';
-
-    $queue_ir_edunet = RT::Test->load_or_create_queue(
-        Name              => 'Incident Reports - EDUNET',
-        CorrespondAddress => 'edu-reports at example.com',
-        CommentAddress    => 'edu-reports-comment at example.com',
-    );
-    ok $queue_ir_edunet && $queue_ir_edunet->id, 'loaded or created queue';
-
-    $queue_ir_govnet = RT::Test->load_or_create_queue(
-        Name              => 'Incident Reports - GOVNET',
-        CorrespondAddress => 'gov-reports at example.com',
-        CommentAddress    => 'gov-reports-comment at example.com',
-    );
-    ok $queue_ir_govnet && $queue_ir_govnet->id, 'loaded or created queue';
-}
-
-my $eduhandler = RT::Test->load_or_create_user( Name => 'eduhandler', Password => 'eduhandler' );
-ok $eduhandler->id, "Created eduhandler";
-my $govhandler = RT::Test->load_or_create_user( Name => 'govhandler', Password => 'govhandler' );
-ok $govhandler->id, "Created govhandler";
-
-ok( RT::Test->add_rights(
-    { Principal => 'Privileged',
-        Right => [qw(ModifyCustomField SeeCustomField OwnTicket)], },
-    { Principal => $govhandler, Object => $queue_ir,
-        Right => [qw(SeeQueue CreateTicket)] },
-    { Principal => $eduhandler, Object => $queue_ir,
-        Right => [qw(SeeQueue CreateTicket)] },
-    { Principal => $eduhandler, Object => $queue_ir_edunet,
-        Right => [qw(ShowTicket CreateTicket)] },
-    { Principal => $govhandler, Object => $queue_ir_govnet,
-        Right => [qw(ShowTicket CreateTicket)] },
-), 'added rights');
-
-my ($baseurl) = RT::Test->started_ok;
-my $agent = default_agent();
-my $rtir_user = rtir_user();
-$agent->login( rtir_test_user => 'rtir_test_pass' );
-
-diag "create an IR via base address";
-{
-    RT::Test->clean_caught_mails;
-
-        my $text = <<EOF;
-From: @{[ $rtir_user->EmailAddress ]}
-To: reports\@example.com
-Subject: This is a test of constituency functionality
-
-Foob!
-EOF
-    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
-    is $status >> 8, 0, "The mail gateway exited ok";
-    ok $id, "created ticket $id";
-
-    my $ticket = RT::Ticket->new( $RT::SystemUser );
-    $ticket->Load( $id );
-    ok $ticket->id, 'loaded the ticket';
-    is $ticket->FirstCustomFieldValue('Constituency'), 'EDUNET', 'correct value';
-
-    $agent->display_ticket( $id);
-    $agent->content_like( qr/\QEDUNET/, "value on the page" );
-
-    my @mail = RT::Test->fetch_caught_mails;
-    ok @mail, 'there are some outgoing emails';
-    
-    my $from_ok = 1;
-    foreach my $mail ( @mail ) {
-        next if $mail =~ /^From:\s*.*?edu-reports\@example\.com/mi;
-        diag $mail;
-        $from_ok = 0;
-        last;
-    }
-    ok $from_ok, 'all From addresses are correct';
-}
-diag "create an IR under GOVNET";
-{
-    RT::Test->clean_caught_mails;
-
-    my $text = <<EOF;
-From: @{[ $rtir_user->EmailAddress ]}
-To: gov-reports\@example.com
-X-RT-Mail-Extension: GOVNET
-Subject: This is a test of constituency functionality
-
-Foob!
-EOF
-    my ($status, $id) = RT::Test->send_via_mailgate($text, queue => 'Incident Reports');
-    is $status >> 8, 0, "The mail gateway exited ok";
-    ok $id, "created ticket $id";
-
-    my $ticket = RT::Ticket->new( $RT::SystemUser );
-    $ticket->Load( $id );
-    ok $ticket->id, 'loaded the ticket';
-    is $ticket->FirstCustomFieldValue('Constituency'), 'GOVNET', 'correct value';
-
-    $agent->display_ticket( $id);
-    $agent->content_like( qr/GOVNET/, "value on the page" );
-
-    my @mail = RT::Test->fetch_caught_mails;
-    ok @mail, 'there are some outgoing emails';
-    
-    my $from_ok = 1;
-    foreach my $mail ( @mail ) {
-        next if $mail =~ /^From:\s*.*?gov-reports\@example\.com/mi;
-        diag $mail;
-        $from_ok = 0;
-        last;
-    }
-    ok $from_ok, 'all From addresses are correct';
-}
-
-diag "GOV user creates an IR under EDUNET, check addresses";
-{
-    RT::Test->clean_caught_mails;
-
-    ok($agent->login('govhandler', 'govhandler', logout => 1 ));
-    my $id = $agent->create_ir(
-        
-        { Subject => "test", Requestors => $rtir_user->EmailAddress },
-        { Constituency => 'EDUNET' },
-    );
-    ok $id, "created ticket $id";
-
-    my $ticket = RT::Ticket->new( $RT::SystemUser );
-    $ticket->Load( $id );
-    ok $ticket->id, 'loaded the ticket';
-    is $ticket->FirstCustomFieldValue('Constituency'), 'EDUNET', 'correct value';
-
-    my @mail = RT::Test->fetch_caught_mails;
-    ok @mail, 'there are some outgoing emails';
-    
-    my $from_ok = 1;
-    foreach my $mail ( @mail ) {
-        next if $mail =~ /^From:\s*.*?edu-reports\@example\.com/mi;
-        diag $mail;
-        $from_ok = 0;
-        last;
-    }
-    ok $from_ok, 'all From addresses are correct';
-}
-
-
-undef $agent;
-done_testing;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list