[Bps-public-commit] net-lighthouse branch, master, updated. a9683c3d6546b45d9e1d19169396bb5595ae9900

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Aug 31 03:11:20 EDT 2009


The branch, master has been updated
       via  a9683c3d6546b45d9e1d19169396bb5595ae9900 (commit)
      from  36173903325e0a82912fb55ba58cff7792fd8157 (commit)

Summary of changes:
 lib/Net/Lighthouse/Project/Message.pm |   21 ++++++++++++-------
 t/11-message.t                        |   35 +++++++++++++++++++++++---------
 2 files changed, 38 insertions(+), 18 deletions(-)

- Log -----------------------------------------------------------------
commit a9683c3d6546b45d9e1d19169396bb5595ae9900
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Aug 31 15:11:11 2009 +0800

    update project message attrs

diff --git a/lib/Net/Lighthouse/Project/Message.pm b/lib/Net/Lighthouse/Project/Message.pm
index a458be1..82498f8 100644
--- a/lib/Net/Lighthouse/Project/Message.pm
+++ b/lib/Net/Lighthouse/Project/Message.pm
@@ -5,19 +5,24 @@ use Params::Validate ':all';
 use Net::Lighthouse::Util;
 extends 'Net::Lighthouse';
 # read only attr
+has [qw/created_at updated_at/] => (
+    isa => 'Maybe[DateTime]',
+    is  => 'ro',
+);
+
 has [
-    'created_at',     'body_html',
-    'user_name',      'permalink',
-    'comments_count', 'parent_id',
-    'url',            'updated_at',
-    'id',             'user_id',
-    'project_id',     'all_attachments_count',
-    'attachments_count',
+    qw/id user_id parent_id comments_count project_id
+      all_attachments_count attachments_count/
   ] => (
-    isa => 'Maybe[Str]',
+    isa => 'Maybe[Int]',
     is  => 'ro',
   );
 
+has [ 'body_html', 'user_name', 'permalink', 'url', ] => (
+    isa => 'Maybe[Str]',
+    is  => 'ro',
+);
+
 has 'comments' => (
     isa => 'ArrayRef[Net::Lighthouse::Project::Message]',
     is  => 'ro',
diff --git a/t/11-message.t b/t/11-message.t
index 20b4d14..441b5bf 100644
--- a/t/11-message.t
+++ b/t/11-message.t
@@ -3,6 +3,7 @@ use warnings;
 
 use Test::More tests => 53;
 use Test::Mock::LWP;
+use DateTime;
 
 use_ok('Net::Lighthouse::Project');
 use_ok('Net::Lighthouse::Project::Message');
@@ -54,22 +55,36 @@ my %hash = (
     'parent_id'         => undef,
     'body'              => 'ha-ha ha-ha',
     'attachments_count' => '0',
-    'created_at'        => '2009-08-27T07:29:05Z',
+    'created_at'        => DateTime->new(
+        year => 2009,
+        month => 8,
+        day => 27,
+        hour => 7,
+        minute => 29,
+        second => 5,
+    ),
     'url' => 'http://sunnavy.lighthouseapp.com/projects/35918/messages/20298',
-    'id'  => '20298',
-    'comments_count'        => '3',
-    'all_attachments_count' => '1',
-    'project_id'            => '35918',
+    'id'  => 20298,
+    'comments_count'        => 3,
+    'all_attachments_count' => 1,
+    'project_id'            => 35918,
     'account'               => 'sunnavy',
     'user_name'             => 'sunnavy (at gmail)',
-    'updated_at'            => '2009-08-27T07:44:33Z',
+    'updated_at'            => DateTime->new(
+        year => 2009,
+        month => 8,
+        day => 27,
+        hour => 7,
+        minute => 44,
+        second => 33,
+    ),
     'body_html'             => '<div><p>ha-ha ha-ha</p></div>',
     'title'                 => '1st message lala',
-    'user_id'               => '67166'
+    'user_id'               => 67166
 );
 
 for my $k ( keys %hash ) {
-    is( $m1->$k, $hash{$k}, "$k is loaded" );
+    is_deeply( $m1->$k, $hash{$k}, "$k is loaded" );
 }
 
 is( @{$m1->comments}, 3, 'comments number' );
@@ -111,8 +126,8 @@ my $expect_initial_state = {
     'permalink'         => '',
     'body'              => '',
     'attachments_count' => '0',
-    'created_at'        => '',
-    'updated_at'        => '',
+    'created_at'        => undef,
+    'updated_at'        => undef,
     'title'             => '',
     'body_html'         => '',
     'user_id'           => '',

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



More information about the Bps-public-commit mailing list