jsonapi-resources 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonapi/resources/version.rb +1 -1
- data/lib/jsonapi/routing_ext.rb +6 -2
- data/test/fixtures/active_record.rb +41 -6
- data/test/integration/routes/routes_test.rb +5 -5
- data/test/test_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7b404cc6b45386898cdeda9754dae8c7cc993d0
|
4
|
+
data.tar.gz: db594be4a5815e815380940a43fde76d178daad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcaffc65ba5ad2cbf7fd70fa444b2bc97c05f973bd3056b15089af830bbfa7c9c53804aa130ba6de78370a45fdb064c7af193e81716f82dbe8f8dc7bc2df2ebf
|
7
|
+
data.tar.gz: 34f9f78a40732753b294470c0b6cb1ae6548bb726d573fec05b25fe27b1df6436dd48dab7f41e8818c880ecd4204282e2fa0f01ea1dc77d4338c3258fca1e0ba
|
data/lib/jsonapi/routing_ext.rb
CHANGED
@@ -45,7 +45,11 @@ module ActionDispatch
|
|
45
45
|
|
46
46
|
def jsonapi_resources(*resources, &block)
|
47
47
|
resource_type = resources.first
|
48
|
-
|
48
|
+
resource_type_with_module_prefix = [
|
49
|
+
@scope[:module],
|
50
|
+
resource_type
|
51
|
+
].compact.collect(&:to_s).join("/")
|
52
|
+
res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix)
|
49
53
|
|
50
54
|
options = resources.extract_options!.dup
|
51
55
|
options[:controller] ||= resource_type
|
@@ -146,4 +150,4 @@ module ActionDispatch
|
|
146
150
|
end
|
147
151
|
end
|
148
152
|
end
|
149
|
-
end
|
153
|
+
end
|
@@ -177,6 +177,9 @@ end
|
|
177
177
|
class Fact < ActiveRecord::Base
|
178
178
|
end
|
179
179
|
|
180
|
+
class Like < ActiveRecord::Base
|
181
|
+
end
|
182
|
+
|
180
183
|
class Breed
|
181
184
|
|
182
185
|
def initialize(id = nil, name = nil)
|
@@ -288,6 +291,9 @@ module Api
|
|
288
291
|
|
289
292
|
class MoonsController < JSONAPI::ResourceController
|
290
293
|
end
|
294
|
+
|
295
|
+
class LikesController < JSONAPI::ResourceController
|
296
|
+
end
|
291
297
|
end
|
292
298
|
|
293
299
|
module V2
|
@@ -553,6 +559,9 @@ module Api
|
|
553
559
|
filter :name
|
554
560
|
end
|
555
561
|
|
562
|
+
class LikeResource < JSONAPI::Resource
|
563
|
+
end
|
564
|
+
|
556
565
|
class PostResource < JSONAPI::Resource
|
557
566
|
# V1 no longer supports tags and now calls author 'writer'
|
558
567
|
attribute :id
|
@@ -570,23 +579,49 @@ module Api
|
|
570
579
|
|
571
580
|
filters :writer
|
572
581
|
end
|
582
|
+
|
583
|
+
AuthorResource = AuthorResource.dup
|
584
|
+
PersonResource = PersonResource.dup
|
585
|
+
CommentResource = CommentResource.dup
|
586
|
+
TagResource = TagResource.dup
|
587
|
+
SectionResource = SectionResource.dup
|
588
|
+
IsoCurrencyResource = IsoCurrencyResource.dup
|
589
|
+
ExpenseEntryResource = ExpenseEntryResource.dup
|
590
|
+
BreedResource = BreedResource.dup
|
591
|
+
PlanetResource = PlanetResource.dup
|
592
|
+
PlanetTypeResource = PlanetTypeResource.dup
|
593
|
+
MoonResource = MoonResource.dup
|
594
|
+
PreferencesResource = PreferencesResource.dup
|
573
595
|
end
|
574
596
|
end
|
575
597
|
|
576
598
|
module Api
|
577
599
|
module V2
|
578
|
-
|
579
|
-
|
600
|
+
PreferencesResource = PreferencesResource.dup
|
601
|
+
AuthorResource = AuthorResource.dup
|
602
|
+
PostResource = PostResource.dup
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
606
|
+
module Api
|
607
|
+
module V3
|
608
|
+
PostResource = PostResource.dup
|
580
609
|
end
|
581
610
|
end
|
582
611
|
|
583
612
|
module Api
|
584
613
|
module V4
|
585
|
-
|
586
|
-
|
614
|
+
PostResource = PostResource.dup
|
615
|
+
ExpenseEntryResource = ExpenseEntryResource.dup
|
616
|
+
IsoCurrencyResource = IsoCurrencyResource.dup
|
617
|
+
end
|
618
|
+
end
|
587
619
|
|
588
|
-
|
589
|
-
|
620
|
+
module Api
|
621
|
+
module V5
|
622
|
+
PostResource = PostResource.dup
|
623
|
+
ExpenseEntryResource = ExpenseEntryResource.dup
|
624
|
+
IsoCurrencyResource = IsoCurrencyResource.dup
|
590
625
|
end
|
591
626
|
end
|
592
627
|
|
@@ -84,9 +84,9 @@ class RoutesTest < ActionDispatch::IntegrationTest
|
|
84
84
|
{action: 'destroy', controller: 'api/v1/posts', id: '1'})
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
assert_routing({path: '/api/v1/posts/1/links/
|
89
|
-
{controller: 'api/v1/posts', action: 'show_association', post_id: '1', association: '
|
87
|
+
def test_routing_v1_posts_links_writer_show
|
88
|
+
assert_routing({path: '/api/v1/posts/1/links/writer', method: :get},
|
89
|
+
{controller: 'api/v1/posts', action: 'show_association', post_id: '1', association: 'writer'})
|
90
90
|
end
|
91
91
|
|
92
92
|
# V2
|
@@ -148,7 +148,7 @@ class RoutesTest < ActionDispatch::IntegrationTest
|
|
148
148
|
assert_routing({path: '/api/v5/expense-entries/1/links/iso-currency', method: :get},
|
149
149
|
{controller: 'api/v5/expense_entries', action: 'show_association', expense_entry_id: '1', association: 'iso_currency'})
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
#primary_key
|
153
153
|
def test_routing_primary_key_jsonapi_resources
|
154
154
|
assert_routing({path: '/iso_currencies/USD', method: :get},
|
@@ -173,4 +173,4 @@ class RoutesTest < ActionDispatch::IntegrationTest
|
|
173
173
|
|
174
174
|
# Test that non acts as set has_many association update route is not created
|
175
175
|
|
176
|
-
end
|
176
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Gebhardt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|