2659: hide job re-run button when user is inactive and add fixtures and tests for...
authorRadhika Chippada <radhika@curoverse.com>
Sun, 1 Feb 2015 04:01:31 +0000 (23:01 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Sun, 1 Feb 2015 04:01:31 +0000 (23:01 -0500)
apps/workbench/app/views/jobs/_show_job_buttons.html.erb
apps/workbench/test/integration/anonymous_access_test.rb
services/api/test/fixtures/jobs.yml
services/api/test/fixtures/pipeline_instances.yml
services/api/test/fixtures/pipeline_templates.yml

index f4a32197c42de7876d47a609399da860be80e619..d12b74435bb68c16d94f15447782297658939983 100644 (file)
@@ -1,4 +1,4 @@
-<% if @object.state != "Running" %>
+<% if @object.state != "Running" && current_user.is_active %>
   <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#jobRerunModal">
     <i class="fa fa-fw fa-gear"></i> Re-run job...
   </button>
index f5753a5548bf5548204c73c4d9823ee3101b96ac..74d4aec970ef95f84f3cd6dc3d24dbdc1e6ac636 100644 (file)
@@ -93,4 +93,109 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
     visit "/projects/#{api_fixture('groups')['aproject']['uuid']}/?public_data=true"
     assert_text 'Not Found'
   end
+
+  test "selection actions when anonymous user accesses shared project" do
+    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+    visit "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}/?public_data=true"
+
+    assert_selector 'a', text: 'Data collections'
+    assert_selector 'a', text: 'Jobs and pipelines'
+    assert_selector 'a', text: 'Pipeline templates'
+    assert_selector 'a', text: 'Advanced'
+    assert_no_selector 'a', text: 'Subprojects'
+    assert_no_selector 'a', text: 'Other objects'
+    assert_no_selector 'button', text: 'Add data'
+
+    click_button 'Selection'
+    within('.selection-action-container') do
+      assert_selector 'li', text: 'Compare selected'
+      assert_no_selector 'li', text: 'Create new collection with selected collections'
+      assert_no_selector 'li', text: 'Copy selected'
+      assert_no_selector 'li', text: 'Move selected'
+      assert_no_selector 'li', text: 'Remove selected'
+    end
+  end
+
+  def visit_publicly_accessible_project
+    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+    visit "/projects/#{api_fixture('groups')['anonymously_accessible_project']['uuid']}/?public_data=true"
+  end
+
+  test "anonymous user accesses data collections tab in shared project" do
+    visit_publicly_accessible_project
+
+    assert_selector 'a', text: 'Data collections (1)'
+
+    # click on show collection
+    within first('tr[data-kind="arvados#collection"]') do
+      click_link 'Show'
+    end
+
+    # in collection page
+    assert_no_selector 'input', text: 'Create sharing link'
+    assert_no_selector 'a', text: 'Upload'
+
+    within ('#collection_files') do
+      assert_text 'GNU_General_Public_License,_version_3.pdf'
+      # how do i assert the view and download links?
+    end
+  end
+
+  [ 'job', 'pipelineInstance' ].each do |type|
+    test "anonymous user accesses jobs and pipelines tab in shared project and clicks on #{type}" do
+      visit_publicly_accessible_project
+
+      assert_selector 'a', 'Jobs and pipelines (2)'
+
+      click_link 'Jobs and pipelines'
+      assert_text 'hash job'
+
+      # click on type specified collection
+      if type == 'job'
+        verify_job_row
+      else
+        verify_pipeline_instance_row
+      end
+    end
+  end
+
+  def verify_job_row
+    within first('tr[data-kind="arvados#job"]') do
+      assert_text 'hash job using'
+      click_link 'Show'
+    end
+
+    # in job page
+    assert_no_selector 'button', text: 'Re-run job'
+    assert_text 'script_version'
+  end
+
+  def verify_pipeline_instance_row
+    within first('tr[data-kind="arvados#pipelineInstance"]') do
+      assert_text 'Pipeline in publicly accessible project'
+      click_link 'Show'
+    end
+
+    # in pipeline instance page
+    assert_no_selector 'a', text: 'Re-run with latest'
+    assert_no_selector 'a', text: 'Re-run options'
+    assert_text 'This pipeline is complete'
+  end
+
+  test "anonymous user accesses pipeline templates tab in shared project" do
+    visit_publicly_accessible_project
+
+    assert_selector 'a', 'Pipeline templates (1)'
+
+    click_link 'Pipeline templates'
+    assert_text 'Pipeline template in publicly accessible project'
+
+    within first('tr[data-kind="arvados#pipelineTemplate"]') do
+      click_link 'Show'
+    end
+
+    # in template page
+    assert_text 'script version'
+    assert_no_selector 'a', text: 'Run this pipeline'
+  end
 end
index a922a8bd1f8ce363e212d843f169b748398212ad..154828f1fdffb7479a9d65ca0f7eaf28fbe4d34c 100644 (file)
@@ -402,6 +402,17 @@ job_with_latest_version:
   runtime_constraints: {}
   state: Complete
 
+job_in_publicly_accessible_project:
+  uuid: zzzzz-8i9sb-n7omg50bvt0m1nf
+  owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0
+  repository: foo
+  script: hash
+  script_version: 4fe459abe02d9b365932b8f5dc419439ab4e2577
+  state: Complete
+  script_parameters:
+    input: fa7aeb5140e2848d39b416daeef4ffc5+45
+    input2: "stuff2"
+
 # Test Helper trims the rest of the file
 
 # Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 184e7228180e3811613de43878a8fb9f06d0f58a..69e1f7d5ff7d2da848ee5308ff78eca202da1a36 100644 (file)
@@ -216,6 +216,22 @@ pipeline_owned_by_active_in_home:
           dataclass: Collection
           title: foo instance input
 
+pipeline_in_publicly_accessible_project:
+  uuid: zzzzz-d1hrv-n68vc490mloy4fi
+  owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0
+  name: Pipeline in publicly accessible project
+  state: Complete
+  created_at: 2014-09-15 12:00:00
+  components:
+    foo:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: Collection
+          title: foo instance input
+
 # Test Helper trims the rest of the file
 
 # Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 260eab8852025a83ae938af45164908e41414f1a..4659da349092dc37bd63078268d7ef307f3532d1 100644 (file)
@@ -164,3 +164,23 @@ template_with_dataclass_file:
           default: [1,1,2,3,5]
         array_with_value: # important to test repeating values in the array!
           value: [1,1,2,3,5]
+
+pipeline_template_in_publicly_accessible_project:
+  uuid: zzzzz-p5p6p-tmpltpublicproj
+  owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0
+  created_at: 2014-04-14 12:35:04 -0400
+  updated_at: 2014-04-14 12:35:04 -0400
+  modified_at: 2014-04-14 12:35:04 -0400
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  name: Pipeline template in publicly accessible project
+  components:
+    foo_component:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: Collection
+          title: "default input"
+          description: "input collection"