1 require 'integration_helper'
2 require 'helpers/repository_stub_helper'
3 require 'helpers/share_object_helper'
5 class RepositoriesTest < ActionDispatch::IntegrationTest
6 include RepositoryStubHelper
7 include ShareObjectHelper
9 reset_api_fixtures :after_each_test, false
15 test "browse repository from jobs#show" do
16 skip "git2 is unreliable" if Repository.disable_repository_browsing?
17 sha1 = api_fixture('jobs')['running']['script_version']
18 _, fakecommit, fakefile =
19 stub_repo_content sha1: sha1, filename: 'crunch_scripts/hash'
20 show_object_using 'active', 'jobs', 'running', sha1
21 click_on api_fixture('jobs')['running']['script']
23 click_on 'crunch_scripts'
24 assert_selector 'td a', text: 'hash'
26 assert_selector 'td a', text: 'crunch_scripts'
28 assert_text fakecommit
30 show_object_using 'active', 'jobs', 'running', sha1
32 assert_selector 'td a', text: 'crunch_scripts'
34 show_object_using 'active', 'jobs', 'running', sha1
36 assert_text fakecommit
39 test "browse using arv-git-http" do
40 skip "git2 is unreliable" if Repository.disable_repository_browsing?
41 repo = api_fixture('repositories')['foo']
43 File.expand_path('../../../../../tmp/arv-git-httpd-ssl.port', __FILE__)
44 gitsslport = File.read(portfile)
45 Repository.any_instance.
46 stubs(:http_fetch_url).
47 returns "https://localhost:#{gitsslport}/#{repo['name']}.git"
48 commit_sha1 = '1de84a854e2b440dc53bf42f8548afa4c17da332'
49 visit page_with_token('active', "/repositories/#{repo['uuid']}/commit/#{commit_sha1}")
50 assert_text "Date: Tue Mar 18 15:55:28 2014 -0400"
51 visit page_with_token('active', "/repositories/#{repo['uuid']}/tree/#{commit_sha1}")
52 assert_selector "tbody td a", "foo"
53 assert_text "12 bytes"