5417: add additional test updates to verify Run button status when input is not readable.
authorRadhika Chippada <radhika@curoverse.com>
Wed, 15 Apr 2015 17:44:17 +0000 (13:44 -0400)
committerRadhika Chippada <radhika@curoverse.com>
Wed, 15 Apr 2015 17:44:17 +0000 (13:44 -0400)
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/helpers/pipeline_instances_helper.rb
apps/workbench/app/views/pipeline_instances/_show_components.html.erb
apps/workbench/app/views/pipeline_instances/_show_inputs.html.erb
apps/workbench/test/integration/anonymous_access_test.rb

index 09adfef16012e672f430d4375a1b7788948703bf..4af7d29cf3cc8f5aaa165cf426cf18645e0e45e1 100644 (file)
@@ -186,9 +186,8 @@ module ApplicationHelper
     readable = object_readable attrvalue, resource_class
     if readable
       link_to_if_arvados_object attrvalue, opts
-    elsif opts[:required]
-      raw('<div><input type="text" style="border:none;width:100%;background:#ffdddd" disabled=true class="required unreadable-input" value="' +
-           link_text_if_not_readable + '" ></input></div>')
+    elsif opts[:required] and current_user # no need to show this for anonymous user
+      raw('<div><input type="text" style="border:none;width:100%;background:#ffdddd" disabled=true class="required unreadable-input" value="' + link_text_if_not_readable + '" ></input></div>')
     else
       link_text_if_not_readable
     end
index b0d5216efd1588069050d5b0d5aa371abc07492d..3fbd27249a0b76c4c12d70ea00cae0acf18a299d 100644 (file)
@@ -306,4 +306,11 @@ module PipelineInstancesHelper
     raw(s)
   end
 
+  def render_unreadable_inputs_present
+    if current_user and controller.class.name.eql?('PipelineInstancesController') and unreadable_inputs_present?
+      raw('<div class="unreadable-inputs-present">' +
+            '<p style="color:#ff6666">One or more inputs provided are not readable by you. ' +
+              'Please correct these before you can run the pipeline.</p></div>')
+    end
+  end
 end
index a2dbada2b20019efdedf9cb914758f5cf2ed8d97..dae57aa0e85ebbe3ccf7ce183a185dcc860b3f0b 100644 (file)
 
 <% else %>
   <%# state is either New or Ready %>
-  <% if controller.class.name.eql?('PipelineInstancesController') and unreadable_inputs_present? %>
-    <div class="unreadable-inputs-present">
-      <p style="color:#ff6666"> One or more inputs provided are not readable by you. Please correct these before you can run the pipeline.</p>
-    </div>
-  <% end %>
+  <%= render_unreadable_inputs_present %>
 
   <p><i>Here are all of the pipeline's components (jobs that will need to run in order to complete the pipeline). If you know what you're doing (or you're experimenting) you can modify these parameters before starting the pipeline. Usually, you only need to edit the settings presented on the "Inputs" tab above.</i></p>
 
index 67afba1de9f7690e39b8719f0d28e5cb153d9961..567ca72504146667b3f7c04c4be70775466426bf 100644 (file)
 <% if n_inputs == 0 %>
   <p>This pipeline does not need any further inputs specified. You can start it by clicking the "Run" button whenever you're ready. (It's not too late to change existing settings, though.)</p>
 <% else %>
-  <% if controller.class.name.eql?('PipelineInstancesController') and unreadable_inputs_present? %>
-    <div class="unreadable-inputs-present">
-      <p style="color:#ff6666"> One or more inputs provided are not readable by you. Please correct these before you can run the pipeline.</p>
-    </div>
-  <% end %>
+  <%= render_unreadable_inputs_present %>
 
   <p><i>Provide <%= n_inputs > 1 ? 'values' : 'a value' %> for the following <%= n_inputs > 1 ? 'parameters' : 'parameter' %>, then click the "Run" button to start the pipeline.</i></p>
   <% if @object.editable? %>
index e8917792ad6a5f579f0550dd18ea8cea1b535157..d1782b8c2da4f27b3d149a7ea36566c6356decc4 100644 (file)
@@ -243,6 +243,7 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
 
   [
     ['new_pipeline_in_publicly_accessible_project', true],
+    ['new_pipeline_in_publicly_accessible_project', true, 'spectator'],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false, 'spectator'],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', true, 'admin'],
@@ -264,13 +265,24 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
         if user == 'admin'
           assert_text 'input'
           assert_selector 'a', text: 'Choose'
+          assert_selector 'a', text: 'Run'
+          assert_no_selector 'a.disabled', text: 'Run'
         else
           assert_selector 'a', text: object['components']['foo']['script_parameters']['input']['value']
+          user ? (assert_selector 'a', text: 'Run') : (assert_no_selector 'a', text: 'Run')
         end
       else
         assert_no_text 'This pipeline was created from'  # template is not readable
-        assert_text object['components']['foo']['script_parameters']['input']['value']
         assert_no_selector 'a', text: object['components']['foo']['script_parameters']['input']['value']
+        if user
+          assert_text "One or more inputs provided are not readable"
+          assert_selector "input[type=text][value=#{object['components']['foo']['script_parameters']['input']['value']}]"
+          assert_selector 'a.disabled', text: 'Run'
+        else
+          assert_no_text "One or more inputs provided are not readable"
+          assert_text object['components']['foo']['script_parameters']['input']['value']
+          assert_no_selector 'a', text: 'Run'
+        end
       end
     end
   end