Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / apps / workbench / test / controllers / actions_controller_test.rb
1 require 'test_helper'
2
3 class ActionsControllerTest < ActionController::TestCase
4
5   test "send report" do
6     post :report_issue, {format: 'js'}, session_for(:admin)
7     assert_response :success
8
9     found_email = false
10     ActionMailer::Base.deliveries.andand.each do |email|
11       if email.subject.include? "Issue reported by admin"
12         found_email = true
13         break
14       end
15     end
16     assert_equal true, found_email, 'Expected email after issue reported'
17   end
18
19   test "combine files into new collection" do
20     post(:combine_selected_files_into_collection, {
21            selection: ['zzzzz-4zz18-znfnqtbbv4spc3w/foo',
22                        'zzzzz-4zz18-ehbhgtheo8909or/bar',
23                        'zzzzz-4zz18-y9vne9npefyxh8g/baz',
24                        '1fd08fc162a5c6413070a8bd0bffc818+150'],
25            format: "json"},
26          session_for(:active))
27
28     assert_response 302   # collection created and redirected to new collection page
29
30     assert response.headers['Location'].include? '/collections/'
31     new_collection_uuid = response.headers['Location'].split('/')[-1]
32
33     use_token :active
34     collection = Collection.select([:uuid, :manifest_text]).where(uuid: new_collection_uuid).first
35     manifest_text = collection['manifest_text']
36     assert manifest_text.include?('foo'), 'Not found foo in new collection manifest text'
37     assert manifest_text.include?('bar'), 'Not found bar in new collection manifest text'
38     assert manifest_text.include?('baz'), 'Not found baz in new collection manifest text'
39     assert manifest_text.include?('0:0:file1 0:0:file2 0:0:file3'),
40                 'Not found 0:0:file1 0:0:file2 0:0:file3 in new collection manifest text'
41     assert manifest_text.include?('dir1/subdir'), 'Not found dir1/subdir in new collection manifest text'
42     assert manifest_text.include?('dir2'), 'Not found dir2 in new collection manifest text'
43   end
44
45 end