From: Tomas Doran Date: Wed, 19 Aug 2009 21:02:46 +0000 (+0000) Subject: Checking in changes prior to tagging of version 0.26. Changelog diff is: X-Git-Tag: v0.26~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-Session.git;a=commitdiff_plain;h=a4bd5693511c6462684376f93ce86da36005fc76 Checking in changes prior to tagging of version 0.26. Changelog diff is: Index: Changes =================================================================== --- Changes (revision 11170) +++ Changes (working copy) @@ -1,6 +1,9 @@ Revision history for Perl extension Catalyst::Plugin::Session -0.25 2009-0708 +0.26 2009-08-19 + - Remove Test::MockObject from the test suite as it is full of fail. + +0.25 2009-07-08 - Add the a change_session_id method which can be called after authentication to change the user's session cookie whilst preserving their session data. This can be used to provide protection from --- diff --git a/Changes b/Changes index c05c93b..be00c06 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,9 @@ Revision history for Perl extension Catalyst::Plugin::Session -0.25 2009-0708 +0.26 2009-08-19 + - Remove Test::MockObject from the test suite as it is full of fail. + +0.25 2009-07-08 - Add the a change_session_id method which can be called after authentication to change the user's session cookie whilst preserving their session data. This can be used to provide protection from diff --git a/Makefile.PL b/Makefile.PL index b56ccfe..45773ea 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -30,7 +30,6 @@ requires 'Test::More'; test_requires 'Test::Deep'; test_requires 'Test::Exception'; -test_requires 'Test::MockObject' => '1.01'; resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Plugin-Session/0.00/trunk/'; diff --git a/lib/Catalyst/Plugin/Session.pm b/lib/Catalyst/Plugin/Session.pm index 7d3bdaa..31d7833 100644 --- a/lib/Catalyst/Plugin/Session.pm +++ b/lib/Catalyst/Plugin/Session.pm @@ -13,7 +13,7 @@ use Carp; use namespace::clean -except => 'meta'; -our $VERSION = '0.25'; +our $VERSION = '0.26'; my @session_data_accessors; # used in delete_session diff --git a/t/01_setup.t b/t/01_setup.t index 7116db2..13279ad 100644 --- a/t/01_setup.t +++ b/t/01_setup.t @@ -4,17 +4,19 @@ use strict; use warnings; use Test::More tests => 10; -use Test::MockObject; +use Class::MOP; use Test::Deep; my $m; BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) } my %config; -my $log = Test::MockObject->new; +my $log_meta = Class::MOP::Class->create_anon_class(superclasses => ['Moose::Object']); +my $log = $log_meta->name->new; my @mock_isa = (); -$log->set_true("fatal"); +my $calls = 0; +$log_meta->add_method("fatal" => sub { $calls++; 1; }); { @@ -41,7 +43,7 @@ like( "can't setup an object that doesn't use state/store plugins" ); -$log->called_ok( "fatal", "fatal error logged" ); +is $calls, 1, 'Fatal error logged'; @mock_isa = qw/Catalyst::Plugin::Session::State/; eval { MockCxt->new->setup }; @@ -53,13 +55,13 @@ eval { MockCxt->new->setup }; like( $@, qr/requires.*(?:State)/i, "can't setup an object that doesn't use state/store plugins" ); -$log->clear; +$calls = 0; @mock_isa = qw/Catalyst::Plugin::Session::State Catalyst::Plugin::Session::Store/; eval { MockCxt->new->setup }; ok( !$@, "setup() lives with state/store plugins in use" ); -ok( !$log->called("fatal"), "no fatal error logged either" ); +is( $calls, 0, "no fatal error logged either" ); cmp_deeply( [ keys %{ $config{session} } ], diff --git a/t/03_flash.t b/t/03_flash.t index f58222c..0ead785 100644 --- a/t/03_flash.t +++ b/t/03_flash.t @@ -4,28 +4,32 @@ use strict; use warnings; use Test::More tests => 12; -use Test::MockObject::Extends; use Test::Exception; use Test::Deep; my $m; BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) } -my $c = Test::MockObject::Extends->new($m); +my $c_meta = Class::MOP::Class->create_anon_class( + superclasses => [ $m, 'Moose::Object', ], +); +my $c = $c_meta->name->new; my $flash = {}; -$c->mock( +$c_meta->add_method( get_session_data => sub { my ( $c, $key ) = @_; return $key =~ /expire/ ? time() + 1000 : $flash; }, ); -$c->mock("debug" => sub { 0 }); -$c->mock("store_session_data" => sub { $flash = $_[2] }); -$c->mock("delete_session_data" => sub { $flash = {} }); -$c->set_always( _sessionid => "deadbeef" ); -$c->set_always( config => { session => { expires => 1000 } } ); -$c->set_always( stash => {} ); +$c->meta->add_method("debug" => sub { 0 }); +$c->meta->add_method("store_session_data" => sub { $flash = $_[2] }); +$c->meta->add_method("delete_session_data" => sub { $flash = {} }); +$c->meta->add_method( _sessionid => sub { "deadbeef" }); +my $config = { expires => 1000 }; +$c->meta->add_method( config => sub { { session => $config } }); +my $stash = {}; +$c->meta->add_method( stash => sub { $stash } ); is_deeply( $c->session, {}, "nothing in session" ); @@ -67,7 +71,7 @@ cmp_deeply( $c->session, { __updated => re('^\d+$'), }, "session has empty __fla $c->flash->{bar} = "gorch"; -$c->config->{session}{flash_to_stash} = 1; +$config->{flash_to_stash} = 1; $c->finalize_body; $c->prepare_action;