[Jifty-commit] r4076 - in jifty/trunk: lib/Jifty t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Sep 11 13:05:18 EDT 2007
Author: sterling
Date: Tue Sep 11 13:05:17 2007
New Revision: 4076
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Collection.pm
jifty/trunk/lib/Jifty/Record.pm
jifty/trunk/t/TestApp/t/00-model-User.t
Log:
r11937 at dynpc145: andrew | 2007-09-11 12:04:53 -0500
Making the as_*_action() methods accept a paramhash for additional new_action() parameters.
Modified: jifty/trunk/lib/Jifty/Collection.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Collection.pm (original)
+++ jifty/trunk/lib/Jifty/Collection.pm Tue Sep 11 13:05:17 2007
@@ -53,15 +53,17 @@
__PACKAGE__->mk_accessors(qw(pager results_are_readable));
-=head2 as_search_action
+=head2 as_search_action PARAMHASH
Returns the L<Jifty::Action::Record::Search> action for the model associated with this collection.
+The PARAMHASH allows you to add additional parameters to pass to L<Jifty::Web/new_action>.
+
=cut
sub as_search_action {
my $self = shift;
- return $self->record_class->as_search_action;
+ return $self->record_class->as_search_action(@_);
}
=head2 add_record
Modified: jifty/trunk/lib/Jifty/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Record.pm Tue Sep 11 13:05:17 2007
@@ -153,10 +153,12 @@
}
-=head2 as_create_action
+=head2 as_create_action PARAMHASH
Returns the L<Jifty::Action::Record::Create> action for this model class.
+The PARAMHASH allows you to add additional parameters to pass to L<Jifty::Web/new_action>.
+
=cut
sub _action_from_record {
@@ -170,13 +172,15 @@
sub as_create_action {
my $self = shift;
my $action_class = $self->_action_from_record('Create');
- return Jifty->web->new_action( class => $action_class );
+ return Jifty->web->new_action( class => $action_class, @_ );
}
-=head2 as_update_action
+=head2 as_update_action PARAMHASH
Returns the L<Jifty::Action::Record::Update> action for this model class. The current record is passed to the constructor.
+The PARAMHASH allows you to add additional parameters to pass to L<Jifty::Web/new_action>.
+
=cut
sub as_update_action {
@@ -185,13 +189,16 @@
return Jifty->web->new_action(
class => $action_class,
record => $self,
+ @_,
);
}
-=head2 as_delete_action
+=head2 as_delete_action PARAMHASH
Returns the L<Jifty::Action::Record::Delete> action for this model class. The current record is passed to the constructor.
+The PARAMHASH allows you to add additional parameters to pass to L<Jifty::Web/new_action>.
+
=cut
sub as_delete_action {
@@ -200,13 +207,16 @@
return Jifty->web->new_action(
class => $action_class,
record => $self,
+ @_,
);
}
-=head2 as_search_action
+=head2 as_search_action PARAMHASH
Returns the L<Jifty::Action::Record::Search> action for this model class.
+The PARAMHASH allows you to add additional parameters to pass to L<Jifty::Web/new_action>.
+
=cut
sub as_search_action {
@@ -214,6 +224,7 @@
my $action_class = $self->_action_from_record('Search');
return Jifty->web->new_action(
class => $action_class,
+ @_,
);
}
Modified: jifty/trunk/t/TestApp/t/00-model-User.t
==============================================================================
--- jifty/trunk/t/TestApp/t/00-model-User.t (original)
+++ jifty/trunk/t/TestApp/t/00-model-User.t Tue Sep 11 13:05:17 2007
@@ -11,7 +11,7 @@
use lib 't/lib';
use Jifty::SubTest;
-use Jifty::Test tests => 19;
+use Jifty::Test tests => 24;
Jifty::Test->web; # initialize for use with the as_*_action tests
# Make sure we can load the model
use_ok('TestApp::Model::User');
@@ -29,16 +29,20 @@
is($o->name, $$, "Created object has the right name");
# Test the as_foo_action methods
-my $action = $o->as_create_action;
+my $action = $o->as_create_action( moniker => 'test1' );
isa_ok($action, 'TestApp::Action::CreateUser');
-$action = $o->as_update_action;
+is($action->moniker, 'test1', 'create action moniker is test1');
+$action = $o->as_update_action( moniker => 'test2' );
isa_ok($action, 'TestApp::Action::UpdateUser');
is($action->record->id, $o->id, 'update action ID is correct');
-$action = $o->as_delete_action;
+is($action->moniker, 'test2', 'update action moniker is test2');
+$action = $o->as_delete_action( moniker => 'test3' );
isa_ok($action, 'TestApp::Action::DeleteUser');
is($action->record->id, $o->id, 'delete action ID is correct');
-$action = $o->as_search_action;
+is($action->moniker, 'test3', 'delete action moniker is test3');
+$action = $o->as_search_action( moniker => 'test4' );
isa_ok($action, 'TestApp::Action::SearchUser');
+is($action->moniker, 'test4', 'search action moniker is test4');
# And another
$o->create( name => $$, email => $$, password => $$ );
@@ -51,8 +55,9 @@
is($collection->count, 2, "Finds two records");
# Check the as_search_action method
-$action = $collection->as_search_action;
+$action = $collection->as_search_action( moniker => 'test5' );
isa_ok($action, 'TestApp::Action::SearchUser');
+is($action->moniker, 'test5', 'search action moniker is test5');
# Searches in specific
$collection->limit(column => 'id', value => $o->id);
More information about the Jifty-commit
mailing list