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 sha1 = api_fixture('jobs')['running']['script_version']
17 _, fakecommit, fakefile =
18 stub_repo_content sha1: sha1, filename: 'crunch_scripts/hash'
19 show_object_using 'active', 'jobs', 'running', sha1
20 click_on api_fixture('jobs')['running']['script']
22 click_on 'crunch_scripts'
23 assert_selector 'td a', text: 'hash'
25 assert_selector 'td a', text: 'crunch_scripts'
27 assert_text fakecommit
29 show_object_using 'active', 'jobs', 'running', sha1
31 assert_selector 'td a', text: 'crunch_scripts'
33 show_object_using 'active', 'jobs', 'running', sha1
35 assert_text fakecommit
38 test "browse using arv-git-http" do
39 repo = api_fixture('repositories')['foo']
41 File.expand_path('../../../../../tmp/arv-git-httpd-ssl.port', __FILE__)
42 gitsslport = File.read(portfile)
43 Repository.any_instance.
44 stubs(:http_fetch_url).
45 returns "https://localhost:#{gitsslport}/#{repo['name']}.git"
46 commit_sha1 = '1de84a854e2b440dc53bf42f8548afa4c17da332'
47 visit page_with_token('active', "/repositories/#{repo['uuid']}/commit/#{commit_sha1}")
48 assert_text "Date: Tue Mar 18 15:55:28 2014 -0400"
49 visit page_with_token('active', "/repositories/#{repo['uuid']}/tree/#{commit_sha1}")
50 assert_selector "tbody td a", "foo"
51 assert_text "12 bytes"