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 +4 -4
- data/lib/uncle/request.rb +6 -2
- data/lib/uncle/version.rb +1 -1
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/log/test.log +138 -0
- data/test/uncle_test.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b4cacd411915be33e1ecb0e1d76cb0887fe50ff
|
4
|
+
data.tar.gz: 1384c20c13aadad70f1c24442b6ebebd1f83194d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
47
|
-
|
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
data/test/dummy/config/routes.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2902
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2911
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
2917
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
2926
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2935
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2944
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
2952
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
2961
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2970
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2979
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2987
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
2996
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3005
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3014
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
3022
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
3031
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
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
|