Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow form to be rendered with a "get" method attr
Forbid "file" elements when doing so and omit CSRF token.
- Loading branch information
Showing
3 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use Cro::WebApp::Form; | ||
use Cro::WebApp::Template::Repository; | ||
use Test; | ||
|
||
class Search does Cro::WebApp::Form { has $.query is search } | ||
class Upload does Cro::WebApp::Form { has $.photo is file } | ||
|
||
constant template = parse-template 「<&form($_, :method('get'))>」; | ||
|
||
with template.render: Search.empty { | ||
like $_, / 'method="get"' /, 'Form method is GET'; | ||
|
||
unlike $_, / '__CSRF_TOKEN' /, 'CSRF token is omitted'; | ||
} | ||
|
||
throws-like { template.render: Upload.empty }, | ||
X::Cro::WebApp::Form::FileInGET, | ||
:message("Form 'Upload' cannot contain element 'photo' with 'GET' method"), | ||
'File element in a GET form dies'; | ||
|
||
done-testing; |