graphiti_spec_helpers 1.0.beta.2 → 1.0.beta.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: e7095bf2af571aa4b426e9b07bea5f0f26d4f390
4
- data.tar.gz: e584b7e854475c313b7f96e696d82363d8c659d0
3
+ metadata.gz: 2df5b0a708725d2778698aad13eef534b1ab9ba7
4
+ data.tar.gz: 2b701facab45ac164f83b8e921733ee1a6d04844
5
5
  SHA512:
6
- metadata.gz: 67b30ea26482856e57fd72bfac1792f08d8f49ce422a2952ada481e284c68f8a64830d0f9aa93b230b6cd134181bd5f2bbfb8b8bb1ee48f27578fb12dbb4de21
7
- data.tar.gz: 31f4ded38c3d4c1861ee039e12924deba795da859189bf1c1c81c9625825664e776b2f53468f3a643e1081a7f85531f03d28ed733dd765985073040537c2e9c4
6
+ metadata.gz: d9ff8d1a4e779c7f367150ce1c2e6e2e786fce38ae7f403ceecf77c32ca9d1c8ffabaadc4350f86b7e0361927e160d6923054dca6629c557a4536fc5cf6c5190
7
+ data.tar.gz: 75c3bc6db8ea9d18a1c688faa2c50ebe70d72556f348899885c94ed0c2a9092bf2c40a8af15bef08f665b0d82416fb2d073d77cba7dcb0b67ff8db577dff04ad
@@ -4,7 +4,7 @@ module GraphitiSpecHelpers
4
4
 
5
5
  def initialize(attributes, relationships, context)
6
6
  @attributes = attributes.with_indifferent_access
7
- @relationships = relationships
7
+ @relationships = relationships.with_indifferent_access if relationships
8
8
  @context = context
9
9
  end
10
10
 
@@ -72,8 +72,8 @@ module GraphitiSpecHelpers
72
72
  private
73
73
 
74
74
  def include_for(type, id)
75
- data = @context.json[:included].find do |i|
76
- i[:type] == type && i[:id] == id
75
+ data = @context.json['included'].find do |i|
76
+ i['type'] == type && i['id'] == id
77
77
  end
78
78
  @context.node(from: data)
79
79
  end
@@ -8,12 +8,21 @@ require 'graphiti_spec_helpers'
8
8
  begin
9
9
  original = Graphiti::Resource.validate_endpoints
10
10
  Graphiti::Resource.validate_endpoints = false
11
- e.run
11
+
12
+ Graphiti.with_context graphiti_context do
13
+ e.run
14
+ end
12
15
  ensure
13
16
  Graphiti::Resource.validate_endpoints = original
14
17
  end
15
18
  end
16
19
 
20
+ def graphiti_context
21
+ ctx = OpenStruct.new
22
+ ctx.current_user = current_user if respond_to?(:current_user)
23
+ ctx
24
+ end
25
+
17
26
  # If you need to set context:
18
27
  #
19
28
  # Graphiti.with_context my_context, {} do
@@ -1,3 +1,3 @@
1
1
  module GraphitiSpecHelpers
2
- VERSION = "1.0.beta.2"
2
+ VERSION = "1.0.beta.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphiti_spec_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.beta.2
4
+ version: 1.0.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphiti
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: 1.3.1
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.6.12
156
+ rubygems_version: 2.6.13
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Spec helpers for Graphiti and JSONAPI