[Jifty-commit] r2893 - in jifty/branches/template-declare: . t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Mar 3 12:56:26 EST 2007


Author: jesse
Date: Sat Mar  3 12:56:26 2007
New Revision: 2893

Added:
   jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FasterSwallow.pm
   jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FavoriteColor.pm
Modified:
   jifty/branches/template-declare/   (props changed)
   jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t

Log:
 r52946 at pinglin:  jesse | 2007-03-03 12:31:51 +0000
  * now we have working validators


Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FasterSwallow.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FasterSwallow.pm	Sat Mar  3 12:56:26 2007
@@ -0,0 +1,25 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::FasterSwallow;
+use base 'Jifty::DBI::Record::Plugin';
+use Jifty::DBI::Schema;
+use Jifty::DBI::Record schema {
+        column swallow_type => valid are qw(african european), default is 'african';
+    };
+
+
+sub register_triggers {
+    my $self = shift;
+    warn "Adding a trigger for $self";
+    $self->add_trigger(name => 'before_create', callback => \&before_create, abortable => 1);
+}
+
+sub before_create {
+    my $self = shift;
+    my $args = shift;
+    return undef unless ($args->{'swallow_type'} eq 'african');
+    return 1;
+}
+
+1;

Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FavoriteColor.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/FavoriteColor.pm	Sat Mar  3 12:56:26 2007
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::FavoriteColor;
+use base 'Jifty::DBI::Record::Plugin';
+use Jifty::DBI::Schema;
+use Jifty::DBI::Record schema {
+        column color => type is 'text', default is 'Blue';
+    };
+
+
+
+sub register_triggers {
+    my $self = shift;
+    $self->add_trigger(name => 'before_create', callback => \&before_create, abortable => 1);
+}
+
+
+
+sub before_create {
+    my $self = shift;
+    my $args = shift;
+    return undef unless ($args->{'color'} eq 'yellow');
+    return 1;
+}
+
+
+
+1;

Modified: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t
==============================================================================
--- jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t	(original)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t	Sat Mar  3 12:56:26 2007
@@ -10,7 +10,7 @@
 use lib 't/lib';
 use Jifty::SubTest;
 
-use Jifty::Test tests => 10;
+use Jifty::Test tests => 14;
 
 # Make sure we can load the model
 use_ok('TestApp::Plugin::PasswordAuth::Model::User');
@@ -46,7 +46,7 @@
                        color => 'blue',
                        swallow_type => 'african',
                        password => 'secret');
-ok(!$p, "Users can't be created with the wrong favorite color");
+ok(!$id, "Users can't be created with the wrong favorite color");
 
 my $q = TestApp::Plugin::PasswordAuth::Model::User->new(current_user => $system_user);
 ($id) = $p->create( name => 'jesse2',
@@ -54,4 +54,4 @@
                        color => 'yellow',
                        swallow_type => 'european',
                        password => 'secret');
-ok(!$q, "Users can't be created if they don't know african swallow_types are faster");
+ok(!$id, "Users can't be created if they don't know african swallow_types are faster");


More information about the Jifty-commit mailing list