[Catalyst-commits] r12827 - in
trunk/examples/Tutorial/MyApp_Chapter8/MyApp: . lib lib/MyApp
lib/MyApp/Controller lib/MyApp/Model lib/MyApp/Schema/Result
lib/MyApp/Schema/ResultSet lib/MyApp/View root/src root/static/css t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sun Feb 7 11:44:33 GMT 2010
Author: caelum
Date: 2010-02-07 11:44:32 +0000 (Sun, 07 Feb 2010)
New Revision: 12827
Modified:
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Changes
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Makefile.PL
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Books.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Login.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Logout.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Root.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Model/DB.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Author.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Book.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/BookAuthor.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Role.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/User.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/UserRole.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/ResultSet/Book.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/View/TT.pm
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.conf
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.db
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp01.sql
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp02.sql
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/src/wrapper.tt2
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/static/css/main.css
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/01app.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Books.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Login.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Logout.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/live_app01.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/model_DB.t
trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/view_TT.t
Log:
update chapter 8 code
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Changes
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Changes 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Changes 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,4 +1,4 @@
This file documents the revision history for Perl extension MyApp.
-0.01 2009-11-15 00:20:57
+0.01 2010-02-07 02:42:25
- initial revision, generated by Catalyst
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Makefile.PL
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Makefile.PL 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/Makefile.PL 2010-02-07 11:44:32 UTC (rev 12827)
@@ -6,20 +6,21 @@
name 'MyApp';
all_from 'lib/MyApp.pm';
-requires 'Catalyst::Runtime' => '5.80013';
+requires 'Catalyst::Runtime' => '5.80018';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Plugin::StackTrace';
+requires 'Catalyst::Plugin::Authentication';
+requires 'Catalyst::Plugin::Authorization::Roles';
+requires 'Catalyst::Plugin::Session';
+requires 'Catalyst::Plugin::Session::Store::FastMmap';
+requires 'Catalyst::Plugin::Session::State::Cookie';
requires 'Catalyst::Action::RenderView';
-requires 'parent';
+requires 'Moose';
+requires 'namespace::autoclean';
requires 'Config::General'; # This should reflect the config file format you've chosen
# See Catalyst::Plugin::ConfigLoader for supported formats
-requires (
- 'Catalyst::Plugin::Authentication' => '0',
- 'Catalyst::Plugin::Session' => '0',
- 'Catalyst::Plugin::Session::Store::FastMmap' => '0',
- 'Catalyst::Plugin::Session::State::Cookie' => '0',
- 'Catalyst::Plugin::Authorization::Roles' => '0',
-);
+test_requires 'Test::More' => '0.88';
catalyst;
install_script glob('script/*.pl');
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Books.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Books.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Books.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,8 +1,8 @@
package MyApp::Controller::Books;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-use parent 'Catalyst::Controller';
+BEGIN {extends 'Catalyst::Controller'; }
=head1 NAME
@@ -16,7 +16,6 @@
=cut
-
=head2 index
=cut
@@ -27,19 +26,12 @@
$c->response->body('Matched MyApp::Controller::Books in Books.');
}
-
=head2 list
Fetch all book objects and pass to books/list.tt2 in stash to be displayed
=cut
-=head2 list
-
-Fetch all book objects and pass to books/list.tt2 in stash to be displayed
-
-=cut
-
sub list : Local {
# Retrieve the usual Perl OO '$self' for this object. $c is the Catalyst
# 'Context' that's used to 'glue together' the various components
@@ -53,10 +45,9 @@
# Set the TT template to use. You will almost always want to do this
# in your action methods (action methods respond to user input in
# your controllers).
- $c->stash->{template} = 'books/list.tt2';
+ $c->stash(template => 'books/list.tt2');
}
-
=head2 base
Can place common logic to start chained dispatch here
@@ -188,6 +179,31 @@
}
+=head2 delete
+
+Delete a book
+
+=cut
+
+sub delete :Chained('object') :PathPart('delete') :Args(0) {
+ my ($self, $c) = @_;
+
+ # Check permissions
+ $c->detach('/error_noperms')
+ unless $c->stash->{object}->delete_allowed_by($c->user->get_object);
+
+ # Use the book object saved by 'object' and delete it along
+ # with related 'book_author' entries
+ $c->stash->{object}->delete;
+
+ # Use 'flash' to save information across requests until it's read
+ $c->flash->{status_msg} = "Book deleted";
+
+ # Redirect the user back to the list page
+ $c->response->redirect($c->uri_for($self->action_for('list')));
+}
+
+
=head2 list_recent
List recently created books
@@ -234,36 +250,6 @@
$c->stash->{template} = 'books/list.tt2';
}
-
-=head2 delete
-
-Delete a book
-
-=cut
-
-sub delete :Chained('object') :PathPart('delete') :Args(0) {
- my ($self, $c) = @_;
-
- # Check permissions
- $c->detach('/error_noperms')
- unless $c->stash->{object}->delete_allowed_by($c->user->get_object);
-
- # Use the book object saved by 'object' and delete it along
- # with related 'book_authors' entries
- $c->stash->{object}->delete;
-
- # Use 'flash' to save information across requests until it's read
- $c->flash->{status_msg} = "Book deleted";
-
- # Redirect the user back to the list page
- $c->response->redirect($c->uri_for($self->action_for('list')));
-}
-
-
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
@@ -271,4 +257,6 @@
=cut
+__PACKAGE__->meta->make_immutable;
+
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Login.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Login.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Login.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,8 +1,8 @@
package MyApp::Controller::Login;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-use parent 'Catalyst::Controller';
+BEGIN {extends 'Catalyst::Controller'; }
=head1 NAME
@@ -16,7 +16,6 @@
=cut
-
=head2 index
Login logic
@@ -27,11 +26,11 @@
my ($self, $c) = @_;
# Get the username and password from form
- my $username = $c->request->params->{username} || "";
- my $password = $c->request->params->{password} || "";
+ my $username = $c->request->params->{username};
+ my $password = $c->request->params->{password};
# If the username and password values were found in form
- if (defined($username) && defined($password)) {
+ if ($username && $password) {
# Attempt to log the user in
if ($c->authenticate({ username => $username,
password => $password } )) {
@@ -43,17 +42,15 @@
# Set an error message
$c->stash->{error_msg} = "Bad username or password.";
}
+ } else {
+ # Set an error message
+ $c->stash->{error_msg} = "Empty username or password.";
}
# If either of above don't work out, send to the login page
$c->stash->{template} = 'login.tt2';
}
-
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
@@ -61,4 +58,5 @@
=cut
-1;
+__PACKAGE__->meta->make_immutable;
+
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Logout.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Logout.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Logout.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,8 +1,8 @@
package MyApp::Controller::Logout;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-use parent 'Catalyst::Controller';
+BEGIN {extends 'Catalyst::Controller'; }
=head1 NAME
@@ -16,7 +16,6 @@
=cut
-
=head2 index
Logout logic
@@ -33,11 +32,6 @@
$c->response->redirect($c->uri_for('/'));
}
-
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
@@ -45,4 +39,5 @@
=cut
-1;
+__PACKAGE__->meta->make_immutable;
+
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Root.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Root.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Controller/Root.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,14 +1,14 @@
package MyApp::Controller::Root;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-use parent 'Catalyst::Controller';
+BEGIN { extends 'Catalyst::Controller' }
#
# Sets the actions in this controller to be registered with no prefix
# so they function identically to actions created in MyApp.pm
#
-__PACKAGE__->config->{namespace} = '';
+__PACKAGE__->config(namespace => '');
=head1 NAME
@@ -20,34 +20,6 @@
=head1 METHODS
-=cut
-
-=head2 index
-
-=cut
-
-sub index :Path :Args(0) {
- my ( $self, $c ) = @_;
-
- # Hello World
- $c->response->body( $c->welcome_message );
-}
-
-sub default :Path {
- my ( $self, $c ) = @_;
- $c->response->body( 'Page not found' );
- $c->response->status(404);
-}
-
-=head2 end
-
-Attempt to render a view, if needed.
-
-=cut
-
-sub end : ActionClass('RenderView') {}
-
-
=head2 auto
Check if there is a user and, if not, forward to login page
@@ -84,8 +56,31 @@
return 1;
}
+=head2 index
+The root page (/)
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ # Hello World
+ $c->response->body( $c->welcome_message );
+}
+
+=head2 default
+
+Standard 404 error page
+
+=cut
+
+sub default :Path {
+ my ( $self, $c ) = @_;
+ $c->response->body( 'Page not found' );
+ $c->response->status(404);
+}
+
=head2 error_noperms
Permissions error screen
@@ -98,11 +93,14 @@
$c->stash->{template} = 'error_noperms.tt2';
}
+=head2 end
-=head1 AUTHOR
+Attempt to render a view, if needed.
-root
+=cut
+sub end : ActionClass('RenderView') {}
+
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
@@ -110,4 +108,6 @@
=cut
+__PACKAGE__->meta->make_immutable;
+
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Model/DB.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Model/DB.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Model/DB.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -6,9 +6,13 @@
my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db';
__PACKAGE__->config(
schema_class => 'MyApp::Schema',
- connect_info => [
- $dsn,
- ],
+
+ connect_info => {
+ dsn => $dsn,
+ user => '',
+ password => '',
+ on_connect_do => q{PRAGMA foreign_keys = ON},
+ }
);
=head1 NAME
@@ -25,12 +29,8 @@
=head1 GENERATED BY
-Catalyst::Helper::Model::DBIC::Schema - 0.30
+Catalyst::Helper::Model::DBIC::Schema - 0.4
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software, you can redistribute it and/or modify
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Author.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Author.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Author.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,12 +1,48 @@
package MyApp::Schema::Result::Author;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::Author
+
+=cut
+
__PACKAGE__->table("author");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 first_name
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 last_name
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"id",
{
@@ -32,24 +68,26 @@
);
__PACKAGE__->set_primary_key("id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xmFhYr7BshbH+6PNHc5ABg
+=head2 book_authors
+Type: has_many
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::BookAuthor>
-#
-# Set relationships:
-#
+=cut
-# has_many():
-# args:
-# 1) Name of relationship, DBIC will create an accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *foreign* table (aka, foreign key in peer table)
-__PACKAGE__->has_many(book_authors => 'MyApp::Schema::Result::BookAuthor', 'author_id');
+__PACKAGE__->has_many(
+ "book_authors",
+ "MyApp::Schema::Result::BookAuthor",
+ { "foreign.author_id" => "self.id" },
+);
+
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oAaQWLwMfVf6x2RUSDDy3w
+
# many_to_many():
# args:
# 1) Name of relationship, DBIC will create accessor with this name
@@ -58,7 +96,6 @@
# You must already have the has_many() defined to use a many_to_many().
__PACKAGE__->many_to_many(books => 'book_authors', 'book');
-
#
# Helper methods
#
@@ -68,4 +105,5 @@
return $self->first_name . ' ' . $self->last_name;
}
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Book.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Book.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Book.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,12 +1,62 @@
package MyApp::Schema::Result::Book;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::Book
+
+=cut
+
__PACKAGE__->table("book");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 title
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 rating
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 created
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 updated
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"id",
{
@@ -46,32 +96,25 @@
);
__PACKAGE__->set_primary_key("id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:p+F8wq4lqr29mytXXhLmmA
+=head2 book_authors
+Type: has_many
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::BookAuthor>
-#
-# Set relationships:
-#
+=cut
-# has_many():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *foreign* table (aka, foreign key in peer table)
-__PACKAGE__->has_many(book_authors => 'MyApp::Schema::Result::BookAuthor', 'book_id');
+__PACKAGE__->has_many(
+ "book_authors",
+ "MyApp::Schema::Result::BookAuthor",
+ { "foreign.book_id" => "self.id" },
+);
-# many_to_many():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of has_many() relationship this many_to_many() is shortcut for
-# 3) Name of belongs_to() relationship in model class of has_many() above
-# You must already have the has_many() defined to use a many_to_many().
-__PACKAGE__->many_to_many(authors => 'book_authors', 'author');
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QHvXdV7xNcT3CDXRI/jLjg
#
# Enable automatic date handling
@@ -83,13 +126,14 @@
{ data_type => 'datetime', set_on_create => 1, set_on_update => 1 },
);
+# many_to_many():
+# args:
+# 1) Name of relationship, DBIC will create accessor with this name
+# 2) Name of has_many() relationship this many_to_many() is shortcut for
+# 3) Name of belongs_to() relationship in model class of has_many() above
+# You must already have the has_many() defined to use a many_to_many().
+__PACKAGE__->many_to_many(authors => 'book_authors', 'author');
-#
-# Set ResultSet Class
-#
-__PACKAGE__->resultset_class('MyApp::Schema::ResultSet::Book');
-
-
=head2 author_count
Return the number of authors for the current book
@@ -104,7 +148,6 @@
return $self->authors->count;
}
-
=head2 author_list
Return a comma-separated list of authors for the current book
@@ -124,7 +167,6 @@
return join(', ', @names);
}
-
=head2 delete_allowed_by
Can the specified user delete the current book?
@@ -138,5 +180,5 @@
return $user->has_role('admin');
}
-
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/BookAuthor.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/BookAuthor.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/BookAuthor.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,17 +1,49 @@
package MyApp::Schema::Result::BookAuthor;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::BookAuthor
+
+=cut
+
__PACKAGE__->table("book_author");
+
+=head1 ACCESSORS
+
+=head2 book_id
+
+ data_type: INTEGER
+ default_value: undef
+ is_foreign_key: 1
+ is_nullable: 1
+ size: undef
+
+=head2 author_id
+
+ data_type: INTEGER
+ default_value: undef
+ is_foreign_key: 1
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"book_id",
{
data_type => "INTEGER",
default_value => undef,
+ is_foreign_key => 1,
is_nullable => 1,
size => undef,
},
@@ -19,35 +51,49 @@
{
data_type => "INTEGER",
default_value => undef,
+ is_foreign_key => 1,
is_nullable => 1,
size => undef,
},
);
__PACKAGE__->set_primary_key("book_id", "author_id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:crlgLZ4zEvqBzhdRAdsF5w
+=head2 book
+Type: belongs_to
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::Book>
-#
-# Set relationships:
-#
+=cut
-# belongs_to():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *this* table
-__PACKAGE__->belongs_to(book => 'MyApp::Schema::Result::Book', 'book_id');
+__PACKAGE__->belongs_to(
+ "book",
+ "MyApp::Schema::Result::Book",
+ { id => "book_id" },
+ { join_type => "LEFT" },
+);
-# belongs_to():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *this* table
-__PACKAGE__->belongs_to(author => 'MyApp::Schema::Result::Author', 'author_id');
+=head2 author
+Type: belongs_to
+
+Related object: L<MyApp::Schema::Result::Author>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "author",
+ "MyApp::Schema::Result::Author",
+ { id => "author_id" },
+ { join_type => "LEFT" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ClqpMc0qpOO7W5mt7sjL3w
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Role.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Role.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/Role.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,12 +1,41 @@
package MyApp::Schema::Result::Role;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::Role
+
+=cut
+
__PACKAGE__->table("role");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 role
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"id",
{
@@ -25,23 +54,26 @@
);
__PACKAGE__->set_primary_key("id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7GQcbQ/R900IGPkW/bvYFA
+=head2 user_roles
+Type: has_many
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::UserRole>
-#
-# Set relationships:
-#
+=cut
-# has_many():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *foreign* table (aka, foreign key in peer table)
-__PACKAGE__->has_many(map_user_roles => 'MyApp::Schema::Result::UserRole', 'role_id');
+__PACKAGE__->has_many(
+ "user_roles",
+ "MyApp::Schema::Result::UserRole",
+ { "foreign.role_id" => "self.id" },
+);
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZM+4fiRxAJxcpem7BzNCJA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/User.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/User.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/User.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,12 +1,76 @@
package MyApp::Schema::Result::User;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::User
+
+=cut
+
__PACKAGE__->table("user");
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 username
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 password
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 email_address
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 first_name
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 last_name
+
+ data_type: TEXT
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=head2 active
+
+ data_type: INTEGER
+ default_value: undef
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"id",
{
@@ -60,34 +124,34 @@
);
__PACKAGE__->set_primary_key("id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E8RDfu637lxvFfWV6x+1tw
+=head2 user_roles
+Type: has_many
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::UserRole>
-#
-# Set relationships:
-#
+=cut
-# has_many():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *foreign* table (aka, foreign key in peer table)
-__PACKAGE__->has_many(map_user_roles => 'MyApp::Schema::Result::UserRole', 'user_id');
+__PACKAGE__->has_many(
+ "user_roles",
+ "MyApp::Schema::Result::UserRole",
+ { "foreign.user_id" => "self.id" },
+);
+
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xfjg2vo+tmdbYqJjWt93aw
+
# many_to_many():
# args:
# 1) Name of relationship, DBIC will create accessor with this name
# 2) Name of has_many() relationship this many_to_many() is shortcut for
# 3) Name of belongs_to() relationship in model class of has_many() above
# You must already have the has_many() defined to use a many_to_many().
-__PACKAGE__->many_to_many(roles => 'map_user_roles', 'role');
+__PACKAGE__->many_to_many(roles => 'user_roles', 'role');
-
-
# Have the 'password' column use a SHA-1 hash and 10-character salt
# with hex encoding; Generate the 'check_password" method
__PACKAGE__->add_columns(
@@ -101,7 +165,6 @@
},
);
-
=head 2 has_role
Check if a user has the specified role
@@ -116,4 +179,5 @@
return any(map { $_->role } $self->roles) eq $role;
}
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/UserRole.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/UserRole.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/Result/UserRole.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,17 +1,49 @@
package MyApp::Schema::Result::UserRole;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::Core';
-__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn", "Core");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp", "EncodedColumn");
+
+=head1 NAME
+
+MyApp::Schema::Result::UserRole
+
+=cut
+
__PACKAGE__->table("user_role");
+
+=head1 ACCESSORS
+
+=head2 user_id
+
+ data_type: INTEGER
+ default_value: undef
+ is_foreign_key: 1
+ is_nullable: 1
+ size: undef
+
+=head2 role_id
+
+ data_type: INTEGER
+ default_value: undef
+ is_foreign_key: 1
+ is_nullable: 1
+ size: undef
+
+=cut
+
__PACKAGE__->add_columns(
"user_id",
{
data_type => "INTEGER",
default_value => undef,
+ is_foreign_key => 1,
is_nullable => 1,
size => undef,
},
@@ -19,36 +51,49 @@
{
data_type => "INTEGER",
default_value => undef,
+ is_foreign_key => 1,
is_nullable => 1,
size => undef,
},
);
__PACKAGE__->set_primary_key("user_id", "role_id");
+=head1 RELATIONS
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:D+PW4fJ4fvYbDZwblXucEw
+=head2 user
+Type: belongs_to
-# You can replace this text with custom content, and it will be preserved on regeneration
+Related object: L<MyApp::Schema::Result::User>
-#
-# Set relationships:
-#
+=cut
-# belongs_to():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *this* table
-__PACKAGE__->belongs_to(user => 'MyApp::Schema::Result::User', 'user_id');
+__PACKAGE__->belongs_to(
+ "user",
+ "MyApp::Schema::Result::User",
+ { id => "user_id" },
+ { join_type => "LEFT" },
+);
-# belongs_to():
-# args:
-# 1) Name of relationship, DBIC will create accessor with this name
-# 2) Name of the model class referenced by this relationship
-# 3) Column name in *this* table
-__PACKAGE__->belongs_to(role => 'MyApp::Schema::Result::Role', 'role_id');
+=head2 role
+Type: belongs_to
+Related object: L<MyApp::Schema::Result::Role>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "role",
+ "MyApp::Schema::Result::Role",
+ { id => "role_id" },
+ { join_type => "LEFT" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 04:49:36
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tsDMQcH8uEP2vYbVZm6WiA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
1;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/ResultSet/Book.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/ResultSet/Book.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema/ResultSet/Book.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -13,7 +13,7 @@
sub created_after {
my ($self, $datetime) = @_;
- my $date_str = $self->_source_handle->schema->storage
+ my $date_str = $self->result_source->schema->storage
->datetime_parser->format_datetime($datetime);
return $self->search({
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/Schema.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,15 +1,20 @@
package MyApp::Schema;
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
use strict;
use warnings;
use base 'DBIx::Class::Schema';
-__PACKAGE__->load_namespaces;
+__PACKAGE__->load_namespaces(
+ result_namespace => 'Result',
+);
-# Created by DBIx::Class::Schema::Loader v0.04006 @ 2009-11-15 03:45:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lPMFS4jyCvkR5jG+s6igkg
+# Created by DBIx::Class::Schema::Loader v0.05001 @ 2010-02-07 03:38:55
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+asok1riE0WTYfuUVE6bWg
# You can replace this text with custom content, and it will be preserved on regeneration
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/View/TT.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/View/TT.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp/View/TT.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -7,7 +7,7 @@
__PACKAGE__->config(
# Change default TT extension
- TEMPLATE_EXTENSION => '.tt2',
+ #TEMPLATE_EXTENSION => '.tt2',
# Set the location for TT files
INCLUDE_PATH => [
MyApp->path_to( 'root', 'src' ),
@@ -30,10 +30,6 @@
L<MyApp>
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp.pm
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp.pm 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/lib/MyApp.pm 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,8 +1,7 @@
package MyApp;
+use Moose;
+use namespace::autoclean;
-use strict;
-use warnings;
-
use Catalyst::Runtime 5.80;
# Set flags and add plugins for the application
@@ -13,23 +12,25 @@
# Static::Simple: will serve static files from the application's root
# directory
-use parent qw/Catalyst/;
-# Load plugins
use Catalyst qw/
- -Debug
- ConfigLoader
- Static::Simple
+ -Debug
+ ConfigLoader
+ Static::Simple
- StackTrace
+ StackTrace
- Authentication
- Authorization::Roles
+ Authentication
+ Authorization::Roles
- Session
- Session::Store::FastMmap
- Session::State::Cookie
- /;
+ Session
+ Session::Store::FastMmap
+ Session::State::Cookie
+/;
+
+extends 'Catalyst';
+
our $VERSION = '0.01';
+$VERSION = eval $VERSION;
# Configure the application.
#
@@ -41,11 +42,12 @@
# local deployment.
__PACKAGE__->config(
- name => 'MyApp',
- session => {flash_to_stash => 1},
- );
+ name => 'MyApp',
+ # Disable deprecated behavior needed by old applications
+ disable_component_resolution_regex_fallback => 1,
+ session => { flash_to_stash => 1 },
+);
-
# Configure SimpleDB Authentication
__PACKAGE__->config->{'Plugin::Authentication'} = {
default => {
@@ -75,10 +77,6 @@
L<MyApp::Controller::Root>, L<Catalyst>
-=head1 AUTHOR
-
-root
-
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.conf
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.conf 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.conf 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,3 +1,3 @@
-# rename this file to MyApp.yml and put a ':' in front of 'name' if
+# rename this file to myapp.yml and put a ':' after 'name' if
# you want to use YAML like in old versions of Catalyst
name MyApp
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp.db
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp01.sql
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp01.sql 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp01.sql 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,3 +1,4 @@
+PRAGMA foreign_keys = ON;
--
-- Create a very simple database to hold book and author information
--
@@ -8,8 +9,8 @@
);
-- 'book_author' is a many-to-many join table between books & authors
CREATE TABLE book_author (
- book_id INTEGER,
- author_id INTEGER,
+ book_id INTEGER REFERENCES book(id) ON DELETE CASCADE ON UPDATE CASCADE,
+ author_id INTEGER REFERENCES author(id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (book_id, author_id)
);
CREATE TABLE author (
@@ -41,4 +42,3 @@
INSERT INTO book_author VALUES (4, 6);
INSERT INTO book_author VALUES (4, 7);
INSERT INTO book_author VALUES (5, 8);
-
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp02.sql
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp02.sql 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/myapp02.sql 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,3 +1,4 @@
+PRAGMA foreign_keys = ON;
--
-- Add user and role tables, along with a many-to-many join table
--
@@ -15,8 +16,8 @@
role TEXT
);
CREATE TABLE user_role (
- user_id INTEGER,
- role_id INTEGER,
+ user_id INTEGER REFERENCES user(id) ON DELETE CASCADE ON UPDATE CASCADE,
+ role_id INTEGER REFERENCES role(id) ON DELETE CASCADE ON UPDATE CASCADE,
PRIMARY KEY (user_id, role_id)
);
--
@@ -31,4 +32,3 @@
INSERT INTO user_role VALUES (1, 2);
INSERT INTO user_role VALUES (2, 1);
INSERT INTO user_role VALUES (3, 1);
-
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/src/wrapper.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/src/wrapper.tt2 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/src/wrapper.tt2 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>[% template.title or "My Catalyst App!" %]</title>
<link rel="stylesheet" href="[% c.uri_for('/static/css/main.css') %]" />
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/static/css/main.css
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/static/css/main.css 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/root/static/css/main.css 2010-02-07 11:44:32 UTC (rev 12827)
@@ -34,4 +34,3 @@
.error {
color: #f00;
}
-
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/01app.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/01app.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/01app.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,8 +1,10 @@
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 2;
+use Test::More;
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
ok( request('/login')->is_success, 'Request should succeed' );
+
+done_testing();
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Books.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Books.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Books.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,10 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More;
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Books' }
ok( request('/books')->is_redirect, 'Request should succeed' );
-
-
+done_testing();
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Login.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Login.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Login.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,10 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More;
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Login' }
ok( request('/login')->is_success, 'Request should succeed' );
-
-
+done_testing();
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Logout.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Logout.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/controller_Logout.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,10 +1,9 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More;
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Logout' }
ok( request('/logout')->is_redirect, 'Request should succeed' );
-
-
+done_testing();
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/live_app01.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/live_app01.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/live_app01.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -2,14 +2,8 @@
use strict;
use warnings;
+use Test::More;
-# Load testing framework and use 'no_plan' to dynamically pick up
-# all tests. Better to replace "'no_plan'" with "tests => 30" so it
-# knows exactly how many tests need to be run (and will tell you if
-# not), but 'no_plan' is nice for quick & dirty tests
-
-use Test::More 'no_plan';
-
# Need to specify the name of your app as arg on next line
# Can also do:
# use Test::WWW::Mechanize::Catalyst "MyApp";
@@ -103,3 +97,4 @@
$ua2->get_ok("http://localhost/books/url_create/TestTitle2/2/5", "'test02' add");
$ua2->content_contains("Unauthorized!", "Check 'test02' cannot add");
+done_testing;
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/model_DB.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/model_DB.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/model_DB.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,6 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More;
BEGIN { use_ok 'MyApp::Model::DB' }
+done_testing();
Modified: trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/view_TT.t
===================================================================
--- trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/view_TT.t 2010-02-07 11:41:40 UTC (rev 12826)
+++ trunk/examples/Tutorial/MyApp_Chapter8/MyApp/t/view_TT.t 2010-02-07 11:44:32 UTC (rev 12827)
@@ -1,7 +1,7 @@
-use MyApp;
use strict;
use warnings;
-use Test::More tests => 1;
+use Test::More;
BEGIN { use_ok 'MyApp::View::TT' }
+done_testing();
More information about the Catalyst-commits
mailing list