Permalink
Browse files

Plugin::Session::Store::Model use key_prefix specified by config.

  • Loading branch information...
1 parent 33a99ab commit 5b1e0b2ca8bc4018f65da345cbf35983d85af157 @fujiwara fujiwara committed Mar 29, 2011
Showing with 27 additions and 1 deletion.
  1. +5 −1 lib/Ark/Plugin/Session/Store/Model.pm
  2. +22 −0 t/plugin_session_model.t
@@ -14,7 +14,11 @@ has store_model => (
has store_model_key_prefix => (
is => 'rw',
isa => 'Str',
- default => 'session:',
+ default => sub {
+ my $self = shift;
+ defined $self->class_config->{key_prefix} ? $self->class_config->{key_prefix}
+ : 'session:';
+ },
);
around 'get_session_data' => sub {
View
@@ -52,6 +52,11 @@ plan skip_all => 'Cache::MemoryCache required to run this test' if $@;
$c->res->body( $count );
}
+
+ sub prefix: Local {
+ my ($self, $c) = @_;
+ $c->res->body( $c->session->store_model_key_prefix );
+ }
}
plan 'no_plan';
@@ -75,3 +80,20 @@ use Ark::Test 'T1',
is(get('/incr'), 1, 're-increment first ok'); # XXX: this is test for Ark::Test: should be sepalate test.
is(get('/incr'), 2, 're-increment second ok');
}
+
+{
+ is(get('/prefix'), 'session:', 'key_prefix is default');
+}
+
+{
+ package T1;
+ use Ark;
+ conf 'Plugin::Session::Store::Model' => {
+ key_prefix => 'key_prefix_of_session:',
+ model => 'Session',
+ };
+}
+
+{
+ is(get('/prefix'), 'key_prefix_of_session:', 'specified prefix used');
+}

0 comments on commit 5b1e0b2

Please sign in to comment.