simple_jsonapi_rails 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -3
- data/lib/simple_jsonapi/rails/extensions/routing.rb +2 -1
- data/lib/simple_jsonapi/rails/version.rb +1 -1
- data/simple_jsonapi_rails.gemspec +1 -0
- data/test/action_controller_test.rb +5 -0
- data/test/test_helper.rb +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54156ceb047d874781ddfed03c156591ad715c50
|
4
|
+
data.tar.gz: 8d16312de66be3a1f767c522f8cee3345274ee8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a985a3712fd7da77b28cc4a1b8f536ca7914127fc8d70bf2e280d7ab33071738896ab18a8715ac894e668b01eb56ed98aa552dd2d640e620f481ef954af7a3
|
7
|
+
data.tar.gz: 6fd49421b5c11edf2b38a1b9f60c712d1ca4a9b08e450ad5c403421fe69ce3249c27cc95f37f62544351825454265d7bb0648f42cd170a623b12e339b4158951
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SimpleJsonapi/Rails
|
2
2
|
|
3
|
-
A library for integrating SimpleJsonapi into a Rails application.
|
3
|
+
A library for integrating [SimpleJsonapi](https://github.com/patientslikeme/simple_jsonapi) into a Rails application.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -66,7 +66,7 @@ end
|
|
66
66
|
|
67
67
|
### Create and update actions
|
68
68
|
|
69
|
-
Incoming JSON
|
69
|
+
Incoming JSON API documents can be parsed into a more Rails-friendly structure by calling **`jsonapi_deserialize`** in the controller class.
|
70
70
|
|
71
71
|
`jsonapi_deserialize` converts this incoming document ...
|
72
72
|
|
@@ -209,6 +209,7 @@ The `Accept` header, if it present, must also be set to `application/vnd+api.jso
|
|
209
209
|
returned with status 406 Not Acceptable.
|
210
210
|
|
211
211
|
## Routing
|
212
|
+
|
212
213
|
Rails' route mapper works well for most jsonapi resource routes. However, simple_jsonapi_rails does supply helpers method
|
213
214
|
for defining relationship routes, which can be trickier:
|
214
215
|
|
@@ -225,6 +226,7 @@ This code generates the following paths and routes/controller action mappings.
|
|
225
226
|
orders_relationships_items POST /orders/:order_id/relationships/items(.:format) orders/relationships/items#add
|
226
227
|
orders_relationships_items DELETE /orders/:order_id/relationships/items(.:format) orders/relationships/items#remove
|
227
228
|
orders_relationships_items PATCH /orders/:order_id/relationships/items(.:format) orders/relationships/items#replace
|
229
|
+
orders_relationships_items GET /orders/:order_id/relationships/items(.:format) orders/relationships/items#fetch
|
228
230
|
|
229
231
|
orders_relationships_customer PATCH /orders/:order_id/customer(.:format) orders/relationships/customer#replace
|
230
232
|
|
@@ -242,4 +244,3 @@ Once pull request is merged to master, on latest master:
|
|
242
244
|
compatible release) | minor (new features) | patch (bugfixes) ]
|
243
245
|
2. Update version in lib/global_enforcer/version.rb
|
244
246
|
3. Release by running `bundle exec rake release`
|
245
|
-
|
@@ -5,6 +5,7 @@ module SimpleJsonapi
|
|
5
5
|
add: :create,
|
6
6
|
remove: :destroy,
|
7
7
|
replace: :update,
|
8
|
+
fetch: :show,
|
8
9
|
}.freeze
|
9
10
|
|
10
11
|
SUPPORTED_TO_MANY_ACTIONS = ACTION_MAP.keys.freeze
|
@@ -47,7 +48,7 @@ module SimpleJsonapi
|
|
47
48
|
|
48
49
|
def ensure_actions_supported(actions)
|
49
50
|
if actions.any? { |action| SUPPORTED_TO_MANY_ACTIONS.exclude?(action) }
|
50
|
-
raise ArgumentError, "#jsonapi_to_many_relationship supports :add, :remove, and :
|
51
|
+
raise ArgumentError, "#jsonapi_to_many_relationship supports :add, :remove, :replace, and :fetch actions"
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency 'simple_jsonapi'
|
22
22
|
spec.add_runtime_dependency 'rails', '>= 4.2', '< 6.0'
|
23
23
|
|
24
|
+
spec.add_development_dependency 'rails', '~> 5.1.0'
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
26
|
spec.add_development_dependency 'listen'
|
26
27
|
spec.add_development_dependency 'minitest'
|
@@ -235,6 +235,11 @@ class ActionControllerTest < ActionDispatch::IntegrationTest
|
|
235
235
|
controller: "orders/relationships/items",
|
236
236
|
action: "replace",
|
237
237
|
id: 1
|
238
|
+
|
239
|
+
assert_generates "orders/1/relationships/items",
|
240
|
+
controller: "orders/relationships/items",
|
241
|
+
action: "fetch",
|
242
|
+
id: 1
|
238
243
|
end
|
239
244
|
|
240
245
|
it "generates the correct path helpers" do
|
data/test/test_helper.rb
CHANGED
@@ -3,6 +3,8 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
# Set up the dummy app
|
4
4
|
ENV['RAILS_ENV'] = 'test'
|
5
5
|
require_relative 'dummy/config/environment'
|
6
|
+
# change to ActiveRecord::MigrationContext.new(File.expand_path("dummy/db/migrate/", __dir__)).migrate
|
7
|
+
# when we upgrade rails >= 5.2.0
|
6
8
|
ActiveRecord::Migrator.migrate File.expand_path("dummy/db/migrate/", __dir__)
|
7
9
|
|
8
10
|
require 'active_support'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_jsonapi_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PatientsLikeMe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_jsonapi
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 5.1.0
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 5.1.0
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: bundler
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|