[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 697d95ab86fb7086cc168aa98b3276a59b800f64
Shawn Moore
sartak at bestpractical.com
Thu Feb 10 15:28:43 EST 2011
The branch, master has been updated
via 697d95ab86fb7086cc168aa98b3276a59b800f64 (commit)
from 9f4da81426585809aeae7f6b5a1323da1f7a29bc (commit)
Summary of changes:
.../RecordHistory/Mixin/Model/RecordHistory.pm | 6 ++++--
t/TestApp-Plugin-RecordHistory/t/001-basic.t | 6 +-----
t/TestApp-Plugin-RecordHistory/t/003-action.t | 10 ++--------
t/TestApp-Plugin-RecordHistory/t/004-manual.t | 10 ++--------
4 files changed, 9 insertions(+), 23 deletions(-)
- Log -----------------------------------------------------------------
commit 697d95ab86fb7086cc168aa98b3276a59b800f64
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Feb 10 15:28:31 2011 -0500
We now get old_value in after_set callbacks
diff --git a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
index d01622e..2860e00 100644
--- a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
+++ b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
@@ -28,8 +28,9 @@ sub import {
$caller->add_trigger(after_set => sub {
my $self = shift;
my %args = (
- column => undef,
- value => undef,
+ column => undef,
+ value => undef,
+ old_value => undef,
%{ shift @_ },
);
@@ -46,6 +47,7 @@ sub import {
# TODO: capture old_value somehow
$change->add_change_field(
field => $args{column},
+ old_value => $args{old_value},
new_value => $args{value},
);
});
diff --git a/t/TestApp-Plugin-RecordHistory/t/001-basic.t b/t/TestApp-Plugin-RecordHistory/t/001-basic.t
index e689914..86344e5 100644
--- a/t/TestApp-Plugin-RecordHistory/t/001-basic.t
+++ b/t/TestApp-Plugin-RecordHistory/t/001-basic.t
@@ -34,11 +34,7 @@ my $change_field = $change->change_fields->first;
is($change_field->change->id, $change->id, 'associated with the right change');
is($change_field->field, 'title');
is($change_field->new_value, 'Nineteen Eighty-Four');
-
-TODO: {
- local $TODO = "the callback doesn't expose old_value yet";
- is($change_field->old_value, '1984');
-}
+is($change_field->old_value, '1984');
$book->delete;
diff --git a/t/TestApp-Plugin-RecordHistory/t/003-action.t b/t/TestApp-Plugin-RecordHistory/t/003-action.t
index d77bb8a..fa27875 100644
--- a/t/TestApp-Plugin-RecordHistory/t/003-action.t
+++ b/t/TestApp-Plugin-RecordHistory/t/003-action.t
@@ -35,16 +35,10 @@ is($change->change_fields->count, 2, 'two fields updated');
my @change_fields = sort { $a->field cmp $b->field } @{ $change->change_fields->items_array_ref };
is($change_fields[0]->field, 'author', 'first update is to author');
-TODO: {
- local $TODO = "we don't get old_value in the callback yet";
- is($change_fields[0]->old_value, 'George Orwell', 'old value of author is George');
-}
+is($change_fields[0]->old_value, 'George Orwell', 'old value of author is George');
is($change_fields[0]->new_value, 'Aldous Huxley', 'new value of author is Aldous');
is($change_fields[1]->field, 'title', 'second update is to title');
-TODO: {
- local $TODO = "we don't get old_value in the callback yet";
- is($change_fields[1]->old_value, '1984', 'old value of author is 1984');
-}
+is($change_fields[1]->old_value, '1984', 'old value of author is 1984');
is($change_fields[1]->new_value, 'Brave New World', 'new value of author is BNW');
diff --git a/t/TestApp-Plugin-RecordHistory/t/004-manual.t b/t/TestApp-Plugin-RecordHistory/t/004-manual.t
index 89526f9..56d2f06 100644
--- a/t/TestApp-Plugin-RecordHistory/t/004-manual.t
+++ b/t/TestApp-Plugin-RecordHistory/t/004-manual.t
@@ -28,16 +28,10 @@ is($change->change_fields->count, 2, 'two fields updated');
my @change_fields = sort { $a->field cmp $b->field } @{ $change->change_fields->items_array_ref };
is($change_fields[0]->field, 'author', 'first update is to author');
-TODO: {
- local $TODO = "we don't get old_value in the callback yet";
- is($change_fields[0]->old_value, 'George Orwell', 'old value of author is George');
-}
+is($change_fields[0]->old_value, 'George Orwell', 'old value of author is George');
is($change_fields[0]->new_value, 'Aldous Huxley', 'new value of author is Aldous');
is($change_fields[1]->field, 'title', 'second update is to title');
-TODO: {
- local $TODO = "we don't get old_value in the callback yet";
- is($change_fields[1]->old_value, '1984', 'old value of author is 1984');
-}
+is($change_fields[1]->old_value, '1984', 'old value of author is 1984');
is($change_fields[1]->new_value, 'Brave New World', 'new value of author is BNW');
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list