Skip to content

Commit

Permalink
Removed the 'cookies' method from Core::Context. the DSL can directly
Browse files Browse the repository at this point in the history
access the request and does not need this proxy method.

fixed tests accordingly.
  • Loading branch information
mickeyn authored and xsawyerx committed Jul 23, 2014
1 parent 069b446 commit 12a9557
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
7 changes: 0 additions & 7 deletions lib/Dancer2/Core/Context.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ has response => (
},
);

=method cookies
Shortcut that dispatches to L<Dancer2::Core::Request>'s cookies method.
=cut

sub cookies { shift->request->cookies(@_) }

=method cookie
Expand Down
2 changes: 1 addition & 1 deletion lib/Dancer2/Core/DSL.pm
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ sub forward {
sub vars { shift->context->vars }
sub var { shift->context->var(@_) }

sub cookies { shift->context->cookies }
sub cookies { shift->request->cookies }

sub mime {
my $self = shift;
Expand Down
19 changes: 9 additions & 10 deletions t/context.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ my $env = {
use Dancer2;
}

my $request = Dancer2::Core::Dispatcher->build_request(
$env, Dancer2->runner->apps->[0]
);
my $app = Dancer2->runner->apps->[0];

my $c = Dancer2::Core::Context->new(
env => $env, request => $request
);
my $request = Dancer2::Core::Dispatcher->build_request($env, $app);

my $c = Dancer2::Core::Context->new(request=>$request);

isa_ok $c->request, 'Dancer2::Core::Request';
is $c->request->method, 'GET';

isa_ok $c->cookies->{'dancer.session'}, 'Dancer2::Core::Cookie';
is $c->cookies->{'dancer.session'}->value, 1234;
is $c->cookies->{'dancer.session'}->name, 'dancer.session';
is $c->cookies->{'dancer.session'}->secure, 0;

isa_ok $request->cookies->{'dancer.session'}, 'Dancer2::Core::Cookie';
is $request->cookies->{'dancer.session'}->value, 1234;
is $request->cookies->{'dancer.session'}->name, 'dancer.session';
is $request->cookies->{'dancer.session'}->secure, 0;

done_testing;
2 changes: 1 addition & 1 deletion t/error.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ my $env = {

my $a = Dancer2::Core::App->new( name => 'main' );
my $request = Dancer2::Core::Dispatcher->build_request( $env, $a );
my $c = Dancer2::Core::Context->new( env => $env, app => $a, request => $request );
my $c = Dancer2::Core::Context->new();

$a->set_request($request);

Expand Down

0 comments on commit 12a9557

Please sign in to comment.