Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / services / api / test / functional / arvados / v1 / logs_controller_test.rb
1 require 'test_helper'
2
3 class Arvados::V1::LogsControllerTest < ActionController::TestCase
4   fixtures :logs
5
6   test "non-admins can read their own logs" do
7     authorize_with :active
8     post :create, log: {summary: "test log"}
9     assert_response :success
10     uuid = JSON.parse(@response.body)['uuid']
11     assert_not_nil uuid
12     get :show, {id: uuid}
13     assert_response(:success, "failed to load created log")
14     assert_equal("test log", assigns(:object).summary,
15                  "loaded wrong log after creation")
16   end
17
18   test "test can still use where object_kind" do
19     authorize_with :admin
20     get :index, {
21       where: { object_kind: 'arvados#user' }
22     }
23     assert_response :success
24     found = assigns(:objects)
25     assert_not_equal 0, found.count
26     assert_equal found.count, (found.select { |f| f.object_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count
27     l = JSON.parse(@response.body)
28     assert_equal 'arvados#user', l['items'][0]['object_kind']
29   end
30
31   test "test can still use filter object_kind" do
32     authorize_with :admin
33     get :index, {
34       filters: [ ['object_kind', '=', 'arvados#user'] ]
35     }
36     assert_response :success
37     found = assigns(:objects)
38     assert_not_equal 0, found.count
39     assert_equal found.count, (found.select { |f| f.object_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count
40   end
41
42 end