[Rt-commit] rt branch, 4.0/cf-date-parse-in-search, updated. rt-4.0.2-121-g0bae7ff
? sunnavy
sunnavy at bestpractical.com
Sun Oct 2 05:50:59 EDT 2011
The branch, 4.0/cf-date-parse-in-search has been updated
via 0bae7ff1295ec406b4a490eaf77977573f167895 (commit)
via 72aa6cf7f25816a6b0f4538d42e014e02e6a237d (commit)
from 3de7dde19c9ec770396f7e0439557f1c0155e776 (commit)
Summary of changes:
lib/RT/Tickets.pm | 4 +++-
t/customfields/date_search.t | 19 ++++++++++++++++++-
t/customfields/datetime_search.t | 20 +++++++++++++++++++-
3 files changed, 40 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 72aa6cf7f25816a6b0f4538d42e014e02e6a237d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Oct 2 17:39:50 2011 +0800
user may input time with only hour like 3am
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index cea4e94..6fdbef4 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1520,7 +1520,9 @@ sub _CustomFieldLimit {
if ( $date->Unix ) {
# don't consider tz for Date, use server's all the time.
- if ( $cf->Type eq 'Date' || $value !~ /:/ ) {
+ if ( $cf->Type eq 'Date'
+ || $value !~ /:|am|pm|hours|minutes|seconds/i )
+ {
$value = $date->Date( Timezone => 'server' );
}
else {
commit 0bae7ff1295ec406b4a490eaf77977573f167895
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Oct 2 17:43:30 2011 +0800
tests for the cf date parse in search using RT::Date
diff --git a/t/customfields/date_search.t b/t/customfields/date_search.t
index b425b9e..6fa3277 100644
--- a/t/customfields/date_search.t
+++ b/t/customfields/date_search.t
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use RT::Test nodata => 1, tests => 13;
+use RT::Test nodata => 1, tests => 17;
my $q = RT::Queue->new(RT->SystemUser);
ok( $q->Create( Name => 'DateCFTest' . $$ ), 'create queue' );
@@ -19,6 +19,7 @@ ok(
'create cf date'
);
ok( $cf->AddToObject($q), 'date cf apply to queue' );
+my $cf_name = $cf->Name;
my $ticket = RT::Ticket->new(RT->SystemUser);
@@ -80,6 +81,22 @@ is( $ticket->CustomFieldValues->First->Content, '2010-05-04', 'date in db is' );
}
{
+ my $tickets = RT::Tickets->new(RT->SystemUser);
+ $tickets->FromSQL( "'CF.{$cf_name}' = 'May 4 2010'" );
+ is( $tickets->Count, 1, 'found the ticket with = May 4 2010' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' < 'May 4 2010'" );
+ is( $tickets->Count, 0, 'did not find the ticket with < May 4 2010' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' < 'May 5 2010'" );
+ is( $tickets->Count, 1, 'found the ticket with < May 5 2010' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' > 'May 3 2010'" );
+ is( $tickets->Count, 1, 'found the ticket with > May 3 2010' );
+}
+
+
+{
my $tickets = RT::Tickets->new(RT->SystemUser);
$tickets->LimitCustomField(
diff --git a/t/customfields/datetime_search.t b/t/customfields/datetime_search.t
index 11fe3bc..b0131f0 100644
--- a/t/customfields/datetime_search.t
+++ b/t/customfields/datetime_search.t
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use RT::Test nodata => 1, tests => 14;
+use RT::Test nodata => 1, tests => 18;
RT->Config->Set( 'Timezone' => 'EST5EDT' ); # -04:00
my $q = RT::Queue->new(RT->SystemUser);
@@ -20,6 +20,7 @@ ok(
'create cf datetime'
);
ok( $cf->AddToObject($q), 'date cf apply to queue' );
+my $cf_name = $cf->Name;
my $ticket = RT::Ticket->new(RT->SystemUser);
@@ -78,6 +79,23 @@ is(
is( $tickets->Count, 0, 'did not find the ticket with wrong datetime: 2010-05-05' );
}
+{
+ my $tickets = RT::Tickets->new(RT->SystemUser);
+ $tickets->FromSQL( "'CF.{$cf_name}' = 'May 4 2010 7am'" );
+ is( $tickets->Count, 1, 'found the ticket with = May 4 2010 7am' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' = 'May 4 2010 8am'" );
+ is( $tickets->Count, 0, 'did not find the ticket with = May 4 2010 8am' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' > 'May 3 2010 7am'" );
+ is( $tickets->Count, 1, 'found the ticket with > May 3 2010 7am' );
+
+ $tickets->FromSQL( "'CF.{$cf_name}' < 'May 4 2010 8am'" );
+ is( $tickets->Count, 1, 'found the ticket with < May 4 2010 8am' );
+
+}
+
+
my $tickets = RT::Tickets->new( RT->SystemUser );
$tickets->UnLimit;
while( my $ticket = $tickets->Next ) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list