From 36975ebf86c37148ef38a5facd10fad2a977efc9 Mon Sep 17 00:00:00 2001 From: radhika Date: Thu, 25 Sep 2014 11:16:07 -0400 Subject: [PATCH] 3889: fix tests that were doing multiple actions in one test. --- .../arvados/v1/collections_controller_test.rb | 15 +++++------ .../arvados/v1/links_controller_test.rb | 26 +++++++++++-------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb index f2c15c656b..eb91e7def9 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -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 diff --git a/services/api/test/functional/arvados/v1/links_controller_test.rb b/services/api/test/functional/arvados/v1/links_controller_test.rb index b4b78168f2..4058101501 100644 --- a/services/api/test/functional/arvados/v1/links_controller_test.rb +++ b/services/api/test/functional/arvados/v1/links_controller_test.rb @@ -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'] -- 2.39.5