3889: split test doing post and get requests into two different tests by using a...
authorradhika <radhika@curoverse.com>
Thu, 25 Sep 2014 16:24:10 +0000 (12:24 -0400)
committerradhika <radhika@curoverse.com>
Thu, 25 Sep 2014 16:24:10 +0000 (12:24 -0400)
services/api/test/fixtures/logs.yml
services/api/test/functional/arvados/v1/logs_controller_test.rb

index 15945cca3b1c0ee6a189e08909b39137f438ea19..058c38772cf017ceb4c67a4cf85f31324e16fc6a 100644 (file)
@@ -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
index a224e2573f4a30ccd49eb7c098f9acf186a42c18..96daa5b22747452e0eb788146d70f01cdeed9d2e 100644 (file)
@@ -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