[Catalyst-commits] r8838 - in
CatalystX-CRUD/CatalystX-CRUD/trunk/t: . lib/MyApp/Controller
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Fri Dec 12 04:58:09 GMT 2008
Author: karpet
Date: 2008-12-12 04:58:09 +0000 (Fri, 12 Dec 2008)
New Revision: 8838
Added:
CatalystX-CRUD/CatalystX-CRUD/trunk/t/lib/MyApp/Controller/FetchRewrite.pm
Modified:
CatalystX-CRUD/CatalystX-CRUD/trunk/t/01-file.t
Log:
test PathPrefix override
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/t/01-file.t
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/t/01-file.t 2008-12-12 04:57:21 UTC (rev 8837)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/t/01-file.t 2008-12-12 04:58:09 UTC (rev 8838)
@@ -1,4 +1,4 @@
-use Test::More tests => 35;
+use Test::More tests => 40;
use strict;
use lib qw( lib t/lib );
use_ok('CatalystX::CRUD::Model::File');
@@ -63,7 +63,10 @@
# create related file
ok( $res = request(
- POST( '/file/otherdir%2ftestfile2/save', [ content => 'hello world 2' ] )
+ POST(
+ '/file/otherdir%2ftestfile2/save',
+ [ content => 'hello world 2' ]
+ )
),
"POST new file2"
);
@@ -76,8 +79,11 @@
is( $res->headers->{status}, 302, "new file 302 redirect status" );
# create relationship
-ok( $res = request( POST( '/file/testfile/dir/otherdir%2ftestfile2/add', [] ) ),
- "add related dir/otherdir%2ftestfile2" );
+ok( $res
+ = request(
+ POST( '/file/testfile/dir/otherdir%2ftestfile2/add', [] ) ),
+ "add related dir/otherdir%2ftestfile2"
+);
#dump $res;
@@ -85,8 +91,11 @@
# remove the relationship
-ok( $res = request( POST( '/file/testfile/dir/otherdir%2ftestfile2/remove', [] ) ),
- "remove related dir/testfile2" );
+ok( $res = request(
+ POST( '/file/testfile/dir/otherdir%2ftestfile2/remove', [] )
+ ),
+ "remove related dir/testfile2"
+);
is( $res->headers->{status}, 204, "relationship removed with status 204" );
@@ -161,3 +170,36 @@
like( $res->content, qr/content => undef/, "file nuked adapter" );
+# test the fetch() rewrite
+
+# create a new file
+ok( $res = request(
+ POST(
+ '/fetchrewrite/id/testfile/save', [ content => 'hello world' ]
+ )
+ ),
+ "POST new file adapter"
+);
+
+is( $res->content,
+ '{ content => "hello world", file => "testfile" }',
+ "POST new file response adapter"
+);
+
+ok( $res = request(
+ HTTP::Request->new( GET => '/fetchrewrite/id/testfile/view' )
+ ),
+ "fetch rewrite works"
+);
+
+# delete the file
+
+ok( $res = request( POST( '/fetchrewrite/id/testfile/rm', [] ) ),
+ "rm fetch rewrite" );
+
+# confirm it is gone
+ok( $res = request(
+ HTTP::Request->new( GET => '/fetchrewrite/id/testfile/view' )
+ ),
+ "confirm we nuked the fetch rewrite file"
+);
Added: CatalystX-CRUD/CatalystX-CRUD/trunk/t/lib/MyApp/Controller/FetchRewrite.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/t/lib/MyApp/Controller/FetchRewrite.pm (rev 0)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/t/lib/MyApp/Controller/FetchRewrite.pm 2008-12-12 04:58:09 UTC (rev 8838)
@@ -0,0 +1,26 @@
+package MyApp::Controller::FetchRewrite;
+use strict;
+use base qw( CatalystX::CRUD::Test::Controller );
+use Carp;
+use Data::Dump qw( dump );
+use File::Temp;
+use MyApp::Form;
+
+__PACKAGE__->config(
+ primary_key => 'absolute',
+ form_class => 'MyApp::Form',
+ form_fields => [qw( file content )],
+ model_adapter => 'CatalystX::CRUD::ModelAdapter::File',
+ model_name => 'File',
+ primary_key => 'file',
+ init_form => 'init_with_file',
+ init_object => 'file_from_form',
+);
+
+# append the namespace qualifier for objects
+sub _parse_PathPrefix_attr {
+ my ( $self, $c, $name, $value ) = @_;
+ return PathPart => $self->path_prefix . '/id';
+}
+
+1;
More information about the Catalyst-commits
mailing list