uncle 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 336be1f9d0b34f0d33084cf21907b845aaf0428a
4
- data.tar.gz: 1937bad55cb10178520575b5782201ff1c249b73
3
+ metadata.gz: 5b4cacd411915be33e1ecb0e1d76cb0887fe50ff
4
+ data.tar.gz: 1384c20c13aadad70f1c24442b6ebebd1f83194d
5
5
  SHA512:
6
- metadata.gz: 4ec38753e03f0d585ae533245fa59f310b9b38849a065d181451ee45cc9a10b854085471d5bb6407fa17ff7a2403e84c3d64f0dc09f63c3ad62700e3aab499f1
7
- data.tar.gz: 8baa9240f8661d4b8338737f47e5fa261880746c8cf3a674c9b06cac24e72d8e0ab93fc34466fa404de91883170107e0a99c4f1f38646479c74a9c3a58e04f57
6
+ metadata.gz: 34a8a5b927803aaf1b61e78dd4f62de74c28c541949f1b42acd3eb653f8d4b81a55a6009d9c6ddfe16fb351e761a1f9cd46ed2cf55ad83a2a1532b82a5dcf016
7
+ data.tar.gz: fd3870593f469753ca923b044397fcb80274be3606364d3cb8dc83f3602b9e86891f223690c675415c8dd0c16ca253f9c3ae1162822d1f6f44bac01846d47494
data/lib/uncle/request.rb CHANGED
@@ -43,8 +43,12 @@ module Uncle
43
43
 
44
44
  def child_resource_nodes
45
45
  @child_resource_nodes ||= begin
46
- nodes = node_for_path(request.path).siblings
47
- node = nodes.detect { |c| c.key == ":#{resource_name}_id" }
46
+ node = node_for_path(request.path)
47
+
48
+ if node.parent
49
+ nodes = node.parent.children
50
+ node = nodes.detect { |c| c.key == ":#{resource_name}_id" }
51
+ end
48
52
 
49
53
  node.children
50
54
  end
data/lib/uncle/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uncle
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,4 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
+ root 'widgets#show'
3
+
2
4
  resources :widgets, except: %i<new edit> do
3
5
  resources :gizmos, except: %i<new edit>
4
6
  resources :doo_dads, except: %i<new edit>
@@ -2895,6 +2895,144 @@ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2895
2895
  UncleTest: test_returning_the_parent_resource_from_a_resource_instance
2896
2896
  ----------------------------------------------------------------------
2897
2897
  Started GET "/thingies/1" for 127.0.0.1 at 2014-04-13 21:14:25 +0100
2898
+ Processing by ThingiesController#show as HTML
2899
+ Parameters: {"id"=>"1"}
2900
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2901
+  (0.1ms) rollback transaction
2902
+  (0.1ms) begin transaction
2903
+ ----------------------------------------------------------------------
2904
+ UncleTest: test_returning_the_child_resources_from_a_resource_instance
2905
+ ----------------------------------------------------------------------
2906
+ Started GET "/widgets/1" for 127.0.0.1 at 2014-04-14 02:20:38 +0100
2907
+ Processing by WidgetsController#show as HTML
2908
+ Parameters: {"id"=>"1"}
2909
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
2910
+  (0.1ms) rollback transaction
2911
+  (0.1ms) begin transaction
2912
+ ----------------------------------------------------------------
2913
+ UncleTest: test_returning_the_child_resources_from_the_root_path
2914
+ ----------------------------------------------------------------
2915
+ Started GET "/" for 127.0.0.1 at 2014-04-14 02:20:38 +0100
2916
+  (0.0ms) rollback transaction
2917
+  (0.0ms) begin transaction
2918
+ ------------------------------------------------------------------------
2919
+ UncleTest: test_returning_the_parent_resource_from_a_collection_resource
2920
+ ------------------------------------------------------------------------
2921
+ Started GET "/widgets/1/gizmos" for 127.0.0.1 at 2014-04-14 02:20:38 +0100
2922
+ Processing by GizmosController#index as HTML
2923
+ Parameters: {"widget_id"=>"1"}
2924
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2925
+  (0.0ms) rollback transaction
2926
+  (0.0ms) begin transaction
2927
+ ----------------------------------------------------------------------
2928
+ UncleTest: test_returning_the_parent_resource_from_a_resource_instance
2929
+ ----------------------------------------------------------------------
2930
+ Started GET "/thingies/1" for 127.0.0.1 at 2014-04-14 02:20:38 +0100
2931
+ Processing by ThingiesController#show as HTML
2932
+ Parameters: {"id"=>"1"}
2933
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
2934
+  (0.1ms) rollback transaction
2935
+  (0.1ms) begin transaction
2936
+ ----------------------------------------------------------------------
2937
+ UncleTest: test_returning_the_child_resources_from_a_resource_instance
2938
+ ----------------------------------------------------------------------
2939
+ Started GET "/widgets/1" for 127.0.0.1 at 2014-04-14 02:21:46 +0100
2940
+ Processing by WidgetsController#show as HTML
2941
+ Parameters: {"id"=>"1"}
2942
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
2943
+  (0.1ms) rollback transaction
2944
+  (0.0ms) begin transaction
2945
+ ----------------------------------------------------------------
2946
+ UncleTest: test_returning_the_child_resources_from_the_root_path
2947
+ ----------------------------------------------------------------
2948
+ Started GET "/" for 127.0.0.1 at 2014-04-14 02:21:46 +0100
2949
+ Processing by WidgetsController#show as HTML
2950
+ Completed 500 Internal Server Error in 0ms
2951
+  (0.0ms) rollback transaction
2952
+  (0.0ms) begin transaction
2953
+ ------------------------------------------------------------------------
2954
+ UncleTest: test_returning_the_parent_resource_from_a_collection_resource
2955
+ ------------------------------------------------------------------------
2956
+ Started GET "/widgets/1/gizmos" for 127.0.0.1 at 2014-04-14 02:21:46 +0100
2957
+ Processing by GizmosController#index as HTML
2958
+ Parameters: {"widget_id"=>"1"}
2959
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2960
+  (0.0ms) rollback transaction
2961
+  (0.0ms) begin transaction
2962
+ ----------------------------------------------------------------------
2963
+ UncleTest: test_returning_the_parent_resource_from_a_resource_instance
2964
+ ----------------------------------------------------------------------
2965
+ Started GET "/thingies/1" for 127.0.0.1 at 2014-04-14 02:21:46 +0100
2966
+ Processing by ThingiesController#show as HTML
2967
+ Parameters: {"id"=>"1"}
2968
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2969
+  (0.1ms) rollback transaction
2970
+  (0.1ms) begin transaction
2971
+ ----------------------------------------------------------------------
2972
+ UncleTest: test_returning_the_child_resources_from_a_resource_instance
2973
+ ----------------------------------------------------------------------
2974
+ Started GET "/widgets/1" for 127.0.0.1 at 2014-04-14 02:26:20 +0100
2975
+ Processing by WidgetsController#show as HTML
2976
+ Parameters: {"id"=>"1"}
2977
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
2978
+  (0.1ms) rollback transaction
2979
+  (0.0ms) begin transaction
2980
+ ----------------------------------------------------------------
2981
+ UncleTest: test_returning_the_child_resources_from_the_root_path
2982
+ ----------------------------------------------------------------
2983
+ Started GET "/" for 127.0.0.1 at 2014-04-14 02:26:20 +0100
2984
+ Processing by WidgetsController#show as HTML
2985
+ Completed 500 Internal Server Error in 0ms
2986
+  (0.1ms) rollback transaction
2987
+  (0.0ms) begin transaction
2988
+ ------------------------------------------------------------------------
2989
+ UncleTest: test_returning_the_parent_resource_from_a_collection_resource
2990
+ ------------------------------------------------------------------------
2991
+ Started GET "/widgets/1/gizmos" for 127.0.0.1 at 2014-04-14 02:26:20 +0100
2992
+ Processing by GizmosController#index as HTML
2993
+ Parameters: {"widget_id"=>"1"}
2994
+ Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)
2995
+  (0.1ms) rollback transaction
2996
+  (0.1ms) begin transaction
2997
+ ----------------------------------------------------------------------
2998
+ UncleTest: test_returning_the_parent_resource_from_a_resource_instance
2999
+ ----------------------------------------------------------------------
3000
+ Started GET "/thingies/1" for 127.0.0.1 at 2014-04-14 02:26:20 +0100
3001
+ Processing by ThingiesController#show as HTML
3002
+ Parameters: {"id"=>"1"}
3003
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
3004
+  (0.1ms) rollback transaction
3005
+  (0.1ms) begin transaction
3006
+ ----------------------------------------------------------------------
3007
+ UncleTest: test_returning_the_child_resources_from_a_resource_instance
3008
+ ----------------------------------------------------------------------
3009
+ Started GET "/widgets/1" for 127.0.0.1 at 2014-04-14 02:28:12 +0100
3010
+ Processing by WidgetsController#show as HTML
3011
+ Parameters: {"id"=>"1"}
3012
+ Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
3013
+  (0.1ms) rollback transaction
3014
+  (0.0ms) begin transaction
3015
+ ----------------------------------------------------------------
3016
+ UncleTest: test_returning_the_child_resources_from_the_root_path
3017
+ ----------------------------------------------------------------
3018
+ Started GET "/" for 127.0.0.1 at 2014-04-14 02:28:12 +0100
3019
+ Processing by WidgetsController#show as HTML
3020
+ Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
3021
+  (0.2ms) rollback transaction
3022
+  (0.1ms) begin transaction
3023
+ ------------------------------------------------------------------------
3024
+ UncleTest: test_returning_the_parent_resource_from_a_collection_resource
3025
+ ------------------------------------------------------------------------
3026
+ Started GET "/widgets/1/gizmos" for 127.0.0.1 at 2014-04-14 02:28:12 +0100
3027
+ Processing by GizmosController#index as HTML
3028
+ Parameters: {"widget_id"=>"1"}
3029
+ Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms)
3030
+  (0.1ms) rollback transaction
3031
+  (0.1ms) begin transaction
3032
+ ----------------------------------------------------------------------
3033
+ UncleTest: test_returning_the_parent_resource_from_a_resource_instance
3034
+ ----------------------------------------------------------------------
3035
+ Started GET "/thingies/1" for 127.0.0.1 at 2014-04-14 02:28:12 +0100
2898
3036
  Processing by ThingiesController#show as HTML
2899
3037
  Parameters: {"id"=>"1"}
2900
3038
  Completed 200 OK in 0ms (Views: 0.1ms | ActiveRecord: 0.0ms)
data/test/uncle_test.rb CHANGED
@@ -33,4 +33,15 @@ class UncleTest < ActiveSupport::TestCase
33
33
 
34
34
  assert_equal child_resources, JSON.parse(last_response.body)
35
35
  end
36
+
37
+ test 'returning the child resources from the root path' do
38
+ get '/'
39
+
40
+ child_resources = {
41
+ 'widgets' => 'http://example.org/widgets',
42
+ 'thingies' => 'http://example.org/thingies'
43
+ }
44
+
45
+ assert_equal child_resources, JSON.parse(last_response.body)
46
+ end
36
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uncle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stevie Graham