11185: On re-run without reuse, assign 'false' to CR.use_existing. Added related...
authorLucas Di Pentima <lucas@curoverse.com>
Wed, 26 Apr 2017 14:03:35 +0000 (11:03 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Wed, 26 Apr 2017 14:03:35 +0000 (11:03 -0300)
apps/workbench/app/controllers/container_requests_controller.rb
apps/workbench/test/controllers/container_requests_controller_test.rb

index 75bcebd63f7d889e8c433ac13b234c1c2690c182..36bda087f8df6a9dcd6af52fa4d04f1ded52f599 100644 (file)
@@ -64,10 +64,13 @@ class ContainerRequestsController < ApplicationController
 
     @object = ContainerRequest.new
 
-    # If "no reuse" requested, pass the correct argument to arvados-cwl-runner command.
-    if params[:no_reuse] and src.command[0] == 'arvados-cwl-runner'
-      command = src.command - ['--enable-reuse']
-      command.insert(1, '--disable-reuse')
+    if params[:no_reuse]
+      @object.use_existing = false
+      # If "no reuse" requested, pass the correct argument to arvados-cwl-runner command.
+      if src.command[0] == 'arvados-cwl-runner'
+        command = src.command - ['--enable-reuse']
+        command.insert(1, '--disable-reuse')
+      end
     else
       command = src.command
     end
index 6a0dd3044560ec26d60cbfe7c9ad8d064f37d0ac..af7abcd3b2bb345893eaefdd2e173c227f44b4e8 100644 (file)
@@ -57,4 +57,13 @@ class ContainerRequestsControllerTest < ActionController::TestCase
     assert_equal completed_cr['cmd'], copied_cr['cmd']
     assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
   end
+
+  test "container request copy without reuse" do
+    completed_cr = api_fixture('container_requests')['completed']
+    post(:copy, {id: completed_cr['uuid']}, session_for(:active))
+    assert_response 302
+    copied_cr = assigns(:object)
+    assert_not_nil copied_cr
+    refute copied_cr['use_existing']
+  end
 end