[Jifty-commit] r6218 - in jifty/trunk: . t/TestApp-Plugin-ActorMetadata t/TestApp-Plugin-ActorMetadata/bin t/TestApp-Plugin-ActorMetadata/etc t/TestApp-Plugin-ActorMetadata/lib t/TestApp-Plugin-ActorMetadata/lib/TestApp t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model
Jifty commits
jifty-commit at lists.jifty.org
Fri Jan 9 04:51:33 EST 2009
Author: sunnavy
Date: Fri Jan 9 04:51:33 2009
New Revision: 6218
Added:
jifty/trunk/t/TestApp-Plugin-ActorMetadata/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/Makefile.PL
jifty/trunk/t/TestApp-Plugin-ActorMetadata/bin/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/bin/jifty (contents, props changed)
jifty/trunk/t/TestApp-Plugin-ActorMetadata/etc/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/etc/config.yml
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/Post.pm
jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/User.pm
jifty/trunk/t/TestApp-Plugin-ActorMetadata/t/
jifty/trunk/t/TestApp-Plugin-ActorMetadata/t/actormetadata.t
Modified:
jifty/trunk/ (props changed)
Log:
r6232 at sunnavys-mb: sunnavy | 2009-01-09 17:51:14 +0800
added TestApp-Plugin-ActorMetadata
Added: jifty/trunk/t/TestApp-Plugin-ActorMetadata/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/Makefile.PL Fri Jan 9 04:51:33 2009
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name 'TestApp::Plugin::ActorMetadata';
+version '0.01';
+requires 'Jifty' => '0.81208';
+
+WriteAll;
Added: jifty/trunk/t/TestApp-Plugin-ActorMetadata/bin/jifty
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/bin/jifty Fri Jan 9 04:51:33 2009
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use UNIVERSAL::require;
+
+BEGIN {
+ Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+ my $root = Jifty::Util->app_root;
+ unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty;
+use Jifty::Script;
+
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: jifty/trunk/t/TestApp-Plugin-ActorMetadata/etc/config.yml
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/etc/config.yml Fri Jan 9 04:51:33 2009
@@ -0,0 +1,76 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: TestApp::Plugin::ActorMetadata
+ ApplicationName: TestApp::Plugin::ActorMetadata
+ ApplicationUUID: C4418A2E-DE0B-11DD-96DC-F9E9C3E98ACD
+ ConfigFileVersion: 4
+ Database:
+ AutoUpgrade: 1
+ CheckSchema: 1
+ Database: testapp_plugin_actormetadata
+ 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:
+ - User: {}
+ - Authentication::Password: {}
+ -
+ LetMe: {}
+
+ -
+ SkeletonApp: {}
+
+ -
+ REST: {}
+
+ -
+ Halo: {}
+
+ -
+ ErrorTemplates: {}
+
+ -
+ OnlineDocs: {}
+
+ -
+ CompressedCSSandJS: {}
+
+ -
+ AdminUI: {}
+
+ PubSub:
+ Backend: Memcached
+ Enable: ~
+ SkipAccessControl: 0
+ TemplateClass: TestApp::Plugin::ActorMetadata::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: 1
+ 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-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/Post.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/Post.pm Fri Jan 9 04:51:33 2009
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::ActorMetadata::Model::Post;
+use Jifty::DBI::Schema;
+
+use TestApp::Plugin::ActorMetadata::Record schema {
+ column
+ title => type is 'text',
+ label is 'Title',
+ default is 'Untitled post';
+};
+
+use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata;
+
+# Your model-specific methods go here.
+
+1;
+
Added: jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/lib/TestApp/Plugin/ActorMetadata/Model/User.pm Fri Jan 9 04:51:33 2009
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::ActorMetadata::Model::User;
+use Jifty::DBI::Schema;
+
+use TestApp::Plugin::ActorMetadata::Record schema {
+
+};
+
+use Jifty::Plugin::User::Mixin::Model::User;
+use Jifty::Plugin::Authentication::Password::Mixin::Model::User;
+# Your model-specific methods go here.
+
+1;
+
Added: jifty/trunk/t/TestApp-Plugin-ActorMetadata/t/actormetadata.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp-Plugin-ActorMetadata/t/actormetadata.t Fri Jan 9 04:51:33 2009
@@ -0,0 +1,56 @@
+use strict;
+use warnings;
+
+use Test::More tests => 17;
+use Jifty::Test;
+my ( $user_foo, $user_bar );
+
+$user_foo = TestApp::Plugin::ActorMetadata::Model::User->new;
+$user_foo->create( name => 'foo', email => 'foo at example.com' );
+ok( $user_foo->id, 'created user foo' );
+
+$user_bar = TestApp::Plugin::ActorMetadata::Model::User->new;
+$user_bar->create( name => 'bar', email => 'bar at example.com' );
+ok( $user_bar->id, 'created user bar' );
+
+# create a post with current user foo
+my $post =
+ TestApp::Plugin::ActorMetadata::Model::Post->new( current_user => $user_foo );
+$post->create( title => 'foo' );
+ok( $post->id, 'created a post' );
+is( $post->created_by->id, $user_foo->id, 'created_by is set' );
+
+# XXX TODO update_by can't be refers to user :/
+# see Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata
+is( $post->updated_by, $user_foo->id, 'updated_by is set' );
+
+my $now = Jifty::DateTime->now;
+my $created_on = $post->created_on;
+ok( abs( $created_on->epoch - $now->epoch < 2 ), 'created_on is set' );
+ok( abs( $post->updated_on->epoch - $now->epoch < 2 ), 'created_on is set' );
+
+sleep 3; # just let time pass
+
+# update by foo
+$post->set_title( 'foo 2' );
+is( $post->title, 'foo 2', 'updated title' );
+is( $post->created_by->id, $user_foo->id, 'created_by is not updated' );
+is( $post->created_on->epoch, $created_on->epoch, 'created_on is not updated' );
+
+is( $post->updated_by, $user_foo->id, 'updated_by is not updated' );
+
+ok( abs( $post->updated_on->epoch - Jifty::DateTime->now->epoch < 2 ),
+ 'update_on is updated correctly' );
+
+sleep 3;
+# update by bar
+$post->current_user($user_bar);
+
+$post->set_title( 'bar' );
+is( $post->title, 'bar', 'updated title' );
+is( $post->created_by->id, $user_foo->id, 'created_by is not updated' );
+is( $post->created_on->epoch, $created_on->epoch, 'created_on is not updated' );
+
+is( $post->updated_by, $user_bar->id, 'updated_by is not updated' );
+ok( abs( $post->updated_on->epoch - Jifty::DateTime->now->epoch < 2 ),
+ 'update_on is updated' );
More information about the Jifty-commit
mailing list