6414: When viewing a public project, the text "Public Projects" now
[arvados.git] / apps / workbench / test / controllers / projects_controller_test.rb
index 4be4c089a2864f85b61bff83064a54d1a366e8cd..51a4e37d4b75b9484f90027cf32e5da1c3575d85 100644 (file)
@@ -370,4 +370,40 @@ class ProjectsControllerTest < ActionController::TestCase
      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)
+      assert_includes @response.body, "href=\"#{path}\""
+      assert_includes @response.body, "All #{target}"
+    end
+  end
+
+  test "visit a public project and verify the public projects page link exists" do
+    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+    get :show, {id: api_fixture('groups')['anonymously_accessible_project']['uuid']}
+    project = assigns(:object)
+    refute_empty css_select("[href=\"/projects/#{project['uuid']}\"]")
+    assert_includes @response.body, "<a href=\"/projects/public\">Public Projects</a>"
+  end
+
 end