From 12a9557cd8e7c8e4962003f7fac9bb0876b2ee70 Mon Sep 17 00:00:00 2001 From: mickey Date: Thu, 29 May 2014 07:37:06 +0200 Subject: [PATCH] Removed the 'cookies' method from Core::Context. the DSL can directly access the request and does not need this proxy method. fixed tests accordingly. --- lib/Dancer2/Core/Context.pm | 7 ------- lib/Dancer2/Core/DSL.pm | 2 +- t/context.t | 19 +++++++++---------- t/error.t | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/Dancer2/Core/Context.pm b/lib/Dancer2/Core/Context.pm index 599400082..3a59788f5 100644 --- a/lib/Dancer2/Core/Context.pm +++ b/lib/Dancer2/Core/Context.pm @@ -100,13 +100,6 @@ has response => ( }, ); -=method cookies - -Shortcut that dispatches to L's cookies method. - -=cut - -sub cookies { shift->request->cookies(@_) } =method cookie diff --git a/lib/Dancer2/Core/DSL.pm b/lib/Dancer2/Core/DSL.pm index bd32efbe0..35c20ca6b 100644 --- a/lib/Dancer2/Core/DSL.pm +++ b/lib/Dancer2/Core/DSL.pm @@ -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; diff --git a/t/context.t b/t/context.t index 25c91024a..67a7893e7 100644 --- a/t/context.t +++ b/t/context.t @@ -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; diff --git a/t/error.t b/t/error.t index 589dc844b..899cf3ca8 100644 --- a/t/error.t +++ b/t/error.t @@ -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);