3889: fix tests that were doing multiple actions in one test.
authorradhika <radhika@curoverse.com>
Thu, 25 Sep 2014 15:16:07 +0000 (11:16 -0400)
committerradhika <radhika@curoverse.com>
Thu, 25 Sep 2014 15:16:07 +0000 (11:16 -0400)
services/api/test/functional/arvados/v1/collections_controller_test.rb
services/api/test/functional/arvados/v1/links_controller_test.rb

index f2c15c656b3f2570adf211cd6fdb01222cf3bfb7..eb91e7def9cb1cc9e70a67080409d5ec5ae36b03 100644 (file)
@@ -104,17 +104,16 @@ EOS
     assert_response :success
     assert_nil assigns(:objects)
 
-    get :show, {
-      id: test_collection[:portable_data_hash]
-    }
-    assert_response :success
-    assert_not_nil assigns(:object)
-    resp = JSON.parse(@response.body)
-    assert_equal test_collection[:portable_data_hash], resp['portable_data_hash']
+    created = JSON.parse(@response.body)
+
+    retrieved_collection = Collection.select([:uuid, :portable_data_hash, :manifest_text]).
+      where(portable_data_hash: created['portable_data_hash']).first
+
+    assert_equal test_collection[:portable_data_hash], retrieved_collection['portable_data_hash']
 
     # The manifest in the response will have had permission hints added.
     # Remove any permission hints in the response before comparing it to the source.
-    stripped_manifest = resp['manifest_text'].gsub(/\+A[A-Za-z0-9@_-]+/, '')
+    stripped_manifest = retrieved_collection['manifest_text'].gsub(/\+A[A-Za-z0-9@_-]+/, '')
     assert_equal test_collection[:manifest_text], stripped_manifest
   end
 
index b4b78168f2444eb169d00c148bf076418f5830aa..4058101501684520ebc661c63b2d7ea0a030f4fc 100644 (file)
@@ -2,17 +2,21 @@ require 'test_helper'
 
 class Arvados::V1::LinksControllerTest < ActionController::TestCase
 
-  test "no symbol keys in serialized hash" do
-    link = {
-      properties: {username: 'testusername'},
-      link_class: 'test',
-      name: 'encoding',
-      tail_uuid: users(:admin).uuid,
-      head_uuid: virtual_machines(:testvm).uuid
-    }
-    authorize_with :admin
-    [link, link.to_json].each do |formatted_link|
-      post :create, link: formatted_link
+  ['link', 'link_json'].each do |formatted_link|
+    test "no symbol keys in serialized hash #{formatted_link}" do
+      link = {
+        properties: {username: 'testusername'},
+        link_class: 'test',
+        name: 'encoding',
+        tail_uuid: users(:admin).uuid,
+        head_uuid: virtual_machines(:testvm).uuid
+      }
+      authorize_with :admin
+      if formatted_link == 'link_json'
+        post :create, link: link.to_json
+      else
+        post :create, link: link
+      end
       assert_response :success
       assert_not_nil assigns(:object)
       assert_equal 'testusername', assigns(:object).properties['username']