json_api_test_helpers 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8426114ccff33ae5db1ecf0cedcac9a3d6eb8c50d7af2d690271a943c60ca6b
4
- data.tar.gz: 13afcc8aac13cb0d0450d2814b4b5526158558507dc103b04f13540bde8e38a5
3
+ metadata.gz: 7049d95423c1b890bc7682de2f30aa6db778526efc22e4598f5d99bbca22c528
4
+ data.tar.gz: fed032e89f35c31a30e52f9c1940e1924225e230e6032db949577d94e47d8bc5
5
5
  SHA512:
6
- metadata.gz: 363c1fb6cce348f7456c4caa56c820a280771b335b0f6be3032543ab617b149c05de1312028216e9e3a6bf3265ffb0c1e5937868478b849a532a3dbd120ba339
7
- data.tar.gz: 3f736067be421d041e32d465a5c9d48d0b27ffb608c2028119a303eb047ba616bf95aabc19cbcb9709bc8ef456fd3010b18295c5f448b057ffef6d148054edec
6
+ metadata.gz: 40db80329ad03c43ef159dcecfeb8909760a72e53794dab345c1259b2b566f073f7ae718900a602ea488e600b47277cc96c1d7dbb1d57fb6e17897fcedb537f2
7
+ data.tar.gz: a32d7c16a93ff291a2f9472823248bb1b7f69d55a45aad745dd255beafa78e981acc96194696002d9a2a4f2c0525322222588e772d5d293b933d133ce09e42f1
data/README.md CHANGED
@@ -27,6 +27,7 @@ Methods:
27
27
  | json_response | | Returns parsed `response.body` as Hash with indifferent access or Array |
28
28
  | json_api_record | `record`, `attributes`, `relationships: nil`, `additional: nil`| Returns Hash in JSON API format with serialized object |
29
29
  | json_api_collection | `collection`, `attributes = nil`, `relationships: nil` | Returns Hash in JSON API format with serialized array |
30
+ | json_api_relationships | `record`, `relationships` | Returns Hash of the record's relationships. When `relationships` argument is Array, all releations have name same as model class names. When it's Hash { relationship_name => class_name } |
30
31
  | fix_value_for_json | `value` | Fix values which are usually used in Rails apps. `DateTime`, `ActiveSupport::TimeWithZone` to `iso8601`; `CarrierWave::Uploader::Serialization` to `serializable_hash`; everything else to Hash with replaced underscores `_` to minus `-` in attribute names |
31
32
  | fix_comparing_types | `value` | Fix type value to easy compare. `DateTime`, `ActiveSupport::TimeWithZone` to `datetime` with UTC; `ActiveRecord::Point` to string `"#{value.x}, #{value.y}"`. |
32
33
  | attributes_for_nested | `attributes`, `**associations` | Merge `attributes` with associations with JSON API format |
@@ -39,6 +40,8 @@ expect(json_response).to include_json(json_api_record(User.first, [ :email, :ano
39
40
 
40
41
  expect(json_response).to include_json(json_api_collection(User.all))
41
42
 
43
+ expect(json_response).to include_json(json_api_relationships(user, posts: :user_posts))
44
+
42
45
  post 'some_post', params: json_api_params({ attribute1: :value1, attribute2: :value2 })
43
46
  ```
44
47
 
@@ -12,7 +12,7 @@ module JsonApiTestHelpers
12
12
  def json_api_record(record, attributes, relationships: nil, additional: nil)
13
13
  json = {
14
14
  'data' => {
15
- 'id' => record.id.to_s,
15
+ 'id' => record.uuid,
16
16
  'attributes' => json_api_record_attributes(record, attributes)
17
17
  }
18
18
  }
@@ -24,7 +24,7 @@ module JsonApiTestHelpers
24
24
  {
25
25
  'data' => collection.map do |record|
26
26
  hash = {
27
- 'id' => record.id.to_s
27
+ 'id' => record.uuid
28
28
  }
29
29
  hash['attributes'] = json_api_record_attributes(record, attributes) if attributes
30
30
  hash['relationships'] = json_api_relationships(record, relationships) if relationships
@@ -92,7 +92,7 @@ module JsonApiTestHelpers
92
92
 
93
93
  def data_relationship_object(object, relationship)
94
94
  {
95
- 'id' => object.id.to_s,
95
+ 'id' => object.uuid,
96
96
  'type' => json_api_model_name(relationship).pluralize
97
97
  }
98
98
  end
@@ -1,3 +1,3 @@
1
1
  module JsonApiTestHelpers
2
- VERSION = '1.2'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_api_test_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-12 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler