[Jifty-commit] jifty branch, master, updated. d8a8097102d4add0931c8f398a95cf5d39b5f291

Jifty commits jifty-commit at lists.jifty.org
Mon Jan 11 23:41:24 EST 2010


The branch, master has been updated
       via  d8a8097102d4add0931c8f398a95cf5d39b5f291 (commit)
      from  dac4d6b131b041b6735ec2d1a9cc17c8c9646a63 (commit)

Summary of changes:
 t/TestApp-Uploads/Makefile.PL                      |    7 +++
 {bin => t/TestApp-Uploads/bin}/jifty               |    0
 .../etc/config.yml                                 |   41 +++++++++++++------
 .../TestApp/Uploads/Action/AttachmentDetails.pm    |   28 +++++++++++++
 t/TestApp-Uploads/t/rest.t                         |   32 +++++++++++++++
 t/TestApp-Uploads/t/upload.txt                     |    1 +
 6 files changed, 96 insertions(+), 13 deletions(-)
 create mode 100644 t/TestApp-Uploads/Makefile.PL
 copy {bin => t/TestApp-Uploads/bin}/jifty (100%)
 copy t/{TestApp-Template-Declare => TestApp-Uploads}/etc/config.yml (67%)
 create mode 100644 t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
 create mode 100644 t/TestApp-Uploads/t/rest.t
 create mode 100644 t/TestApp-Uploads/t/upload.txt

- Log -----------------------------------------------------------------
commit d8a8097102d4add0931c8f398a95cf5d39b5f291
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Jan 11 23:41:18 2010 -0500

    Add a basic file-upload test

diff --git a/t/TestApp-Uploads/Makefile.PL b/t/TestApp-Uploads/Makefile.PL
new file mode 100644
index 0000000..ef48267
--- /dev/null
+++ b/t/TestApp-Uploads/Makefile.PL
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name        'TestApp::Uploads';
+version     '0.01';
+requires    'Jifty' => '1.00105';
+
+WriteAll;
diff --git a/t/TestApp-Uploads/bin/jifty b/t/TestApp-Uploads/bin/jifty
new file mode 100755
index 0000000..118d895
--- /dev/null
+++ b/t/TestApp-Uploads/bin/jifty
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use UNIVERSAL::require;
+
+BEGIN {
+    Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+    my $root = Jifty::Util->app_root(quiet => 1);
+    unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty;
+use Jifty::Script;
+
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
diff --git a/t/TestApp-Uploads/etc/config.yml b/t/TestApp-Uploads/etc/config.yml
new file mode 100644
index 0000000..4ac17d5
--- /dev/null
+++ b/t/TestApp-Uploads/etc/config.yml
@@ -0,0 +1,73 @@
+--- 
+framework: 
+  AdminMode: 1
+  ApplicationClass: TestApp::Uploads
+  ApplicationName: TestApp-Uploads
+  ApplicationUUID: EE2D4328-FF2F-11DE-9789-0CDBEE916148
+  ConfigFileVersion: 4
+  Database: 
+    AutoUpgrade: 1
+    CheckSchema: 1
+    Database: testapp_uploads
+    Driver: SQLite
+    Host: localhost
+    Password: ''
+    RecordBaseClass: Jifty::DBI::Record::Cachable
+    User: ''
+    Version: 0.0.1
+  DevelMode: 1
+  L10N: 
+    PoDir: share/po
+  LogLevel: INFO
+  Mailer: Sendmail
+  MailerArgs: []
+
+  Plugins: 
+    - 
+      AdminUI: {}
+
+    - 
+      CompressedCSSandJS: {}
+
+    - 
+      ErrorTemplates: {}
+
+    - 
+      Halo: {}
+
+    - 
+      LetMe: {}
+
+    - 
+      OnlineDocs: {}
+
+    - 
+      REST: {}
+
+    - 
+      SkeletonApp: {}
+
+  PubSub: 
+    Backend: Memcached
+    Enable: ~
+  SkipAccessControl: 0
+  TemplateClass: TestApp::Uploads::View
+  View: 
+    Handlers: 
+      - Jifty::View::Static::Handler
+      - Jifty::View::Declare::Handler
+      - Jifty::View::Mason::Handler
+  Web: 
+    BaseURL: http://localhost
+    DataDir: var/mason
+    Globals: []
+
+    MasonConfig: 
+      autoflush: 0
+      default_escape_flags: h
+      error_format: text
+      error_mode: fatal
+    Port: 8888
+    ServeStaticFiles: 1
+    StaticRoot: share/web/static
+    TemplateRoot: share/web/templates
diff --git a/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
new file mode 100644
index 0000000..6c539ac
--- /dev/null
+++ b/t/TestApp-Uploads/lib/TestApp/Uploads/Action/AttachmentDetails.pm
@@ -0,0 +1,28 @@
+package TestApp::Uploads::Action::AttachmentDetails;
+use strict;
+use warnings;
+use base 'Jifty::Action';
+
+use Jifty::Param::Schema;
+use Jifty::Action schema {
+    param content =>
+        label is 'File',
+        render as 'Upload';
+};
+
+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);
+
+    return 1;
+}
+
+1;
+
diff --git a/t/TestApp-Uploads/t/rest.t b/t/TestApp-Uploads/t/rest.t
new file mode 100644
index 0000000..ed45ca6
--- /dev/null
+++ b/t/TestApp-Uploads/t/rest.t
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use Jifty::Test::Dist tests => 5;
+use Jifty::Test::WWW::Mechanize;
+use HTTP::Request::Common;
+
+my $server  = Jifty::Test->make_server;
+isa_ok($server, 'Jifty::Server');
+my $URL     = $server->started_ok;
+my $mech    = Jifty::Test::WWW::Mechanize->new;
+
+ok(1, "Loaded the test script");
+
+# we can't use $0 because Jifty::Test::Dist can chdir and
+# $0 doesn't track that
+$mech->request(POST "$URL/=/action/AttachmentDetails.yml",
+    Content_Type => 'multipart/form-data',
+    Content => [
+        content => ['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',
+});
+
diff --git a/t/TestApp-Uploads/t/upload.txt b/t/TestApp-Uploads/t/upload.txt
new file mode 100644
index 0000000..878e990
--- /dev/null
+++ b/t/TestApp-Uploads/t/upload.txt
@@ -0,0 +1 @@
+hlagh

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


More information about the Jifty-commit mailing list