[Jifty-commit] jifty branch, jquery_with_ui, updated. 71971465c071890330a1cd2f24d5f9bd155cdac8

Jifty commits jifty-commit at lists.jifty.org
Tue Feb 2 08:25:56 EST 2010


The branch, jquery_with_ui has been updated
       via  71971465c071890330a1cd2f24d5f9bd155cdac8 (commit)
       via  bf6e881804209184bc2f7d0a38293cfe77784a41 (commit)
      from  99c54250d466c800cffdd8c2e7163009cd98a15e (commit)

Summary of changes:
 .../lib/TestApp/Uploads/Action/Uploads.pm          |   27 ++++++++++++++++++++
 t/TestApp-Uploads/lib/TestApp/Uploads/View.pm      |   20 ++++++++++++++
 t/TestApp-Uploads/t/uploads-js.t                   |   24 +++++++++++++++++
 3 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100644 t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
 create mode 100644 t/TestApp-Uploads/lib/TestApp/Uploads/View.pm
 create mode 100644 t/TestApp-Uploads/t/uploads-js.t

- Log -----------------------------------------------------------------
commit bf6e881804209184bc2f7d0a38293cfe77784a41
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 2 21:24:33 2010 +0800

    uploads js tests

diff --git a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
new file mode 100644
index 0000000..270d5a0
--- /dev/null
+++ b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
@@ -0,0 +1,28 @@
+package TestApp::Uploads::Action::Uploads;
+use strict;
+use warnings;
+use base 'Jifty::Action';
+use UNIVERSAL::isa;
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+    param content =>
+        label is 'File',
+        render as 'Uploads';
+};
+
+sub take_action {
+    my $self = shift;
+
+    my $attachments = $self->argument_value('content');
+    $self->result->content(files => {});
+    for my $att ( ref $attachments eq 'ARRAY' ? @$attachments : $attachments ) {
+        next unless $att && $att->isa('Jifty::Web::FileUpload');
+        warn $att->filename;
+        $self->result->content('files')->{$att->filename} = $att->content;
+    }
+    return 1;
+}
+
+1;
+
diff --git a/t/TestApp-Uploads/lib/TestApp/Uploads/View.pm b/t/TestApp-Uploads/lib/TestApp/Uploads/View.pm
new file mode 100644
index 0000000..18e777d
--- /dev/null
+++ b/t/TestApp-Uploads/lib/TestApp/Uploads/View.pm
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+package TestApp::Uploads::View;
+use Jifty::View::Declare -base;
+
+template 'uploads.html' => page { title => _('Test uploads') } content {
+    my $self = shift;
+    my $moniker = 'uploads';
+    my $action  = new_action(
+        class   => 'TestApp::Uploads::Action::Uploads',
+        moniker => $moniker,
+    );
+    with( name => $moniker ), form {
+        render_action($action);
+        form_submit( label => _('Submit') );
+    }
+};
+
+1;
diff --git a/t/TestApp-Uploads/t/uploads-js.t b/t/TestApp-Uploads/t/uploads-js.t
new file mode 100644
index 0000000..652bf50
--- /dev/null
+++ b/t/TestApp-Uploads/t/uploads-js.t
@@ -0,0 +1,24 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use Jifty::Test::Dist tests => 9;
+use Jifty::Test::WWW::Selenium;
+
+my $server = Jifty::Test->make_server;
+isa_ok( $server, 'Jifty::Server' );
+my $URL = $server->started_ok;
+my $sel = Jifty::Test::WWW::Selenium->rc_ok($server);
+
+$sel->open_ok("/uploads.html");
+my $field = '//a[contains(@class, "attach-more")]';
+$sel->wait_for_element_present_ok($field);
+my $src = $sel->get_html_source();
+my $count = () = $src =~ /type="file"/g;
+is( $count, 1, 'initially, only 1 file' );
+$sel->click_ok($field);
+$sel->wait_for_element_present_ok($field);
+$src = $sel->get_html_source();
+$count = () = $src =~ /type="file"/g;
+is( $count, 2, 'got 2 files' );
+
+$sel->stop;

commit 71971465c071890330a1cd2f24d5f9bd155cdac8
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 2 21:25:26 2010 +0800

    tiny clean

diff --git a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
index 270d5a0..d517b0d 100644
--- a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
+++ b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/Uploads.pm
@@ -18,7 +18,6 @@ sub take_action {
     $self->result->content(files => {});
     for my $att ( ref $attachments eq 'ARRAY' ? @$attachments : $attachments ) {
         next unless $att && $att->isa('Jifty::Web::FileUpload');
-        warn $att->filename;
         $self->result->content('files')->{$att->filename} = $att->content;
     }
     return 1;

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list