[ARVADOS] updated: 9a124cfd453548bb447df9513f72809a1fba0433

git at public.curoverse.com git at public.curoverse.com
Fri Feb 28 19:30:53 EST 2014


Summary of changes:
 .../app/controllers/arvados/v1/jobs_controller.rb  |    1 +
 .../api/test/integration/collections_api_test.rb   |    4 ---
 services/api/test/integration/jobs_api_test.rb     |   23 ++++++++++++++++++++
 services/api/test/test_helper.rb                   |    6 +++++
 4 files changed, 30 insertions(+), 4 deletions(-)
 create mode 100644 services/api/test/integration/jobs_api_test.rb

       via  9a124cfd453548bb447df9513f72809a1fba0433 (commit)
      from  f96533820a514a36c618c8343d4b6320c7c31cf6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9a124cfd453548bb447df9513f72809a1fba0433
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Feb 28 16:29:34 2014 -0800

    Fix jobs.cancel and add integration test. closes #2258

diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb
index 6c45f88..5c2f5db 100644
--- a/services/api/app/controllers/arvados/v1/jobs_controller.rb
+++ b/services/api/app/controllers/arvados/v1/jobs_controller.rb
@@ -42,6 +42,7 @@ class Arvados::V1::JobsController < ApplicationController
   end
 
   def cancel
+    reload_object_before_update
     @object.update_attributes cancelled_at: Time.now
     show
   end
diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index 076b234..1ceedd7 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -3,10 +3,6 @@ require 'test_helper'
 class CollectionsApiTest < ActionDispatch::IntegrationTest
   fixtures :all
 
-  def jresponse
-    @jresponse ||= ActiveSupport::JSON.decode @response.body
-  end
-
   test "should get index" do
     get "/arvados/v1/collections", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
     assert_response :success
diff --git a/services/api/test/integration/jobs_api_test.rb b/services/api/test/integration/jobs_api_test.rb
new file mode 100644
index 0000000..1c4e294
--- /dev/null
+++ b/services/api/test/integration/jobs_api_test.rb
@@ -0,0 +1,23 @@
+require 'test_helper'
+
+class JobsApiTest < ActionDispatch::IntegrationTest
+  fixtures :all
+
+  test "cancel job" do
+    post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    assert_response :success
+    assert_equal "arvados#job", jresponse['kind']
+    assert_not_nil jresponse['cancelled_at']
+  end
+
+  test "cancel someone else's visible job" do
+    post "/arvados/v1/jobs/#{jobs(:barbaz).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
+    assert_response 403
+  end
+
+  test "cancel someone else's invisible job" do
+    post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
+    assert_response 404
+  end
+
+end
diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index 8c12ffb..8e33995 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -20,5 +20,11 @@ class ActiveSupport::TestCase
   # Add more helper methods to be used by all tests here...
 end
 
+class ActionDispatch::IntegrationTest
+  def jresponse
+    @jresponse ||= ActiveSupport::JSON.decode @response.body
+  end
+end
+
 # Ensure permissions are computed from the test fixtures.
 User.invalidate_permissions_cache

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list