X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8e69317214ad56a6255f56725fa3b966c663eda3..d8616b7126de7e234b901b9bb166b5e4203da3c0:/services/api/test/functional/arvados/v1/logs_controller_test.rb diff --git a/services/api/test/functional/arvados/v1/logs_controller_test.rb b/services/api/test/functional/arvados/v1/logs_controller_test.rb index a224e2573f..475e7d6672 100644 --- a/services/api/test/functional/arvados/v1/logs_controller_test.rb +++ b/services/api/test/functional/arvados/v1/logs_controller_test.rb @@ -3,16 +3,22 @@ require 'test_helper' class Arvados::V1::LogsControllerTest < ActionController::TestCase fixtures :logs - test "non-admins can read their own logs" do + test "non-admins can create their own logs" do authorize_with :active - post :create, log: {summary: "test log"} + post :create, log: {summary: 'test log'} assert_response :success - uuid = JSON.parse(@response.body)['uuid'] - assert_not_nil uuid - get :show, {id: uuid} - assert_response(:success, "failed to load created log") - assert_equal("test log", assigns(:object).summary, - "loaded wrong log after creation") + resp = assigns(:object) + assert_not_nil resp.uuid + assert_equal('test log', resp.summary, "loaded wrong log after creation") + end + + test "non-admins can read their own logs" do + authorize_with :active + my_log = logs(:log_owned_by_active) + get :show, {id: my_log[:uuid]} + assert_response(:success, "failed to get log") + resp = assigns(:object) + assert_equal(my_log[:summary], resp.summary, "got wrong log") end test "test can still use where object_kind" do @@ -23,7 +29,7 @@ class Arvados::V1::LogsControllerTest < ActionController::TestCase assert_response :success found = assigns(:objects) assert_not_equal 0, found.count - assert_equal found.count, (found.select { |f| f.object_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count + assert_equal found.count, (found.select { |f| f.object_uuid.match User.uuid_regex }).count l = JSON.parse(@response.body) assert_equal 'arvados#user', l['items'][0]['object_kind'] end @@ -36,7 +42,7 @@ class Arvados::V1::LogsControllerTest < ActionController::TestCase assert_response :success found = assigns(:objects) assert_not_equal 0, found.count - assert_equal found.count, (found.select { |f| f.object_uuid.match /[a-z0-9]{5}-tpzed-[a-z0-9]{15}/}).count + assert_equal found.count, (found.select { |f| f.object_uuid.match User.uuid_regex }).count end end