fixed regression with action_role namespaces being lost (created last release) and...
[catagits/CatalystX-Declare.git] / t / lib / TestApp / Controller / ActionParams.pm
CommitLineData
d14acb87 1use CatalystX::Declare;
2namespace TestApp;
3
4role hasActionParams {
5 has [qw/p1 p2/] => (is=>'ro', lazy_build=>1);
6
7 method _build_p1 {
34a0a1ff 8 join ',', @{$self->attributes->{p1}};
d14acb87 9 }
10 method _build_p2 {
34a0a1ff 11 join ',', @{$self->attributes->{p2}};
d14acb87 12 }
13}
14
15controller ::Controller::ActionParams {
16
17 action base
18 under '/base'
19 as 'actionparams';
20
21 action first under base
12b853ff 22 with hasActionParams(p1=>100,p2=>101)
23 is final {
d14acb87 24 my $p1 = $ctx->controller->action_for('first')->p1;
25 my $p2 = $ctx->controller->action_for('first')->p2;
26 $ctx->response->body("action_args_first: $p1,$p2");
27 }
28
29 action second under base
12b853ff 30 with hasActionParams({p1=>200,p2=>201})
d14acb87 31 is final {
32 my $p1 = $ctx->controller->action_for('second')->p1;
33 my $p2 = $ctx->controller->action_for('second')->p2;
34 $ctx->response->body("action_args_second: $p1,$p2");
35 }
36
e00e30bd 37 action third under base
38 with hasActionParams(
39 p1=>300,
40 p2=>301,
41 ) is final {
42 my $p1 = $ctx->controller->action_for('third')->p1;
43 my $p2 = $ctx->controller->action_for('third')->p2;
44 $ctx->response->body("action_args_third: $p1,$p2");
45 }
34a0a1ff 46
47 action forth under base
48 with (hasActionParams(
49 p1=>400,
50 p2=>401,
51 ), hasActionParams(p1=>1,p2=>2)) is final {
52 my $p1 = $ctx->controller->action_for('forth')->p1;
53 my $p2 = $ctx->controller->action_for('forth')->p2;
54 $ctx->response->body("action_args_forth: $p1,$p2");
55 }
12b853ff 56
57 action first_app_ns under base
58 with hasActionParams_AppNS(p1=>100,p2=>101)
59 is final {
60 my $p1 = $ctx->controller->action_for('first')->p1;
61 my $p2 = $ctx->controller->action_for('first')->p2;
62 $ctx->response->body("action_args_first: $p1,$p2");
63 }
64
65 action first_cat_ns under base
66 with hasActionParams_CatNS(p1=>100,p2=>101)
67 is final {
68 my $p1 = $ctx->controller->action_for('first')->p1;
69 my $p2 = $ctx->controller->action_for('first')->p2;
70 $ctx->response->body("action_args_first: $p1,$p2");
71 }
72
d14acb87 73}
74