From ef6972c6f0e42266220d3d256f69f817f559bf2c Mon Sep 17 00:00:00 2001 From: radhika Date: Thu, 25 Sep 2014 12:24:10 -0400 Subject: [PATCH] 3889: split test doing post and get requests into two different tests by using a fixture. --- services/api/test/fixtures/logs.yml | 9 +++++++++ .../functional/arvados/v1/logs_controller_test.rb | 11 ++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/services/api/test/fixtures/logs.yml b/services/api/test/fixtures/logs.yml index 15945cca3b..058c38772c 100644 --- a/services/api/test/fixtures/logs.yml +++ b/services/api/test/fixtures/logs.yml @@ -35,3 +35,12 @@ log5: # baz collection added, readable by active and spectator through group 'al object_uuid: zzzzz-4zz18-y9vne9npefyxh8g # baz file object_owner_uuid: zzzzz-tpzed-000000000000000 # system user event_at: <%= 5.minute.ago.to_s(:db) %> + +log_owned_by_active: + id: 6 + uuid: zzzzz-xxxxx-pshmckwoma12345 + owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz # active user + object_uuid: zzzzz-2x53u-382brsig8rp3667 # repository foo + object_owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz # active user + event_at: <%= 2.minute.ago.to_s(:db) %> + summary: non-admin use can read own logs 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..96daa5b227 100644 --- a/services/api/test/functional/arvados/v1/logs_controller_test.rb +++ b/services/api/test/functional/arvados/v1/logs_controller_test.rb @@ -3,15 +3,20 @@ 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"} assert_response :success uuid = JSON.parse(@response.body)['uuid'] assert_not_nil uuid - get :show, {id: uuid} + 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 load created log") - assert_equal("test log", assigns(:object).summary, + assert_equal(my_log[:summary], assigns(:object).summary, "loaded wrong log after creation") end -- 2.30.2