[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 562ac4d021440224b1382a59ba819670d012dd4c
Shawn Moore
sartak at bestpractical.com
Wed Feb 9 21:09:42 EST 2011
The branch, master has been updated
via 562ac4d021440224b1382a59ba819670d012dd4c (commit)
via 3f94a9a5e55a053ea693e00458d25412e575d177 (commit)
from 1853ed3ea733da657bbe01fae58f9937cbf76b95 (commit)
Summary of changes:
.../lib/TestApp/Plugin/RecordHistory/Model/Book.pm | 2 +
t/TestApp-Plugin-RecordHistory/t/003-action.t | 34 ++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
create mode 100644 t/TestApp-Plugin-RecordHistory/t/003-action.t
- Log -----------------------------------------------------------------
commit 3f94a9a5e55a053ea693e00458d25412e575d177
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Feb 9 21:09:17 2011 -0500
Give books an author so we can test updating multiple fields
diff --git a/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Book.pm b/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Book.pm
index bdbe98c..d1cbb89 100644
--- a/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Book.pm
+++ b/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Book.pm
@@ -7,6 +7,8 @@ use Jifty::DBI::Schema;
use TestApp::Plugin::RecordHistory::Record schema {
column title =>
type is 'varchar';
+ column author =>
+ type is 'varchar';
};
use Jifty::Plugin::RecordHistory::Mixin::Model::RecordHistory;
commit 562ac4d021440224b1382a59ba819670d012dd4c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Feb 9 21:09:30 2011 -0500
Begin adding tests for updating multiple fields in one go
diff --git a/t/TestApp-Plugin-RecordHistory/t/003-action.t b/t/TestApp-Plugin-RecordHistory/t/003-action.t
new file mode 100644
index 0000000..ec3805c
--- /dev/null
+++ b/t/TestApp-Plugin-RecordHistory/t/003-action.t
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use Jifty::Test::Dist tests => 7;
+
+my $book = TestApp::Plugin::RecordHistory::Model::Book->new;
+$book->create(
+ title => '1984',
+);
+ok($book->id, 'created a book');
+
+Jifty->web->request(Jifty::Request->new);
+Jifty->web->response(Jifty::Response->new);
+
+my $action = TestApp::Plugin::RecordHistory::Action::UpdateBook->new(
+ record => $book,
+ arguments => {
+ title => 'Brave New World',
+ author => 'Aldous Huxley',
+ },
+);
+
+$action->run;
+
+ok($action->result->success);
+
+isa_ok($book->changes, 'Jifty::Plugin::RecordHistory::Model::ChangeCollection');
+is($book->changes->count, 2, 'two changes');
+is($book->changes->first->type, 'create', 'first change is the create');
+my $change = $book->changes->last;
+is($change->type, 'update', 'second change is the update');
+is($change->change_fields->count, 2, 'two fields updated');
+
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list