OSDN Git Service

t: add test for /api/v1/story
authorhylom <hylom@users.sourceforge.jp>
Fri, 28 Oct 2016 12:07:37 +0000 (21:07 +0900)
committerhylom <hylom@users.sourceforge.jp>
Fri, 28 Oct 2016 12:07:37 +0000 (21:07 +0900)
src/newslash_web/t/api.t

index aa8c1d0..3a3c7f2 100644 (file)
@@ -7,24 +7,54 @@ use Test::More;
 use Test::Mojo;
 use Data::Dumper;
 
+use POSIX qw(strftime);
+
 my $t = Test::Mojo->new('Newslash::Web');
 
 SKIP: {
     skip "mode is not 'test'", 1 if ($t->app->mode ne 'test');
+    # submission test
     my $test_data = {
                      title => "テストタレコミ @ " . localtime,
-                     intro_text => "テスト本文\nてすとてすと",
+                     introtext => "テスト本文\nてすとてすと",
                      action => 'post',
                     };
     $t->post_ok('/api/v1/submission' => {Accept => '*/*'} => json => $test_data)
       ->status_is(200)
-      ->json_has('/submission_id');
+      ->json_has('/id')
+      ->json_is('/type' => "submission");
 
     # duplicated submission
     $t->post_ok('/api/v1/submission' => {Accept => '*/*'} => json => $test_data)
       ->status_is(409);
 }
 
+SKIP: {
+    skip "mode is not 'test'", 1 if ($t->app->mode ne 'test');
+    # story test
+    my $createtime = strftime('%FT%T', gmtime);
+    my $test_data = {
+                     title => "テストストーリー",
+                     createtime => $createtime,
+                     author => "test01",
+                     dept => "テストdept",
+                     introtext => "テスト本文\nてすとてすと",
+                     bodytext => "",
+                     add_related => "",
+                     url => "",
+                     mediaurl => "",
+                     mediatype => "",
+                     email => "",
+                     commentstatus => "enabled",
+                     display => 1,
+                     action => 'post',
+                    };
+    $t->post_ok('/api/v1/story' => {Accept => '*/*'} => json => $test_data)
+      ->status_is(200)
+      ->json_has('/id')
+      ->json_is('/type' => "story");
+}
+
 subtest 'submission preview' => sub {
     my $test_data = {
                      title => "テストタレコミ @ " . localtime,