11185: When re-run, the default behaviour is to copy reuse disabled. Changed modal...
authorLucas Di Pentima <lucas@curoverse.com>
Thu, 27 Apr 2017 15:42:49 +0000 (12:42 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Thu, 27 Apr 2017 15:42:49 +0000 (12:42 -0300)
the user to enable reuse.
Updated tests.

apps/workbench/app/controllers/container_requests_controller.rb
apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
apps/workbench/test/controllers/container_requests_controller_test.rb

index 36bda087f8df6a9dcd6af52fa4d04f1ded52f599..51ad4b67544be0f260545806e8de29742fc32a87 100644 (file)
@@ -64,15 +64,23 @@ class ContainerRequestsController < ApplicationController
 
     @object = ContainerRequest.new
 
-    if params[:no_reuse]
+    # By default the copied CR won't be reusing jobs, unless use_existing=true param
+    # is passed.
+    command = src.command
+    if params[:use_existing]
+      @object.use_existing = true
+      # Pass the correct argument to arvados-cwl-runner command.
+      if src.command[0] == 'arvados-cwl-runner'
+        command = src.command - ['--disable-reuse']
+        command.insert(1, '--enable-reuse')
+      end
+    else
       @object.use_existing = false
-      # If "no reuse" requested, pass the correct argument to arvados-cwl-runner command.
+      # 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
 
     @object.command = command
@@ -88,7 +96,6 @@ class ContainerRequestsController < ApplicationController
     @object.runtime_constraints = src.runtime_constraints
     @object.scheduling_parameters = src.scheduling_parameters
     @object.state = 'Uncommitted'
-    @object.use_existing = false
 
     # set owner_uuid to that of source, provided it is a project and writable by current user
     current_project = Group.find(src.owner_uuid) rescue nil
index 6d5ba6422ec14553dcbf9cf767af1b7140603d62..fc810b1525cc36db630a9c0086d1fb355bdbc408 100644 (file)
@@ -22,8 +22,8 @@
       </div>
 
       <div class="modal-body">
-              <%= check_box_tag(:no_reuse, "true", false) %>
-              <%= label_tag(:script_use_latest, "Disable container reuse") %>
+              <%= check_box_tag(:use_existing, "true", false) %>
+              <%= label_tag(:use_existing, "Enable container reuse") %>
       </div>
 
       <div class="modal-footer">
index 9b4009eeda63044a149cf084bf53cc21ad5612c7..7b0f6fc9002d5a667bd22539e0d4f71fe4357876 100644 (file)
@@ -55,14 +55,20 @@ class ContainerRequestsControllerTest < ActionController::TestCase
     assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
     assert_equal completed_cr['cmd'], copied_cr['cmd']
     assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
+    refute copied_cr[:use_existing]
   end
 
-  test "container request copy without reuse" do
+  test "container request copy with reuse enabled" do
     completed_cr = api_fixture('container_requests')['completed']
-    post(:copy, {id: completed_cr['uuid']}, session_for(:active))
+    post(:copy,
+         {
+           id: completed_cr['uuid'],
+           use_existing: true,
+         },
+         session_for(:active))
     assert_response 302
     copied_cr = assigns(:object)
     assert_not_nil copied_cr
-    refute copied_cr['use_existing']
+    assert copied_cr['use_existing']
   end
 end