summaryrefslogtreecommitdiff
path: root/rt/t/rtname.t
blob: ef6092bb2e18cf242e01cb685dcc814a5b96913e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl
use strict;
use warnings;

use RT::Test nodata => 1, tests => 9;

use RT::Interface::Email;

# normal use case, regexp set to rtname
RT->Config->Set( rtname => "site" );
RT->Config->Set( EmailSubjectTagRegex => qr/site/ );
RT->Config->Set( rtname => undef );
is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);

# oops usecase, where the regexp is scragged
RT->Config->Set( rtname => "site" );
RT->Config->Set( EmailSubjectTagRegex => undef );
is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);

# set to a simple regexp. NOTE: we no longer match "site"
RT->Config->Set( rtname => "site");
RT->Config->Set( EmailSubjectTagRegex => qr/newsite/);
is(RT::Interface::Email::ParseTicketId("[site #123] test"), undef);
is(RT::Interface::Email::ParseTicketId("[newsite #123] test"), 123);

# set to a more complex regexp
RT->Config->Set( rtname => "site" );
RT->Config->Set( EmailSubjectTagRegex => qr/newsite|site/ );
is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[newsite #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);