closes #3821
[arvados.git] / apps / workbench / test / controllers / container_requests_controller_test.rb
1 require 'test_helper'
2
3 class ContainerRequestsControllerTest < ActionController::TestCase
4   test "visit completed container request log tab" do
5     use_token 'active'
6
7     cr = api_fixture('container_requests')['completed']
8     container_uuid = cr['container_uuid']
9     container = Container.find(container_uuid)
10
11     get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
12     assert_response :success
13
14     assert_select "a", {:href=>"/collections/#{container['log']}", :text=>"Download the log"}
15     assert_select "a", {:href=>"#{container['log']}/baz"}
16     assert_not_includes @response.body, '<div id="event_log_div"'
17   end
18
19   test "visit running container request log tab" do
20     use_token 'active'
21
22     cr = api_fixture('container_requests')['running']
23     container_uuid = cr['container_uuid']
24     container = Container.find(container_uuid)
25
26     get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
27     assert_response :success
28
29     assert_includes @response.body, '<div id="event_log_div"'
30     assert_select 'Download the log', false
31   end
32
33   test "completed container request offers re-run option" do
34     use_token 'active'
35
36     uuid = api_fixture('container_requests')['completed']['uuid']
37
38     get :show, {id: uuid}, session_for(:active)
39     assert_response :success
40
41    assert_includes @response.body, "href=\"/container_requests/#{uuid}/copy\""
42   end
43
44   test "container request copy" do
45     completed_cr = api_fixture('container_requests')['completed']
46     post(:copy,
47          {
48            id: completed_cr['uuid']
49          },
50          session_for(:active))
51     assert_response 302
52     copied_cr = assigns(:object)
53     assert_not_nil copied_cr
54     assert_equal 'Uncommitted', copied_cr[:state]
55     assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
56     assert_equal completed_cr['cmd'], copied_cr['cmd']
57     assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
58   end
59 end