[Jifty-commit] jifty branch, master, updated. 57bb6d53c2ac57892363d7cf62e32c9ce65d71fc
Jifty commits
jifty-commit at lists.jifty.org
Fri Apr 2 02:49:53 EDT 2010
The branch, master has been updated
via 57bb6d53c2ac57892363d7cf62e32c9ce65d71fc (commit)
from 76a1f6b6027ade405945a05441ca51f1cb3879d4 (commit)
Summary of changes:
.../TestApp/Uploads/Action/AttachmentDetails.pm | 23 ++++++---
t/TestApp-Uploads/t/rest.t | 53 ++++++++++++++++---
2 files changed, 59 insertions(+), 17 deletions(-)
- Log -----------------------------------------------------------------
commit 57bb6d53c2ac57892363d7cf62e32c9ce65d71fc
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Apr 2 14:45:50 2010 +0800
tests for multiple uploads
diff --git a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
index 6c539ac..c5f560c 100644
--- a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
+++ b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
@@ -7,20 +7,27 @@ use Jifty::Param::Schema;
use Jifty::Action schema {
param content =>
label is 'File',
- render as 'Upload';
+ render as 'Uploads';
};
sub take_action {
my $self = shift;
- my $attachment = $self->argument_value('content');
-
- $self->result->content(filename => $attachment->filename);
- $self->result->content(content_type => $attachment->content_type);
- $self->result->content(length => length($attachment->content));
- $self->result->content(stringify => "$attachment");
- $self->result->content(scalar_ref => $$attachment);
+ my $attachments = $self->argument_value('content');
+ my @att = ref $attachments eq 'ARRAY' ? @$attachments : $attachments;
+ my @contents;
+ for my $att (@att) {
+ push @contents,
+ {
+ filename => $att->filename,
+ content_type => $att->content_type,
+ length => length $att->content,
+ stringify => "$att",
+ scalar_ref => $$att,
+ };
+ }
+ $self->result->content(contents => \@contents);
return 1;
}
diff --git a/t/TestApp-Uploads/t/rest.t b/t/TestApp-Uploads/t/rest.t
index 54bee97..adb1ba7 100644
--- a/t/TestApp-Uploads/t/rest.t
+++ b/t/TestApp-Uploads/t/rest.t
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use warnings;
use strict;
-use Jifty::Test::Dist tests => 5;
+use Jifty::Test::Dist tests => 7;
use Jifty::Test::WWW::Mechanize;
use HTTP::Request::Common;
@@ -17,16 +17,51 @@ ok(1, "Loaded the test script");
$mech->request(POST "$URL/=/action/AttachmentDetails.yml",
Content_Type => 'multipart/form-data',
Content => [
- content => ['t/upload.txt'],
+ content => ['t/upload.txt', 't/upload.txt',],
],
);
my $results = Jifty::YAML::Load($mech->content);
ok($results->{success}, 'success');
-is_deeply($results->{content}, {
- content_type => 'text/plain',
- filename => 'upload.txt',
- length => 6,
- scalar_ref => 'upload.txt',
- stringify => 'upload.txt',
-});
+is_deeply(
+ $results->{content}{contents},
+ [
+ {
+ content_type => 'text/plain',
+ filename => 'upload.txt',
+ length => 6,
+ scalar_ref => 'upload.txt',
+ stringify => 'upload.txt',
+ }
+ ],
+ 'one attachment is parsed',
+);
+$mech->request(POST "$URL/=/action/AttachmentDetails.yml",
+ Content_Type => 'multipart/form-data',
+ Content => [
+ content => ['t/upload.txt', 't/upload.txt',],
+ content => ['t/upload2.txt', 't/upload2.txt'],
+ ],
+);
+$results = Jifty::YAML::Load($mech->content);
+ok($results->{success}, 'success');
+is_deeply(
+ $results->{content}{contents},
+ [
+ {
+ content_type => 'text/plain',
+ filename => 'upload.txt',
+ length => 6,
+ scalar_ref => 'upload.txt',
+ stringify => 'upload.txt',
+ },
+ {
+ content_type => 'text/plain',
+ filename => 'upload2.txt',
+ length => 11,
+ scalar_ref => 'upload2.txt',
+ stringify => 'upload2.txt',
+ },
+ ],
+ 'two attachments are parsed',
+);
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list