[Jifty-commit] r5782 - in JiftyX-ModelHelpers/trunk: . t t/Simapp t/Simapp/bin t/Simapp/doc t/Simapp/etc t/Simapp/lib t/Simapp/lib/Simapp t/Simapp/lib/Simapp/Action t/Simapp/lib/Simapp/Model t/Simapp/log t/Simapp/share t/Simapp/share/po t/Simapp/share/web/static t/Simapp/share/web/templates t/Simapp/t t/Simapp/var

Jifty commits jifty-commit at lists.jifty.org
Tue Sep 2 11:37:03 EDT 2008


Author: gugod
Date: Tue Sep  2 11:37:02 2008
New Revision: 5782

Added:
   JiftyX-ModelHelpers/trunk/t/
   JiftyX-ModelHelpers/trunk/t/Simapp/
   JiftyX-ModelHelpers/trunk/t/Simapp/Makefile.PL
   JiftyX-ModelHelpers/trunk/t/Simapp/bin/
   JiftyX-ModelHelpers/trunk/t/Simapp/bin/jifty   (contents, props changed)
   JiftyX-ModelHelpers/trunk/t/Simapp/doc/
   JiftyX-ModelHelpers/trunk/t/Simapp/etc/
   JiftyX-ModelHelpers/trunk/t/Simapp/etc/config.yml
   JiftyX-ModelHelpers/trunk/t/Simapp/lib/
   JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/
   JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/Action/
   JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/Model/
   JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/Model/Book.pm
   JiftyX-ModelHelpers/trunk/t/Simapp/log/
   JiftyX-ModelHelpers/trunk/t/Simapp/share/
   JiftyX-ModelHelpers/trunk/t/Simapp/share/po/
   JiftyX-ModelHelpers/trunk/t/Simapp/share/web/
   JiftyX-ModelHelpers/trunk/t/Simapp/share/web/static/
   JiftyX-ModelHelpers/trunk/t/Simapp/share/web/templates/
   JiftyX-ModelHelpers/trunk/t/Simapp/t/
   JiftyX-ModelHelpers/trunk/t/Simapp/t/00-model-Book.t
   JiftyX-ModelHelpers/trunk/t/Simapp/t/helpers.t
   JiftyX-ModelHelpers/trunk/t/Simapp/var/
Modified:
   JiftyX-ModelHelpers/trunk/   (props changed)

Log:
 r23660 at yra:  gugod | 2008-09-02 23:35:54 +0800
 Add a simple app to test model helpers.
 
 The real test file is Simapp/t/helpers.t
 


Added: JiftyX-ModelHelpers/trunk/t/Simapp/Makefile.PL
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/Makefile.PL	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name        'Simapp';
+version     '0.01';
+requires    'Jifty' => '0.80408';
+
+WriteAll;

Added: JiftyX-ModelHelpers/trunk/t/Simapp/bin/jifty
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/bin/jifty	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,10 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use UNIVERSAL::require;
+
+use Jifty;
+use Jifty::Script;
+
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();

Added: JiftyX-ModelHelpers/trunk/t/Simapp/etc/config.yml
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/etc/config.yml	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,74 @@
+--- 
+framework: 
+  AdminMode: 1
+  ApplicationClass: Simapp
+  ApplicationName: Simapp
+  ApplicationUUID: 62E656F2-7901-11DD-926E-C08783FE53EB
+  ConfigFileVersion: 4
+  Database: 
+    AutoUpgrade: 1
+    CheckSchema: 1
+    Database: simapp
+    Driver: SQLite
+    Host: localhost
+    Password: ''
+    RecordBaseClass: Jifty::DBI::Record::Cachable
+    User: ''
+    Version: 0.0.1
+  DevelMode: 1
+  L10N: 
+    PoDir: share/po
+  LogLevel: INFO
+  Mailer: Sendmail
+  MailerArgs: []
+
+  Plugins: 
+    - 
+      LetMe: {}
+
+    - 
+      SkeletonApp: {}
+
+    - 
+      REST: {}
+
+    - 
+      Halo: {}
+
+    - 
+      ErrorTemplates: {}
+
+    - 
+      OnlineDocs: {}
+
+    - 
+      CompressedCSSandJS: {}
+
+    - 
+      AdminUI: {}
+
+  PubSub: 
+    Backend: Memcached
+    Enable: ~
+  SkipAccessControl: 0
+  TemplateClass: Simapp::View
+  View: 
+    FallbackHandler: Jifty::View::Mason::Handler
+    Handlers: 
+      - Jifty::View::Static::Handler
+      - Jifty::View::Declare::Handler
+      - Jifty::View::Mason::Handler
+  Web: 
+    BaseURL: http://localhost
+    DataDir: var/mason
+    Globals: []
+
+    MasonConfig: 
+      autoflush: 0
+      default_escape_flags: h
+      error_format: text
+      error_mode: fatal
+    Port: 8888
+    ServeStaticFiles: 1
+    StaticRoot: share/web/static
+    TemplateRoot: share/web/templates

Added: JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/Model/Book.pm
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/lib/Simapp/Model/Book.pm	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+
+package Simapp::Model::Book;
+use Jifty::DBI::Schema;
+
+use Simapp::Record schema {
+    column name => type is 'varchar(255)';
+};
+
+# Your model-specific methods go here.
+
+1;
+

Added: JiftyX-ModelHelpers/trunk/t/Simapp/t/00-model-Book.t
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/t/00-model-Book.t	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Book model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('Simapp::Model::Book');
+
+# Grab a system user
+my $system_user = Simapp::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = Simapp::Model::Book->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Book create returned success");
+ok($o->id, "New Book has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Book create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection =  Simapp::Model::BookCollection->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");
+

Added: JiftyX-ModelHelpers/trunk/t/Simapp/t/helpers.t
==============================================================================
--- (empty file)
+++ JiftyX-ModelHelpers/trunk/t/Simapp/t/helpers.t	Tue Sep  2 11:37:02 2008
@@ -0,0 +1,27 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use Jifty::Test::Dist tests => 3;
+use JiftyX::ModelHelpers;
+
+{
+    use Simapp::Model::Book;
+    my $b = Book;
+    is( ref($b), "Simapp::Model::Book" );
+}
+
+my $good_book_id;
+{
+    my $b1 = Jifty->app_class(Model => "Book")->new;
+    $good_book_id = $b1->create( name => "Good Book A");
+
+    my $b2 = Book(name => "Good Book A");
+    is( $b2->id, $b1->id );
+}
+
+{
+    my $b = Book($good_book_id);
+    is( $b->name, "Good Book A" );
+}
+


More information about the Jifty-commit mailing list