[Rt-commit] rt branch, cf-date, updated. rt-3.8.8-196-g6633f23

? sunnavy sunnavy at bestpractical.com
Wed Aug 4 03:25:27 EDT 2010


The branch, cf-date has been updated
       via  6633f23ca23ab371e48cd4b2994ec6a9be228c45 (commit)
       via  c49fa80cb29c1ac64c75291c9db16414d7824e9c (commit)
       via  2c88d50aefe3ec7fe3fa094da553c091a7b38819 (commit)
       via  66271b1b9374082a291971b92f5b17c507a87121 (commit)
       via  c05542d69e9e8ceb0f3146806cb61313c8fbe56c (commit)
       via  ddc5a1fdd46494a28c0fd9bd0072df62016571aa (commit)
       via  312ee7b4f8bced27ae606cb00f5cb67b160a3589 (commit)
       via  4c2b63334aba6b3986c72192df1f82c723f3cf4b (commit)
      from  ee1b9a2a0e1156de21876a7ce3b8f84a8a84392f (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm                      |   32 ++++-
 lib/RT/Interface/Web.pm                            |    2 +-
 lib/RT/Record.pm                                   |    9 +-
 lib/RT/Tickets_Overlay.pm                          |    5 +-
 share/html/Elements/EditCustomFieldDate            |    4 +-
 ...EditCustomFieldDate => EditCustomFieldDateTime} |    0
 share/html/Elements/ShowCustomFieldDate            |    4 +-
 ...ShowCustomFieldDate => ShowCustomFieldDateTime} |    0
 share/html/Search/Elements/PickCFs                 |    7 +-
 t/api/cf_date_search.t                             |  110 +++++++----------
 t/api/{cf_date_search.t => cf_datetime_search.t}   |   12 +-
 t/web/cf_date.t                                    |  137 ++++++-------------
 t/web/{cf_date.t => cf_datetime.t}                 |   35 ++---
 13 files changed, 150 insertions(+), 207 deletions(-)
 copy share/html/Elements/{EditCustomFieldDate => EditCustomFieldDateTime} (100%)
 copy share/html/Elements/{ShowCustomFieldDate => ShowCustomFieldDateTime} (100%)
 copy t/api/{cf_date_search.t => cf_datetime_search.t} (92%)
 copy t/web/{cf_date.t => cf_datetime.t} (87%)

- Log -----------------------------------------------------------------
commit 4c2b63334aba6b3986c72192df1f82c723f3cf4b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:01:41 2010 +0800

    split date cf into date and datetime

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 76b15f6..0de811b 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -102,6 +102,11 @@ our %FieldTypes = (
         'Select date',			# loc
         'Select up to [_1] dates',	# loc
     ],
+    DateTime => [
+        'Select multiple datetimes',	# loc
+        'Select datetime',			# loc
+        'Select up to [_1] datetimes',	# loc
+    ],
 );
 
 
@@ -835,7 +840,7 @@ Returns an array of all possible composite values for custom fields.
 
 sub TypeComposites {
     my $self = shift;
-    return grep !/(?:[Tt]ext|Combobox|Date)-0/, map { ("$_-1", "$_-0") } $self->Types;
+    return grep !/(?:[Tt]ext|Combobox|Date|DateTime)-0/, map { ("$_-1", "$_-0") } $self->Types;
 }
 
 =head2 SetLookupType
@@ -1167,13 +1172,26 @@ sub AddValueForObject {
         }
     }
     # For date, we need to store Content as ISO date
-    if ($self->Type eq 'Date') {
+    if ($self->Type =~ /^Date(Time)?$/) {
+        my $is_datetime = $1 ? 1 : 0; 
         my $DateObj = new RT::Date( $self->CurrentUser );
-        $DateObj->Set(
-            Format => 'unknown',
-            Value  => $args{'Content'},
-        );
-        $args{'Content'} = $DateObj->ISO;
+        if ($is_datetime) {
+            $DateObj->Set(
+                Format => 'unknown',
+                Value  => $args{'Content'},
+            );
+            $args{'Content'} = $DateObj->ISO;
+        }
+        else {
+            # in case user input date with time, let's omit it by setting timezone 
+            # to utc so "hour" won't affect "day"
+            $DateObj->Set(
+                Format => 'unknown',
+                Value  => $args{'Content'},
+                Timezone => 'UTC',
+            );
+            $args{'Content'} = $DateObj->Date( Timezone => 'UTC' );
+        }
     }
     my $newval = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
     my $val    = $newval->Create(
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index c5f3e26..be73cbe 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1738,7 +1738,7 @@ sub _ProcessObjectCustomFieldUpdates {
             }
 
             # For Date Cfs, @values is empty when there is no changes (no datas in form input)
-            return @results if ( $cf->Type eq 'Date' && ! @values );
+            return @results if ( $cf->Type =~ /^Date(?:Time)?$/ && ! @values );
 
             $cf_values->RedoSearch;
             while ( my $cf_value = $cf_values->Next ) {
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 877c04c..90854b5 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1714,8 +1714,9 @@ sub _AddCustomFieldValue {
 
         my $new_content = $new_value->Content;
 
-        # For date, we need to display them in "human" format in result message
-        if ($cf->Type eq 'Date') {
+        # For datetime, we need to display them in "human" format in result message
+        #XXX TODO how about date without time?
+        if ($cf->Type eq 'DateTime') {
             my $DateObj = new RT::Date( $self->CurrentUser );
             $DateObj->Set(
                 Format => 'ISO',
@@ -1821,8 +1822,8 @@ sub DeleteCustomFieldValue {
     }
 
     my $old_value = $TransactionObj->OldValue;
-    # For date, we need to display them in "human" format in result message
-    if ( $cf->Type eq 'Date' ) {
+    # For datetime, we need to display them in "human" format in result message
+    if ( $cf->Type eq 'DateTime' ) {
         my $DateObj = new RT::Date( $self->CurrentUser );
         $DateObj->Set(
             Format => 'ISO',
diff --git a/lib/RT/Tickets_Overlay.pm b/lib/RT/Tickets_Overlay.pm
index 60e3e6a..31d612f 100755
--- a/lib/RT/Tickets_Overlay.pm
+++ b/lib/RT/Tickets_Overlay.pm
@@ -1428,8 +1428,9 @@ sub _CustomFieldLimit {
             $cf->Load($field);
 
             # need special treatment for Date
-            if ( $cf->Type eq 'Date' ) {
-                if ( $op eq '=' ) {
+            if ( $cf->Type =~ /^Date(Time)?$/ ) {
+                my $is_datetime = $1 ? 1 : 0;
+                if ( $is_datetime && $op eq '=' ) {
 
                # if we're specifying =, that means we want everything on a
                # particular single day.  in the database, we need to check for >
diff --git a/share/html/Elements/EditCustomFieldDate b/share/html/Elements/EditCustomFieldDate
index 9df469f..b6e10a0 100644
--- a/share/html/Elements/EditCustomFieldDate
+++ b/share/html/Elements/EditCustomFieldDate
@@ -46,11 +46,11 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 % my $name = $NamePrefix.$CustomField->Id.'-Values';
-<& /Elements/SelectDate, Name => "$name", current => 0 &> (<%$DateObj->AsString%>)
+<& /Elements/SelectDate, Name => "$name", current => 0, ShowTime => 0 &> (<%$DateObj->AsString(Time => 0)%>)
 
 <%INIT>
 my $DateObj = new RT::Date ( $session{'CurrentUser'} );
-$DateObj->Set( Format => 'ISO', Value => $Default );
+$DateObj->Set( Format => 'unknown', Value => $Default );
 </%INIT>
 <%ARGS>
 $Object => undef
diff --git a/share/html/Elements/ShowCustomFieldDate b/share/html/Elements/ShowCustomFieldDate
index 4e8ad67..3a80c0a 100644
--- a/share/html/Elements/ShowCustomFieldDate
+++ b/share/html/Elements/ShowCustomFieldDate
@@ -48,8 +48,8 @@
 <%INIT>
  my $content = $Object->Content;
  my $DateObj = new RT::Date ( $session{'CurrentUser'} );
- $DateObj->Set( Format => 'ISO', Value => $content );
- $content = $DateObj->AsString;
+ $DateObj->Set( Format => 'unknown', Value => $content );
+ $content = $DateObj->AsString(Time => 0);
 </%INIT>
 <%$content|n%>
 <%ARGS>
diff --git a/share/html/Search/Elements/PickCFs b/share/html/Search/Elements/PickCFs
index beda9f7..65d58f3 100644
--- a/share/html/Search/Elements/PickCFs
+++ b/share/html/Search/Elements/PickCFs
@@ -80,7 +80,7 @@ while ( my $CustomField = $CustomFields->Next ) {
     $line{'Field'} = $CustomField->Name;
 
     # Op
-    if ($CustomField->Type eq 'Date') {
+    if ($CustomField->Type =~ /^Date(Time)?$/ ) {
         $line{'Op'} = {
             Type => 'component',
             Path => '/Elements/SelectDateRelation',
@@ -99,11 +99,12 @@ while ( my $CustomField = $CustomFields->Next ) {
     }
 
     # Value
-    if ($CustomField->Type eq 'Date') {
+    if ($CustomField->Type =~ /^Date(Time)?$/) {
+        my $is_datetime = $1 ? 1 : 0;
         $line{'Value'} = {
             Type => 'component',
             Path => '/Elements/SelectDate',
-            Arguments => {},
+            Arguments => { $is_datetime ? ( ShowTime => 0 ) : (), },
         };
     } else {
         $line{'Value'} = {

commit 312ee7b4f8bced27ae606cb00f5cb67b160a3589
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:12:42 2010 +0800

    add (Show|Edit)CustomFieldDateTiem

diff --git a/share/html/Elements/EditCustomFieldDateTime b/share/html/Elements/EditCustomFieldDateTime
new file mode 100644
index 0000000..9df469f
--- /dev/null
+++ b/share/html/Elements/EditCustomFieldDateTime
@@ -0,0 +1,62 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%#  
+%# This software is Copyright (c) 1996-2008 Best Practical Solutions, LLC 
+%#                                          <jesse at bestpractical.com>
+%# 
+%# (Except where explicitly superseded by other copyright notices)
+%# 
+%# 
+%# LICENSE:
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/copyleft/gpl.html.
+%# 
+%# 
+%# CONTRIBUTION SUBMISSION POLICY:
+%# 
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%# 
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%# 
+%# END BPS TAGGED BLOCK }}}
+% my $name = $NamePrefix.$CustomField->Id.'-Values';
+<& /Elements/SelectDate, Name => "$name", current => 0 &> (<%$DateObj->AsString%>)
+
+<%INIT>
+my $DateObj = new RT::Date ( $session{'CurrentUser'} );
+$DateObj->Set( Format => 'ISO', Value => $Default );
+</%INIT>
+<%ARGS>
+$Object => undef
+$CustomField => undef
+$NamePrefix => undef
+$Default => undef
+$Values => undef
+$MaxValues => 1
+</%ARGS>
diff --git a/share/html/Elements/ShowCustomFieldDateTime b/share/html/Elements/ShowCustomFieldDateTime
new file mode 100644
index 0000000..4e8ad67
--- /dev/null
+++ b/share/html/Elements/ShowCustomFieldDateTime
@@ -0,0 +1,57 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%# 
+%# COPYRIGHT:
+%#  
+%# This software is Copyright (c) 1996-2008 Best Practical Solutions, LLC 
+%#                                          <jesse at bestpractical.com>
+%# 
+%# (Except where explicitly superseded by other copyright notices)
+%# 
+%# 
+%# LICENSE:
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%# 
+%# 
+%# CONTRIBUTION SUBMISSION POLICY:
+%# 
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%# 
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%# 
+%# END BPS TAGGED BLOCK }}}
+<%INIT>
+ my $content = $Object->Content;
+ my $DateObj = new RT::Date ( $session{'CurrentUser'} );
+ $DateObj->Set( Format => 'ISO', Value => $content );
+ $content = $DateObj->AsString;
+</%INIT>
+<%$content|n%>
+<%ARGS>
+$Object
+</%ARGS>

commit ddc5a1fdd46494a28c0fd9bd0072df62016571aa
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:13:33 2010 +0800

    update datetime cf test

diff --git a/t/api/cf_date_search.t b/t/api/cf_datetime_search.t
similarity index 92%
rename from t/api/cf_date_search.t
rename to t/api/cf_datetime_search.t
index fd45e2d..d0884f4 100644
--- a/t/api/cf_date_search.t
+++ b/t/api/cf_datetime_search.t
@@ -7,17 +7,17 @@ use RT::Test tests => 14;
 RT->Config->Set( 'Timezone' => 'EST5EDT' ); # -04:00
 
 my $q = RT::Queue->new($RT::SystemUser);
-ok( $q->Create( Name => 'DateCFTest' . $$ ), 'create queue' );
+ok( $q->Create( Name => 'DateTimeCFTest' . $$ ), 'create queue' );
 
 my $cf = RT::CustomField->new($RT::SystemUser);
 ok(
     $cf->Create(
-        Name       => 'date-' . $$,
-        Type       => 'Date',
+        Name       => 'datetime-' . $$,
+        Type       => 'DateTime',
         MaxValues  => 1,
         LookupType => RT::Ticket->CustomFieldLookupType,
     ),
-    'create cf date'
+    'create cf datetime'
 );
 ok( $cf->AddToObject($q), 'date cf apply to queue' );
 
@@ -75,7 +75,7 @@ is(
         VALUE       => '2010-05-05',
     );
 
-    is( $tickets->Count, 0, 'did not find the ticket with wrong date: 2010-05-05' );
+    is( $tickets->Count, 0, 'did not find the ticket with wrong datetime: 2010-05-05' );
 }
 
 my $tickets = RT::Tickets->new( $RT::SystemUser );
@@ -113,7 +113,7 @@ while( my $ticket  = $tickets->Next ) {
         OPERATOR    => '=',
         VALUE       => '2010-06-22',
     );
-    is( $tickets->Count, 1, 'found the ticket with rough date: 2010-06-22' );
+    is( $tickets->Count, 1, 'found the ticket with rough datetime: 2010-06-22' );
 
     $tickets->UnLimit;
     $tickets->LimitCustomField(
diff --git a/t/web/cf_date.t b/t/web/cf_datetime.t
similarity index 90%
rename from t/web/cf_date.t
rename to t/web/cf_datetime.t
index 1560ded..7072746 100644
--- a/t/web/cf_date.t
+++ b/t/web/cf_datetime.t
@@ -11,7 +11,7 @@ ok $m->login, 'logged in as root';
 my $root = RT::User->new( $RT::SystemUser );
 ok( $root->Load('root'), 'load root user' );
 
-my $cf_name = 'test cf date';
+my $cf_name = 'test cf datetime';
 
 my $cfid;
 diag "Create a CF" if $ENV{'TEST_VERBOSE'};
@@ -25,7 +25,7 @@ diag "Create a CF" if $ENV{'TEST_VERBOSE'};
         form_name => "ModifyCustomField",
         fields => {
             Name          => $cf_name,
-            TypeComposite => 'Date-1',
+            TypeComposite => 'DateTime-1',
             LookupType    => 'RT::Queue-RT::Ticket',
         },
     );
@@ -61,7 +61,7 @@ diag 'check valid inputs with various timezones in ticket create page' if $ENV{'
         form_name => "CreateTicketInQueue",
         fields => { Queue => 'General' },
     );
-    $m->content_like(qr/Select date/, 'has cf field');
+    $m->content_like(qr/Select datetime/, 'has cf field');
     # Calendar link is added via js, so can't test it as link
     $m->content_like(qr/Calendar/, 'has Calendar');
 
@@ -84,13 +84,13 @@ diag 'check valid inputs with various timezones in ticket create page' if $ENV{'
         'date in db is in UTC'
     );
 
-    $m->content_like(qr/test cf date:/, 'has no cf date field on the page');
-    $m->content_like(qr/Tue May 04 13:00:01 2010/, 'has cf date value on the page');
+    $m->content_like(qr/test cf datetime:/, 'has no cf datetime field on the page');
+    $m->content_like(qr/Tue May 04 13:00:01 2010/, 'has cf datetime value on the page');
 
     $root->SetTimezone( 'Asia/Shanghai' );
     # interesting that $m->reload doesn't work
     $m->get_ok( $m->uri );
-    $m->content_like(qr/Wed May 05 01:00:01 2010/, 'cf date value respects user timezone');
+    $m->content_like(qr/Wed May 05 01:00:01 2010/, 'cf datetime value respects user timezone');
 
     $m->submit_form(
         form_name => "CreateTicketInQueue",
@@ -114,11 +114,11 @@ diag 'check valid inputs with various timezones in ticket create page' if $ENV{'
         'date in db is in UTC'
     );
 
-    $m->content_like(qr/test cf date:/, 'has no cf date field on the page');
-    $m->content_like(qr/Thu May 06 07:00:01 2010/, 'cf date input respects user timezone');
+    $m->content_like(qr/test cf datetime:/, 'has no cf datetime field on the page');
+    $m->content_like(qr/Thu May 06 07:00:01 2010/, 'cf datetime input respects user timezone');
     $root->SetTimezone( 'EST5EDT' ); # back to -04:00
     $m->get_ok( $m->uri );
-    $m->content_like(qr/Wed May 05 19:00:01 2010/, 'cf date value respects user timezone');
+    $m->content_like(qr/Wed May 05 19:00:01 2010/, 'cf datetime value respects user timezone');
 }
 
 
@@ -133,7 +133,7 @@ diag 'check search build page' if $ENV{'TEST_VERBOSE'};
         'have at least 2 Calendar links' );
     $m->form_number(3);
     my ($cf_op) =
-      $m->find_all_inputs( type => 'option', name_regex => qr/test cf date/ );
+      $m->find_all_inputs( type => 'option', name_regex => qr/test cf datetime/ );
     is_deeply(
         [ $cf_op->possible_values ],
         [ '<', '=', '>' ],
@@ -141,7 +141,7 @@ diag 'check search build page' if $ENV{'TEST_VERBOSE'};
     );
 
     my ($cf_field) =
-      $m->find_all_inputs( type => 'text', name_regex => qr/test cf date/ );
+      $m->find_all_inputs( type => 'text', name_regex => qr/test cf datetime/ );
     $m->submit_form(
         fields => {
             $cf_op->name    => '=',
@@ -238,6 +238,6 @@ diag 'check search build page' if $ENV{'TEST_VERBOSE'};
     );
     $m->content_like(qr/Ticket \d+ created/, "a ticket is created succesfully");
 
-    $m->content_like(qr/test cf date:/, 'has no cf date field on the page');
+    $m->content_like(qr/test cf datetime:/, 'has no cf datetime field on the page');
     $m->content_unlike(qr/foodate/, 'invalid dates not set');
 }

commit c05542d69e9e8ceb0f3146806cb61313c8fbe56c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:24:18 2010 +0800

    cf_date_search.t is for cf date only now

diff --git a/t/api/cf_date_search.t b/t/api/cf_date_search.t
new file mode 100644
index 0000000..0ffbfa7
--- /dev/null
+++ b/t/api/cf_date_search.t
@@ -0,0 +1,127 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use RT::Test tests => 13;
+
+my $q = RT::Queue->new($RT::SystemUser);
+ok( $q->Create( Name => 'DateCFTest' . $$ ), 'create queue' );
+
+my $cf = RT::CustomField->new($RT::SystemUser);
+ok(
+    $cf->Create(
+        Name       => 'date-' . $$,
+        Type       => 'Date',
+        MaxValues  => 1,
+        LookupType => RT::Ticket->CustomFieldLookupType,
+    ),
+    'create cf date'
+);
+ok( $cf->AddToObject($q), 'date cf apply to queue' );
+
+my $ticket = RT::Ticket->new($RT::SystemUser);
+
+ok(
+    $ticket->Create(
+        Queue                    => $q->id,
+        Subject                  => 'Test',
+        'CustomField-' . $cf->id => '2010-05-04',
+    ),
+    'create ticket with cf set to 2010-05-04'
+);
+
+is(
+    $ticket->CustomFieldValues->First->Content,
+    '2010-05-04',
+    'date in db is'
+);
+
+{
+
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '=',
+        VALUE       => '2010-05-04',
+    );
+    is( $tickets->Count, 1, 'found the ticket with exact date: 2010-05-04' );
+
+}
+
+{
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '>',
+        VALUE       => '2010-05-03',
+    );
+
+    is( $tickets->Count, 1, 'found ticket with > 2010-05-03' );
+}
+
+{
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '<',
+        VALUE       => '2010-05-05',
+    );
+
+    is( $tickets->Count, 1, 'found ticket with < 2010-05-05' );
+}
+
+{
+
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '=',
+        VALUE       => '2010-05-05',
+    );
+
+    is( $tickets->Count, 0, 'did not find the ticket with = 2010-05-05' );
+}
+
+{
+
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '<',
+        VALUE       => '2010-05-03',
+    );
+
+    is( $tickets->Count, 0, 'did not find the ticket with < 2010-05-03' );
+}
+
+{
+
+    my $tickets = RT::Tickets->new($RT::SystemUser);
+    $tickets->LimitCustomField(
+        CUSTOMFIELD => $cf->id,
+        OPERATOR    => '>',
+        VALUE       => '2010-05-05',
+    );
+
+    is( $tickets->Count, 0, 'did not find the ticket with > 2010-05-05' );
+}
+
+
+$ticket = RT::Ticket->new($RT::SystemUser);
+
+ok(
+    $ticket->Create(
+        Queue                    => $q->id,
+        Subject                  => 'Test',
+        'CustomField-' . $cf->id => '2010-05-04 12:34:56',
+    ),
+    'create ticket with cf set to 2010-05-04 12:34:56'
+);
+
+is(
+    $ticket->CustomFieldValues->First->Content,
+    '2010-05-04',
+    'date in db only has date'
+);
+

commit 66271b1b9374082a291971b92f5b17c507a87121
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:26:23 2010 +0800

    a bit perltidy for cf_date_search.t

diff --git a/t/api/cf_date_search.t b/t/api/cf_date_search.t
index 0ffbfa7..15abd70 100644
--- a/t/api/cf_date_search.t
+++ b/t/api/cf_date_search.t
@@ -31,11 +31,7 @@ ok(
     'create ticket with cf set to 2010-05-04'
 );
 
-is(
-    $ticket->CustomFieldValues->First->Content,
-    '2010-05-04',
-    'date in db is'
-);
+is( $ticket->CustomFieldValues->First->Content, '2010-05-04', 'date in db is' );
 
 {
 
@@ -107,7 +103,6 @@ is(
     is( $tickets->Count, 0, 'did not find the ticket with > 2010-05-05' );
 }
 
-
 $ticket = RT::Ticket->new($RT::SystemUser);
 
 ok(
@@ -119,9 +114,6 @@ ok(
     'create ticket with cf set to 2010-05-04 12:34:56'
 );
 
-is(
-    $ticket->CustomFieldValues->First->Content,
-    '2010-05-04',
-    'date in db only has date'
-);
+is( $ticket->CustomFieldValues->First->Content,
+    '2010-05-04', 'date in db only has date' );
 

commit 2c88d50aefe3ec7fe3fa094da553c091a7b38819
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:29:28 2010 +0800

    a bit diag fix

diff --git a/t/web/cf_datetime.t b/t/web/cf_datetime.t
index 7072746..e0a7ef5 100644
--- a/t/web/cf_datetime.t
+++ b/t/web/cf_datetime.t
@@ -122,8 +122,6 @@ diag 'check valid inputs with various timezones in ticket create page' if $ENV{'
 }
 
 
-diag 'check invalid inputs' if $ENV{'TEST_VERBOSE'};
-
 diag 'check search build page' if $ENV{'TEST_VERBOSE'};
 {
     $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
@@ -221,6 +219,8 @@ diag 'check search build page' if $ENV{'TEST_VERBOSE'};
     $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
 }
 
+diag 'check invalid inputs' if $ENV{'TEST_VERBOSE'};
+
 {
     $m->submit_form(
         form_name => "CreateTicketInQueue",

commit c49fa80cb29c1ac64c75291c9db16414d7824e9c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:37:02 2010 +0800

    cf_date.t is for date only now

diff --git a/t/web/cf_date.t b/t/web/cf_date.t
new file mode 100644
index 0000000..7e34107
--- /dev/null
+++ b/t/web/cf_date.t
@@ -0,0 +1,192 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 35;
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+my $root = RT::User->new($RT::SystemUser);
+ok( $root->Load('root'), 'load root user' );
+
+my $cf_name = 'test cf date';
+
+my $cfid;
+diag "Create a CF" if $ENV{'TEST_VERBOSE'};
+{
+    $m->follow_link( text => 'Configuration' );
+    $m->title_is( q/RT Administration/, 'admin screen' );
+    $m->follow_link( text => 'Custom Fields' );
+    $m->title_is( q/Select a Custom Field/, 'admin-cf screen' );
+    $m->follow_link( text => 'Create' );
+    $m->submit_form(
+        form_name => "ModifyCustomField",
+        fields    => {
+            Name          => $cf_name,
+            TypeComposite => 'Date-1',
+            LookupType    => 'RT::Queue-RT::Ticket',
+        },
+    );
+    $m->content_like( qr/Object created/, 'created CF sucessfully' );
+    $cfid = $m->form_name('ModifyCustomField')->value('id');
+    ok $cfid, "found id of the CF in the form, it's #$cfid";
+}
+
+diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'};
+my $queue = RT::Test->load_or_create_queue( Name => 'General' );
+ok $queue && $queue->id, 'loaded or created queue';
+
+{
+    $m->follow_link( text => 'Queues' );
+    $m->title_is( q/Admin queues/, 'admin-queues screen' );
+    $m->follow_link( text => 'General' );
+    $m->title_is( q/Editing Configuration for queue General/,
+        'admin-queue: general' );
+    $m->follow_link( text => 'Ticket Custom Fields' );
+    $m->title_is( q/Edit Custom Fields for General/,
+        'admin-queue: general cfid' );
+
+    $m->form_name('EditCustomFields');
+    $m->tick( "AddCustomField" => $cfid );
+    $m->click('UpdateCFs');
+
+    $m->content_like( qr/Object created/, 'TCF added to the queue' );
+}
+
+diag 'check valid inputs with various timezones in ticket create page'
+  if $ENV{'TEST_VERBOSE'};
+{
+    my ( $ticket, $id );
+
+    $m->submit_form(
+        form_name => "CreateTicketInQueue",
+        fields    => { Queue => 'General' },
+    );
+    $m->content_like( qr/Select date/, 'has cf field' );
+
+    $m->submit_form(
+        form_name => "TicketCreate",
+        fields    => {
+            Subject                                       => 'test 2010-05-04',
+            Content                                       => 'test',
+            "Object-RT::Ticket--CustomField-$cfid-Values" => '2010-05-04',
+        },
+    );
+    ok( ($id) = $m->content =~ /Ticket (\d+) created/, "created ticket $id" );
+
+    $ticket = RT::Ticket->new($RT::SystemUser);
+    $ticket->Load($id);
+    is( $ticket->CustomFieldValues($cfid)->First->Content,
+        '2010-05-04', 'date in db' );
+
+    $m->content_like( qr/test cf date:/, 'has no cf date field on the page' );
+    $m->content_like( qr/Tue May 04 2010/,
+        'has cf date value on the page' );
+}
+
+diag 'check search build page' if $ENV{'TEST_VERBOSE'};
+{
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+
+    $m->form_number(3);
+    my ($cf_op) =
+      $m->find_all_inputs( type => 'option', name_regex => qr/test cf date/ );
+    is_deeply(
+        [ $cf_op->possible_values ],
+        [ '<', '=', '>' ],
+        'right oprators'
+    );
+
+    my ($cf_field) =
+      $m->find_all_inputs( type => 'text', name_regex => qr/test cf date/ );
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '=',
+            $cf_field->name => '2010-05-04'
+        },
+        button => 'DoSearch',
+    );
+
+    $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
+    $m->content_contains( '2010-05-04',     'got the right ticket' );
+    $m->content_lacks( '2010-05-06', 'did not get the wrong ticket' );
+
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+    $m->form_number(3);
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '<',
+            $cf_field->name => '2010-05-05'
+        },
+        button => 'DoSearch',
+    );
+    $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
+
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+    $m->form_number(3);
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '>',
+            $cf_field->name => '2010-05-03',
+        },
+        button => 'DoSearch',
+    );
+    $m->content_contains( 'Found 1 ticket', 'Found 1 ticket' );
+
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+    $m->form_number(3);
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '=',
+            $cf_field->name => '2010-05-05',
+        },
+        button => 'DoSearch',
+    );
+    $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
+
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+    $m->form_number(3);
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '<',
+            $cf_field->name => '2010-05-03',
+        },
+        button => 'DoSearch',
+    );
+    $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
+
+    $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
+    $m->form_number(3);
+    $m->submit_form(
+        fields => {
+            $cf_op->name    => '>',
+            $cf_field->name => '2010-05-05',
+        },
+        button => 'DoSearch',
+    );
+    $m->content_contains( 'Found 0 tickets', 'Found 0 tickets' );
+}
+
+diag 'check invalid inputs' if $ENV{'TEST_VERBOSE'};
+{
+    $m->submit_form(
+        form_name => "CreateTicketInQueue",
+        fields    => { Queue => 'General' },
+    );
+    my $form = $m->form_name("TicketCreate");
+
+    $m->submit_form(
+        form_name => "TicketCreate",
+        fields    => {
+            Subject                                       => 'test',
+            Content                                       => 'test',
+            "Object-RT::Ticket--CustomField-$cfid-Values" => 'foodate',
+        },
+    );
+    $m->content_like( qr/Ticket \d+ created/,
+        "a ticket is created succesfully" );
+
+    $m->content_like( qr/test cf date:/, 'has no cf date field on the page' );
+    $m->content_unlike( qr/foodate/, 'invalid dates not set' );
+}

commit 6633f23ca23ab371e48cd4b2994ec6a9be228c45
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Aug 4 14:52:53 2010 +0800

    no Calendar link test as we won't use that very soon

diff --git a/t/web/cf_datetime.t b/t/web/cf_datetime.t
index e0a7ef5..2d11f53 100644
--- a/t/web/cf_datetime.t
+++ b/t/web/cf_datetime.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 46;
+use RT::Test tests => 44;
 RT->Config->Set( 'Timezone' => 'EST5EDT' ); # -04:00
 
 my ($baseurl, $m) = RT::Test->started_ok;
@@ -62,8 +62,6 @@ diag 'check valid inputs with various timezones in ticket create page' if $ENV{'
         fields => { Queue => 'General' },
     );
     $m->content_like(qr/Select datetime/, 'has cf field');
-    # Calendar link is added via js, so can't test it as link
-    $m->content_like(qr/Calendar/, 'has Calendar');
 
     $m->submit_form(
         form_name => "TicketCreate",
@@ -126,9 +124,6 @@ diag 'check search build page' if $ENV{'TEST_VERBOSE'};
 {
     $m->get_ok( $baseurl . '/Search/Build.html?Query=Queue=1' );
 
-    # make sure there are at least 2 Calendar links
-    $m->content_like( qr/createCalendar.*createCalendar/s,
-        'have at least 2 Calendar links' );
     $m->form_number(3);
     my ($cf_op) =
       $m->find_all_inputs( type => 'option', name_regex => qr/test cf datetime/ );

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


More information about the Rt-commit mailing list