3882: Test response status and #cancel method.
authorTom Clegg <tom@curoverse.com>
Mon, 6 Oct 2014 13:41:25 +0000 (09:41 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 6 Oct 2014 13:41:25 +0000 (09:41 -0400)
services/api/test/functional/arvados/v1/jobs_controller_test.rb

index a3d44528a341ad01550dfed3b1ffe4e17c5eea58..c28cdf7dac4a0bb9c5f0eda28879adf630a62b32 100644 (file)
@@ -102,12 +102,13 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   end
 
   [
-    ['cancelled_at', Time.now],
-    ['state', 'Cancelled'],
-    ['state', 'Running'],
-    ['state', 'Failed'],
-    ['state', 'Complete'],
-  ].each do |attribute, value|
+    ['cancelled_at', Time.now, :success],
+    ['state', 'Cancelled', :success],
+    ['state', 'Running', :unprocessable_entity],
+    ['state', 'Failed', :unprocessable_entity],
+    ['state', 'Complete', :unprocessable_entity],
+    [:use_action, :cancel, :success],
+  ].each do |attribute, value, expected_response|
     test "cancelled job stays cancelled when updated using #{attribute} #{value}" do
       # We need to verify that "cancel" creates a trigger file, so first
       # let's make sure there is no stale trigger file.
@@ -117,13 +118,18 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
       end
 
       authorize_with :active
-      put :update, {
-        id: jobs(:cancelled).uuid,
-        job: {
-          attribute => value
+      if attribute == :use_action
+        post value, { id: jobs(:cancelled).uuid }
+      else
+        put :update, {
+          id: jobs(:cancelled).uuid,
+          job: {
+            attribute => value
+          }
         }
-      }
-      job = JSON.parse(@response.body)
+      end
+      assert_response expected_response
+      job = json_response
       assert_not_nil job['cancelled_at'], 'job cancelled again using #{attribute}=#{value} did not have cancelled_at value'
       assert_equal job['state'], 'Cancelled', 'cancelled again job state changed when updated using using #{attribute}=#{value}'
     end