[ARVADOS] updated: 3ea6744bcf9cc4812ab24913286c3bc8e123b76a

git at public.curoverse.com git at public.curoverse.com
Fri May 2 19:45:30 EDT 2014


Summary of changes:
 apps/workbench/app/models/arvados_resource_list.rb |   11 ++++++++---
 .../test/unit/arvados_resource_list_test.rb        |   20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 apps/workbench/test/unit/arvados_resource_list_test.rb

       via  3ea6744bcf9cc4812ab24913286c3bc8e123b76a (commit)
       via  af3a38d81374f70d15134813563b7371e8e4127c (commit)
      from  bcc477ed88c04b3200a70d16f1fc99da11c670f8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 3ea6744bcf9cc4812ab24913286c3bc8e123b76a
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 19:45:16 2014 -0400

    Return all links if link_class is not provided. Add docs.

diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb
index f0a1641..258aa44 100644
--- a/apps/workbench/app/models/arvados_resource_list.rb
+++ b/apps/workbench/app/models/arvados_resource_list.rb
@@ -138,7 +138,11 @@ class ArvadosResourceList
     results.links if results.respond_to? :links
   end
 
-  def links_for item_or_uuid, link_class=nil
+  # Return links provided with API response that point to the
+  # specified object, and have the specified link_class. If link_class
+  # is false or omitted, return all links pointing to the specified
+  # object.
+  def links_for item_or_uuid, link_class=false
     return [] if !result_links
     unless @links_for_uuid
       @links_for_uuid = {}
@@ -155,7 +159,7 @@ class ArvadosResourceList
       uuid = item_or_uuid
     end
     (@links_for_uuid[uuid] || []).select do |link|
-      link.link_class == link_class
+      link_class == false or link.link_class == link_class
     end
   end
 

commit af3a38d81374f70d15134813563b7371e8e4127c
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri May 2 19:41:23 2014 -0400

    Return empty list if no "links" supplied in api response. Add tests.

diff --git a/apps/workbench/app/models/arvados_resource_list.rb b/apps/workbench/app/models/arvados_resource_list.rb
index 329033f..f0a1641 100644
--- a/apps/workbench/app/models/arvados_resource_list.rb
+++ b/apps/workbench/app/models/arvados_resource_list.rb
@@ -139,9 +139,10 @@ class ArvadosResourceList
   end
 
   def links_for item_or_uuid, link_class=nil
+    return [] if !result_links
     unless @links_for_uuid
       @links_for_uuid = {}
-      results.links.each do |link|
+      result_links.each do |link|
         if link.respond_to? :head_uuid
           @links_for_uuid[link.head_uuid] ||= []
           @links_for_uuid[link.head_uuid] << link
diff --git a/apps/workbench/test/unit/arvados_resource_list_test.rb b/apps/workbench/test/unit/arvados_resource_list_test.rb
new file mode 100644
index 0000000..4ce6741
--- /dev/null
+++ b/apps/workbench/test/unit/arvados_resource_list_test.rb
@@ -0,0 +1,20 @@
+require 'test_helper'
+
+class ResourceListTest < ActiveSupport::TestCase
+
+  test 'links_for on a resource list that does not return links' do
+    use_token :active
+    results = Specimen.all
+    assert_equal [], results.links_for(api_fixture('users')['active']['uuid'])
+  end
+
+  test 'links_for on non-empty resource list' do
+    use_token :active
+    results = Group.find(api_fixture('groups')['afolder']['uuid']).contents(include_linked: true)
+    assert_equal [], results.links_for(api_fixture('users')['active']['uuid'])
+    assert_equal [], results.links_for(api_fixture('jobs')['running_cancelled']['uuid'])
+    assert_equal [], results.links_for(api_fixture('jobs')['running']['uuid'], 'bogus-link-class')
+    assert_equal true, results.links_for(api_fixture('jobs')['running']['uuid'], 'name').any?
+  end
+
+end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list