[Bps-public-commit] App-Changeloggr branch, master, updated. 8d0424da1429f800800d0a48c0de3c17ec2d377d

sartak at bestpractical.com sartak at bestpractical.com
Wed Apr 29 16:03:05 EDT 2009


The branch, master has been updated
       via  8d0424da1429f800800d0a48c0de3c17ec2d377d (commit)
      from  e686eb98434f70690c0cbd7fb6b1dd1634211582 (commit)

Summary of changes:
 etc/config.yml                         |    2 +-
 lib/App/Changeloggr/Model/User.pm      |   21 +++++++++++++++++++++
 t/{00-model-Vote.t => 00-model-User.t} |   14 +++++++-------
 3 files changed, 29 insertions(+), 8 deletions(-)
 create mode 100644 lib/App/Changeloggr/Model/User.pm
 copy t/{00-model-Vote.t => 00-model-User.t} (73%)

- Log -----------------------------------------------------------------
commit 8d0424da1429f800800d0a48c0de3c17ec2d377d
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Apr 29 16:02:49 2009 -0400

    Begin adding a user model

diff --git a/etc/config.yml b/etc/config.yml
index 6993c35..a0ee90f 100644
--- a/etc/config.yml
+++ b/etc/config.yml
@@ -14,7 +14,7 @@ framework:
     Password: ''
     RecordBaseClass: Jifty::DBI::Record::Cachable
     User: ''
-    Version: 0.0.3
+    Version: 0.0.4
   DevelMode: 1
   L10N: 
     PoDir: share/po
diff --git a/lib/App/Changeloggr/Model/User.pm b/lib/App/Changeloggr/Model/User.pm
new file mode 100644
index 0000000..264d5eb
--- /dev/null
+++ b/lib/App/Changeloggr/Model/User.pm
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+package App::Changeloggr::Model::User;
+use Jifty::DBI::Schema;
+
+use App::Changeloggr::Record schema {
+    column name =>
+        type is 'text',
+        label is 'Name';
+
+    column session_id =>
+        type is 'text',
+        render as 'hidden',
+        is immutable;
+};
+
+sub since { '0.0.4' }
+
+1;
+
diff --git a/t/00-model-User.t b/t/00-model-User.t
new file mode 100644
index 0000000..dba10d3
--- /dev/null
+++ b/t/00-model-User.t
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the User model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('App::Changeloggr::Model::User');
+
+# Grab a system user
+my $system_user = App::Changeloggr::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = App::Changeloggr::Model::User->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "User create returned success");
+ok($o->id, "New User has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "User create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection =  App::Changeloggr::Model::UserCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+

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



More information about the Bps-public-commit mailing list