Merge branch '12737-wb-rails42-upgrade'
[arvados.git] / apps / workbench / test / controllers / repositories_controller_test.rb
index 852a602d526ee70120b68bde1af1caf4f48b113d..b81e2384c98db7975349e0ea4a4c387f95223a2a 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'test_helper'
 require 'helpers/repository_stub_helper'
 require 'helpers/share_object_helper'
@@ -59,7 +63,7 @@ class RepositoriesControllerTest < ActionController::TestCase
       assert_response :success
 
       panes = css_select('[data-toggle=tab]').each do |pane|
-        pane_name = pane.attributes['href']
+        pane_name = pane.attributes['href'].value
         assert_includes expected_panes, pane_name
       end
     end
@@ -69,7 +73,6 @@ class RepositoriesControllerTest < ActionController::TestCase
 
   [:active, :spectator].each do |user|
     test "show tree to #{user}" do
-      skip "git2 is unreliable" if Repository.disable_repository_browsing?
       reset_api_fixtures_after_test false
       sha1, _, _ = stub_repo_content
       get :show_tree, {
@@ -86,7 +89,6 @@ class RepositoriesControllerTest < ActionController::TestCase
     end
 
     test "show commit to #{user}" do
-      skip "git2 is unreliable" if Repository.disable_repository_browsing?
       reset_api_fixtures_after_test false
       sha1, commit, _ = stub_repo_content
       get :show_commit, {
@@ -94,11 +96,10 @@ class RepositoriesControllerTest < ActionController::TestCase
         commit: sha1,
       }, session_for(user)
       assert_response :success
-      assert_select 'pre', h(commit)
+      assert_select 'pre', commit
     end
 
     test "show blob to #{user}" do
-      skip "git2 is unreliable" if Repository.disable_repository_browsing?
       reset_api_fixtures_after_test false
       sha1, _, filedata = stub_repo_content filename: 'COPYING'
       get :show_blob, {
@@ -107,13 +108,12 @@ class RepositoriesControllerTest < ActionController::TestCase
         path: 'COPYING',
       }, session_for(user)
       assert_response :success
-      assert_select 'pre', h(filedata)
+      assert_select 'pre', filedata
     end
   end
 
   ['', '/'].each do |path|
     test "show tree with path '#{path}'" do
-      skip "git2 is unreliable" if Repository.disable_repository_browsing?
       reset_api_fixtures_after_test false
       sha1, _, _ = stub_repo_content filename: 'COPYING'
       get :show_tree, {
@@ -125,4 +125,20 @@ class RepositoriesControllerTest < ActionController::TestCase
       assert_select 'tr td', 'COPYING'
     end
   end
+
+  test "get repositories lists linked as well as owned repositories" do
+    params = {
+      partial: :repositories_rows,
+      format: :json,
+    }
+    get :index, params, session_for(:active)
+    assert_response :success
+    repos = assigns(:objects)
+    assert repos
+    assert_not_empty repos, "my_repositories should not be empty"
+    repo_uuids = repos.map(&:uuid)
+    assert_includes repo_uuids, api_fixture('repositories')['repository2']['uuid']  # owned by active
+    assert_includes repo_uuids, api_fixture('repositories')['repository4']['uuid']  # shared with active
+    assert_includes repo_uuids, api_fixture('repositories')['arvados']['uuid']      # shared with all_users
+  end
 end