[Bps-public-commit] net-lighthouse branch, master, updated. 36173903325e0a82912fb55ba58cff7792fd8157
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Mon Aug 31 03:03:27 EDT 2009
The branch, master has been updated
via 36173903325e0a82912fb55ba58cff7792fd8157 (commit)
from a30f4d905b980381fe9f83377bcbc34d36ce9ad0 (commit)
Summary of changes:
lib/Net/Lighthouse/Project/Changeset.pm | 25 ++++++++++++++----
t/10-changeset.t | 41 ++++++++++++++++--------------
2 files changed, 41 insertions(+), 25 deletions(-)
- Log -----------------------------------------------------------------
commit 36173903325e0a82912fb55ba58cff7792fd8157
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Aug 31 14:57:37 2009 +0800
update project changeset attrs
diff --git a/lib/Net/Lighthouse/Project/Changeset.pm b/lib/Net/Lighthouse/Project/Changeset.pm
index 9eb66dc..03c7a91 100644
--- a/lib/Net/Lighthouse/Project/Changeset.pm
+++ b/lib/Net/Lighthouse/Project/Changeset.pm
@@ -5,16 +5,29 @@ use Params::Validate ':all';
use Net::Lighthouse::Util;
extends 'Net::Lighthouse';
# read only attr
-has [
- 'body', 'revision', 'project_id', 'changed_at',
- 'changes', 'user_id', 'title', 'body_html',
- ] => (
+
+has [qw/project_id user_id/] => (
+ isa => 'Int',
+ is => 'ro',
+);
+
+has 'body_html' => (
isa => 'Maybe[Str]',
is => 'ro',
- );
+);
# read&write attr
-has [qw/body title changes changed_at revision/] => (
+has 'changed_at' => (
+ isa => 'DateTime',
+ is => 'rw',
+);
+
+has 'changes' => (
+ isa => 'ArrayRef',
+ is => 'rw',
+);
+
+has [qw/body title revision/] => (
isa => 'Maybe[Str]',
is => 'rw',
);
diff --git a/t/10-changeset.t b/t/10-changeset.t
index f7214d9..43c0416 100644
--- a/t/10-changeset.t
+++ b/t/10-changeset.t
@@ -3,6 +3,7 @@ use warnings;
use Test::More tests => 32;
use Test::Mock::LWP;
+use DateTime;
use_ok('Net::Lighthouse::Project');
use_ok('Net::Lighthouse::Project::Changeset');
@@ -45,25 +46,28 @@ is( $load, $n1, 'load return $self' );
my %hash = (
'account' => 'sunnavy',
'body' => '#{unprocessed body}',
- 'revision' => '983',
- 'changes' => '---
- - - M
- - /trunk/test/unit/changeset_test.rb
- - - M
- - /trunk/app/models/changeset.rb
- - - M
- - /trunk/db/schema.rb
-
- ',
- 'user_id' => '1',
+ 'revision' => 983,
+ 'changes' => [
+ [ 'M', '/trunk/test/unit/changeset_test.rb' ],
+ [ 'M', '/trunk/app/models/changeset.rb' ],
+ [ 'M', '/trunk/db/schema.rb' ]
+ ],
+ 'user_id' => 1,
'title' => 'rick committed changeset [983]',
'body_html' => '#{processed HTML body}',
- 'changed_at' => '2007-03-21T21:45:23Z',
- 'project_id' => '2'
+ 'changed_at' => DateTime->new(
+ year => 2007,
+ month => 3,
+ day => 21,
+ hour => 21,
+ minute => 45,
+ second => 23,
+ ),
+ 'project_id' => 2,
);
for my $k ( keys %hash ) {
- is( $n1->$k, $hash{$k}, "$k is loaded" );
+ is_deeply( $n1->$k, $hash{$k}, "$k is loaded" );
}
$Mock_response->mock(
@@ -97,13 +101,12 @@ $changeset = Net::Lighthouse::Project::Changeset->new(
my $expect_initial_state = {
'body' => '',
'revision' => '',
- 'changes' => '--- []
-
-',
+ 'changes' => [],
'user_id' => '',
'title' => '',
'body_html' => '',
- 'changed_at' => '',
- 'project_id' => '2'
+ 'changed_at' => undef,
+ 'project_id' => 2
};
+
is_deeply( $changeset->initial_state, $expect_initial_state, 'initial state' );
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list