Merge branch '4523-owner_uuid-index' refs #4523
[arvados.git] / services / api / test / unit / application_test.rb
1 require 'test_helper'
2
3 class ApplicationTest < ActiveSupport::TestCase
4   include CurrentApiClient
5
6   test "test act_as_system_user" do
7     Thread.current[:user] = users(:active)
8     assert_equal users(:active), Thread.current[:user]
9     act_as_system_user do
10       assert_not_equal users(:active), Thread.current[:user]
11       assert_equal system_user, Thread.current[:user]
12     end
13     assert_equal users(:active), Thread.current[:user]
14   end
15
16   test "test act_as_system_user is exception safe" do
17     Thread.current[:user] = users(:active)
18     assert_equal users(:active), Thread.current[:user]
19     caught = false
20     begin
21       act_as_system_user do
22         assert_not_equal users(:active), Thread.current[:user]
23         assert_equal system_user, Thread.current[:user]
24         raise "Fail"
25       end
26     rescue
27       caught = true
28     end
29     assert caught
30     assert_equal users(:active), Thread.current[:user]
31   end
32 end