1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
6 require 'helpers/repository_stub_helper'
7 require 'helpers/share_object_helper'
9 class RepositoriesTest < ActionDispatch::IntegrationTest
10 include RepositoryStubHelper
11 include ShareObjectHelper
13 reset_api_fixtures :after_each_test, false
19 test "browse repository from jobs#show" do
20 sha1 = api_fixture('jobs')['running']['script_version']
21 _, fakecommit, fakefile =
22 stub_repo_content sha1: sha1, filename: 'crunch_scripts/hash'
23 show_object_using 'active', 'jobs', 'running', sha1
24 click_on api_fixture('jobs')['running']['script']
26 click_on 'crunch_scripts'
27 assert_selector 'td a', text: 'hash'
29 assert_selector 'td a', text: 'crunch_scripts'
31 assert_text fakecommit
33 show_object_using 'active', 'jobs', 'running', sha1
35 assert_selector 'td a', text: 'crunch_scripts'
37 show_object_using 'active', 'jobs', 'running', sha1
39 assert_text fakecommit
42 test "browse using arv-git-http" do
43 repo = api_fixture('repositories')['foo']
45 File.expand_path('../../../../../tmp/arv-git-httpd-ssl.port', __FILE__)
46 gitsslport = File.read(portfile)
47 Repository.any_instance.
48 stubs(:http_fetch_url).
49 returns "https://localhost:#{gitsslport}/#{repo['name']}.git"
50 commit_sha1 = '1de84a854e2b440dc53bf42f8548afa4c17da332'
51 visit page_with_token('active', "/repositories/#{repo['uuid']}/commit/#{commit_sha1}")
52 assert_text "Date: Tue Mar 18 15:55:28 2014 -0400"
53 visit page_with_token('active', "/repositories/#{repo['uuid']}/tree/#{commit_sha1}")
54 assert_selector "tbody td a", "foo"
55 assert_text "12 bytes"