[Jifty-commit] r5799 - in jifty/trunk: . t/TestApp-Collection-Select t/TestApp-Collection-Select/bin t/TestApp-Collection-Select/etc t/TestApp-Collection-Select/lib/TestApp t/TestApp-Collection-Select/lib/TestApp/Action t/TestApp-Collection-Select/lib/TestApp/Model t/TestApp-Collection-Select/t

Jifty commits jifty-commit at lists.jifty.org
Sat Sep 6 06:06:35 EDT 2008


Author: sartak
Date: Sat Sep  6 06:06:33 2008
New Revision: 5799

Added:
   jifty/trunk/t/TestApp-Collection-Select/
   jifty/trunk/t/TestApp-Collection-Select/Makefile.PL
   jifty/trunk/t/TestApp-Collection-Select/bin/
   jifty/trunk/t/TestApp-Collection-Select/bin/jifty   (contents, props changed)
   jifty/trunk/t/TestApp-Collection-Select/etc/
   jifty/trunk/t/TestApp-Collection-Select/etc/config.yml
   jifty/trunk/t/TestApp-Collection-Select/lib/
   jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/
   jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Action/
   jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/
   jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Author.pm
   jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Book.pm
   jifty/trunk/t/TestApp-Collection-Select/t/
   jifty/trunk/t/TestApp-Collection-Select/t/collection-select.t
Modified:
   jifty/trunk/   (props changed)

Log:
 r71114 at onn:  sartak | 2008-09-06 06:01:03 -0400
 Add test app from Peter Mottram to uncover this valid_values bug


Added: jifty/trunk/t/TestApp-Collection-Select/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/Makefile.PL	Sat Sep  6 06:06:33 2008
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name        'TestApp';
+version     '0.01';
+requires    'Jifty' => '0.80408';
+
+WriteAll;

Added: jifty/trunk/t/TestApp-Collection-Select/bin/jifty
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/bin/jifty	Sat Sep  6 06:06:33 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: jifty/trunk/t/TestApp-Collection-Select/etc/config.yml
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/etc/config.yml	Sat Sep  6 06:06:33 2008
@@ -0,0 +1,74 @@
+--- 
+framework: 
+  AdminMode: 1
+  ApplicationClass: TestApp
+  ApplicationName: TestApp
+  ApplicationUUID: bf3d4130-6211-4acd-8496-3189acdc856b
+  ConfigFileVersion: 4
+  Database: 
+    AutoUpgrade: 1
+    CheckSchema: 1
+    Database: testapp
+    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: TestApp::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: jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Author.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Author.pm	Sat Sep  6 06:06:33 2008
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+package TestApp::Model::Author;
+use Jifty::DBI::Schema;
+
+use TestApp::Record schema {
+    column name =>
+        type is 'text';
+};
+
+# Your model-specific methods go here.
+
+1;
+

Added: jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Book.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/lib/TestApp/Model/Book.pm	Sat Sep  6 06:06:33 2008
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+package TestApp::Model::Book;
+use Jifty::DBI::Schema;
+
+use TestApp::Record schema {
+    column title =>
+        type is 'text';
+    column author =>
+        refers_to TestApp::Model::AuthorCollection by 'name',
+        render_as 'Select',
+        valid_values are defer {
+            my $authors = TestApp::Model::AuthorCollection->new();
+            $authors->unlimit;
+            $authors->order_by( column => 'name' );
+            [{
+                display_from => 'name',
+                value_from   => 'id',
+                collection   => $authors,
+            }];
+        };
+};
+
+# Your model-specific methods go here.
+
+1;
+

Added: jifty/trunk/t/TestApp-Collection-Select/t/collection-select.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Collection-Select/t/collection-select.t	Sat Sep  6 06:06:33 2008
@@ -0,0 +1,48 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+use Jifty::Test::Dist tests => 15;
+use Jifty::Test::WWW::Mechanize;
+
+# Make sure we can load the models
+use_ok('TestApp::Model::Author');
+use_ok('TestApp::Model::Book');
+
+# Grab a system user
+my $system_user = TestApp::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Create an author
+my $o = TestApp::Model::Author->new(current_user => $system_user);
+my ($id) = $o->create( name => 'Author One' );
+ok($id, "Author create returned success");
+ok($o->id, "New Author has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create( name => 'Author Two' );
+ok($o->id, "Author create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Check we really have 2 author records created
+my $collection =  TestApp::Model::AuthorCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# start a server
+my $server = Jifty::Test->make_server;
+ok($server, 'got a server');
+
+my $url = $server->started_ok;
+
+my $mech = Jifty::Test::WWW::Mechanize->new;
+
+$mech->get_ok($url . '/__jifty/admin/model/Book', 'try getting /__jifty/admin/model/Book');
+
+my $mon = $mech->moniker_for('TestApp::Action::CreateBook');
+ok($mon, 'grab the form moniker');
+
+ok($mech->action_field_value($mon, 'author'), 'check for author field');
+
+ok($mech->select("J:A:F-author-$mon", $id), 'select 1st author');


More information about the Jifty-commit mailing list