refs #6465
[arvados.git] / apps / workbench / test / controllers / projects_controller_test.rb
index c695bd5e6bb3c9569a781fa4c7111d17602e38fe..cb4ef9913b0cb0fa9c272db6d4c28724b30aa53e 100644 (file)
@@ -334,21 +334,67 @@ class ProjectsControllerTest < ActionController::TestCase
     found.description = 'Textile description with link to home page <a href="/">take me home</a>.'
     found.save!
     get(:show, {id: project['uuid']}, session_for(:active))
-    assert_not_includes 'Textile description with link to home page <a href="/">take me home</a>.', @response.body
-    assert_match /Textile description with link to home page .*a href=.*take me home.*\/a.*./, @response.body
+    assert_includes @response.body, 'Textile description with link to home page <a href="/">take me home</a>.'
   end
 
   test "find a project and edit description to textile description with link to object" do
     project = api_fixture('groups')['aproject']
     use_token :active
     found = Group.find(project['uuid'])
+
+    # uses 'Link to object' as a hyperlink for the object
     found.description = '"Link to object":' + api_fixture('groups')['asubproject']['uuid']
     found.save!
     get(:show, {id: project['uuid']}, session_for(:active))
-    puts @response.body
-    assert_not_includes '"Link to object"', @response.body
-    assert_match /href=.*Link to object.*\/a./, @response.body
+
+    # check that input was converted to textile, not staying as inputted
+    refute_includes  @response.body,'"Link to object"'
     refute_empty css_select('[href="/groups/zzzzz-j7d0g-axqo7eu9pwvna1x"]')
   end
 
+  test "project viewer can't see project sharing tab" do
+    project = api_fixture('groups')['aproject']
+    get(:show, {id: project['uuid']}, session_for(:project_viewer))
+    refute_includes @response.body, '<div id="Sharing"'
+    assert_includes @response.body, '<div id="Data_collections"'
+  end
+
+  [
+    'admin',
+    'active',
+  ].each do |username|
+    test "#{username} can see project sharing tab" do
+     project = api_fixture('groups')['aproject']
+     get(:show, {id: project['uuid']}, session_for(username))
+     assert_includes @response.body, '<div id="Sharing"'
+     assert_includes @response.body, '<div id="Data_collections"'
+    end
+  end
+
+  [
+    ['admin',true],
+    ['active',true],
+    ['project_viewer',false],
+  ].each do |user, can_move|
+    test "#{user} can move subproject from project #{can_move}" do
+      get(:show, {id: api_fixture('groups')['aproject']['uuid']}, session_for(user))
+      if can_move
+        assert_includes @response.body, 'Move project...'
+      else
+        refute_includes @response.body, 'Move project...'
+      end
+    end
+  end
+
+  [
+    ["jobs", "/jobs"],
+    ["pipelines", "/pipeline_instances"],
+    ["collections", "/collections"],
+  ].each do |target,path|
+    test "test dashboard button all #{target}" do
+      get :index, {}, session_for(:active)
+      refute_empty css_select("[href=\"#{path}\"]")
+      assert_includes @response.body, "All #{target}"
+    end
+  end
 end