X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c4fa80c6ed2445e1e384455944eb6c4108906cad..9d4bc458b767e4c05024dfe02207283745e1ba06:/apps/workbench/test/controllers/repositories_controller_test.rb diff --git a/apps/workbench/test/controllers/repositories_controller_test.rb b/apps/workbench/test/controllers/repositories_controller_test.rb index f95bb7731f..25bf557685 100644 --- a/apps/workbench/test/controllers/repositories_controller_test.rb +++ b/apps/workbench/test/controllers/repositories_controller_test.rb @@ -1,7 +1,9 @@ require 'test_helper' +require 'helpers/repository_stub_helper' require 'helpers/share_object_helper' class RepositoriesControllerTest < ActionController::TestCase + include RepositoryStubHelper include ShareObjectHelper [ @@ -62,4 +64,61 @@ class RepositoriesControllerTest < ActionController::TestCase end end end + + ### Browse repository content + + [:active, :spectator].each do |user| + test "show tree to #{user}" do + reset_api_fixtures_after_test false + sha1, _, _ = stub_repo_content + get :show_tree, { + id: api_fixture('repositories')['foo']['uuid'], + commit: sha1, + }, session_for(user) + assert_response :success + assert_select 'tr td a', 'COPYING' + assert_select 'tr td', '625 bytes' + assert_select 'tr td a', 'apps' + assert_select 'tr td a', 'workbench' + assert_select 'tr td a', 'Gemfile' + assert_select 'tr td', '33.7 KiB' + end + + test "show commit to #{user}" do + reset_api_fixtures_after_test false + sha1, commit, _ = stub_repo_content + get :show_commit, { + id: api_fixture('repositories')['foo']['uuid'], + commit: sha1, + }, session_for(user) + assert_response :success + assert_select 'pre', h(commit) + end + + test "show blob to #{user}" do + reset_api_fixtures_after_test false + sha1, _, filedata = stub_repo_content filename: 'COPYING' + get :show_blob, { + id: api_fixture('repositories')['foo']['uuid'], + commit: sha1, + path: 'COPYING', + }, session_for(user) + assert_response :success + assert_select 'pre', h(filedata) + end + end + + ['', '/'].each do |path| + test "show tree with path '#{path}'" do + reset_api_fixtures_after_test false + sha1, _, _ = stub_repo_content filename: 'COPYING' + get :show_tree, { + id: api_fixture('repositories')['foo']['uuid'], + commit: sha1, + path: path, + }, session_for(:active) + assert_response :success + assert_select 'tr td', 'COPYING' + end + end end