5737: Merge branch 'master' into 5737-ruby231
[arvados.git] / apps / workbench / test / integration / repositories_browse_test.rb
1 require 'integration_helper'
2 require 'helpers/repository_stub_helper'
3 require 'helpers/share_object_helper'
4
5 class RepositoriesTest < ActionDispatch::IntegrationTest
6   include RepositoryStubHelper
7   include ShareObjectHelper
8
9   reset_api_fixtures :after_each_test, false
10
11   setup do
12     need_javascript
13   end
14
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']
21     assert_text fakefile
22     click_on 'crunch_scripts'
23     assert_selector 'td a', text: 'hash'
24     click_on 'foo'
25     assert_selector 'td a', text: 'crunch_scripts'
26     click_on sha1
27     assert_text fakecommit
28
29     show_object_using 'active', 'jobs', 'running', sha1
30     click_on 'active/foo'
31     assert_selector 'td a', text: 'crunch_scripts'
32
33     show_object_using 'active', 'jobs', 'running', sha1
34     click_on sha1
35     assert_text fakecommit
36   end
37
38   test "browse using arv-git-http" do
39     repo = api_fixture('repositories')['foo']
40     portfile =
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"
52   end
53 end