quilt_rails 3.4.1 → 3.5.2

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: 0a6933fd12f6ae25d25f4afab855ba022287ac3c2e353d3b1d1aa2764adb6e40
4
- data.tar.gz: 88e908022a12e1ed55bcd8859bc7be736e9d844832ed7df30f81caf3f822c875
3
+ metadata.gz: e75a3c9179f160afc62c9d7d275913577f1d8f2e639018854e90a823451481ca
4
+ data.tar.gz: a5979cb7e422567a9f6ab641776fdb59fb9304dd3e6bb83b9313b482798ac427
5
5
  SHA512:
6
- metadata.gz: b2e02a1233697cb16ef35ec291de7736b3e0721d516bcd566c309c88704e996fc5ce40c3ccb72abc54c6dbf1b2fbe384c41bf333a760e1e889b7ee280331f5ba
7
- data.tar.gz: 506bfd185f702ad39e7f6d21713524b002bc90e45e0e1aaed0832d6aee2f5d0d998a104c46b9272ab001040fd1ed49be41a788107cc9c0fea9145697dffb10ff
6
+ metadata.gz: 9bf77688d4b8e9fd4503e0528318a5b4f3cf6a5fd21d6accc75673a29b65765940ef11c4cdc4896c81de44a95c1f007195229c8a4b5532a87ff53b1119a90c8a
7
+ data.tar.gz: e42d50020da5d75bd4d6695bcdd7580cf17e339e32d6bc15e85da67c6aa4015aec6293625bfc658781ca3d6671fd820c4a5ad20a29a442bfb483f375041a7a26
data/README.md CHANGED
@@ -171,7 +171,7 @@ In some cases you may want to send basic data from Rails to your React server. Q
171
171
 
172
172
  **Note:** The data passed should be data that is unlikely or will never change over the course of the session before they render any React components.
173
173
 
174
- **Note:** Please note the minimal dependencies require to use this feature is listed in [CHANGELOG](./CHANGELOG.md#[1.12.0]-2020-05-07)
174
+ **Note:** Please note the minimal dependencies require to use this feature is listed in [CHANGELOG](./CHANGELOG.md#1.12.0-2020-05-07)
175
175
 
176
176
  ```ruby
177
177
  class ReactController < ApplicationController
@@ -13,6 +13,7 @@ module Quilt
13
13
  self.react_server_protocol = ENV['REACT_SERVER_PROTOCOL'] || "http"
14
14
  self.logger = ::Logger.new($stdout)
15
15
  self.mount = true
16
+ self.allow_integration_test = false
16
17
  end
17
18
 
18
19
  def mount?
@@ -7,7 +7,9 @@ module Quilt
7
7
  include ReverseProxy::Controller
8
8
 
9
9
  def render_react(headers: {}, data: {})
10
- raise DoNotIntegrationTestError if Rails.env.test?
10
+ if Rails.env.test? && !Quilt.configuration.allow_integration_test
11
+ raise DoNotIntegrationTestError
12
+ end
11
13
 
12
14
  # Allow concurrent loading to prevent this thread from blocking class
13
15
  # loading in controllers called by the Node server.
@@ -20,7 +22,8 @@ module Quilt
20
22
 
21
23
  def call_proxy(headers, data)
22
24
  if defined? ShopifySecurityBase
23
- ShopifySecurityBase::HTTPHostRestriction.whitelist([Quilt.configuration.react_server_host]) do
25
+ allowlist = ShopifySecurityBase::HTTPHostRestriction.respond_to?(:allowlist) ? :allowlist : :whitelist
26
+ ShopifySecurityBase::HTTPHostRestriction.send(allowlist, [Quilt.configuration.react_server_host]) do
24
27
  proxy(headers, data)
25
28
  end
26
29
  else
@@ -37,9 +40,10 @@ module Quilt
37
40
  end
38
41
 
39
42
  begin
43
+ data_json = JSON.generate(data.as_json, ascii_only: true)
40
44
  reverse_proxy(
41
45
  url,
42
- headers: headers.merge('X-Request-ID': request.request_id, 'X-Quilt-Data': data.to_json)
46
+ headers: headers.merge('X-Request-ID': request.request_id, 'X-Quilt-Data': data_json)
43
47
  ) do |callbacks|
44
48
  callbacks.on_response do |status_code, _response|
45
49
  Quilt.logger.info("[ReactRenderable] #{url} returned #{status_code}")
@@ -53,8 +57,8 @@ module Quilt
53
57
  class ReactServerNoResponseError < StandardError
54
58
  def initialize(url)
55
59
  super(<<~MSG.squish)
56
- Errno::ECONNREFUSED: Waiting for React server to boot up.
57
- If this error persists verify that @shopify/react-server is configured on #{url}"
60
+ Connection refused while waiting for React server to boot up.
61
+ If this error persists, verify that @shopify/react-server is configured on #{url}.
58
62
  MSG
59
63
  end
60
64
  end
@@ -62,8 +66,10 @@ module Quilt
62
66
  class DoNotIntegrationTestError < StandardError
63
67
  def initialize
64
68
  super(<<~MSG.squish)
65
- Do not try to use Rails integration tests on your quilt_rails app.
66
- Instead use Jest and @shopify/react-testing to test your React application directly."
69
+ Please don't test React views with Ruby.
70
+ Jest and @shopify/react-testing should be used to test React components.
71
+
72
+ If you meant to query your Rails application, please check your integration test for errors.
67
73
  MSG
68
74
  end
69
75
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Quilt
3
- VERSION = "3.4.1"
3
+ VERSION = "3.5.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quilt_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathew Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-19 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  requirements: []
160
- rubygems_version: 3.0.3
160
+ rubygems_version: 3.2.20
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: A turn-key solution for integrating server-rendered React into your Rails