[Rt-commit] rt branch, 4.0-trunk, updated. rt-4.0.10-88-gd0193ef
Ruslan Zakirov
ruz at bestpractical.com
Wed Mar 13 16:39:05 EDT 2013
The branch, 4.0-trunk has been updated
via d0193ef37c635891a319440460b50a5bd2fe59ff (commit)
via 7c0471747e466c1e745ba4dafd52d1e66d93e32e (commit)
via 99f47db89d27573d827a6301b8c7e896e502f75a (commit)
from 556f81d7ec161695f53e1773ffa09c99fe64ed3d (commit)
Summary of changes:
lib/RT/CustomField.pm | 3 +--
t/customfields/date.t | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 t/customfields/date.t
- Log -----------------------------------------------------------------
commit 7c0471747e466c1e745ba4dafd52d1e66d93e32e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Feb 11 21:41:37 2013 +0400
test that Date CFs are parsed properly
test API, check both abosolute and relative variants
diff --git a/t/customfields/date.t b/t/customfields/date.t
new file mode 100644
index 0000000..0b8d1e9
--- /dev/null
+++ b/t/customfields/date.t
@@ -0,0 +1,74 @@
+#!/usr/bin/perl
+
+use Test::MockTime qw(set_fixed_time restore_time);
+
+use warnings;
+use strict;
+
+use RT::Test tests => undef;
+
+RT::Test->set_rights(
+ { Principal => 'Everyone', Right => [qw(
+ SeeQueue ShowTicket CreateTicket SeeCustomField ModifyCustomField
+ )] },
+);
+
+my $q = RT::Test->load_or_create_queue( Name => 'General' );
+ok $q && $q->id, 'loaded or created a queue';
+
+my $user_m = RT::Test->load_or_create_user( Name => 'moscow', Timezone => 'Europe/Moscow' );
+ok $user_m && $user_m->id;
+
+my $user_b = RT::Test->load_or_create_user( Name => 'boston', Timezone => 'America/New_York' );
+ok $user_b && $user_b->id;
+
+
+my $cf_name = 'A Date';
+my $cf;
+{
+ $cf = RT::CustomField->new(RT->SystemUser);
+ ok(
+ $cf->Create(
+ Name => $cf_name,
+ 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::CurrentUser->new( $user_m ) );
+ my ($id) = $ticket->Create(
+ Queue => $q->id,
+ Subject => 'Test',
+ 'CustomField-'. $cf->id => '2013-02-11',
+ );
+ my $cf_value = $ticket->CustomFieldValues($cf_name)->First;
+ is( $cf_value->Content, '2013-02-11', 'correct value' );
+
+ $ticket = RT::Ticket->new( RT::CurrentUser->new( $user_b ) );
+ $ticket->Load($id);
+ is( $ticket->FirstCustomFieldValue($cf_name), '2013-02-11', 'correct value' );
+}
+
+# in moscow it's already Feb 11, so tomorrow is Feb 12
+set_fixed_time("2013-02-10T23:10:00Z");
+{
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user_m ) );
+ my ($id) = $ticket->Create(
+ Queue => $q->id,
+ Subject => 'Test',
+ 'CustomField-'. $cf->id => 'tomorrow',
+ );
+ my $cf_value = $ticket->CustomFieldValues($cf_name)->First;
+ is( $cf_value->Content, '2013-02-12', 'correct value' );
+
+ $ticket = RT::Ticket->new( RT::CurrentUser->new( $user_b ) );
+ $ticket->Load($id);
+ is( $ticket->FirstCustomFieldValue($cf_name), '2013-02-12', 'correct value' );
+}
+
+done_testing();
commit d0193ef37c635891a319440460b50a5bd2fe59ff
Merge: 556f81d 7c04717
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Mar 14 00:38:43 2013 +0400
Merge branch '4.0/parse-cf-date-in-user-timezone' into 4.0-trunk
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list