inertia_rails 3.1.0 → 3.1.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: 27e7436cecef40102f1e1ca1971c75b182195e3291f55f94981ef8c87359d9d4
4
- data.tar.gz: 50c9634e36e040732e9bf42e7770a3d759e4930513b4fb54d2761e905689bc24
3
+ metadata.gz: 8c07b523480214ac3e0bcc753b9fabff16e483cceb631a50626dace061664aa0
4
+ data.tar.gz: 9c03ea8d1195414ea9aad62f82893694466167361bc59c104f4cdf0e223a9853
5
5
  SHA512:
6
- metadata.gz: 2653faf355cc672ebe5faec59fffdfe928cddd8b045ba114d5e8fafe01e3c5eb74ed47ac63336e62e1080c5e616a1ce3ac68fa8475644a1caf9f70e0206ce327
7
- data.tar.gz: f7ae1c4be29f75140a42a08cd31c8ca946b1b5bb39a681c8bd2b0c8db71c716bcf3368bc0f37b573ffe84906686d57b191ead1e1143de3d19bf4441bab06c09f
6
+ metadata.gz: af6a5413757d9808ecb55652ebba33555a8cade0655f9d701578c3dcce766f7b009b4ac65b4f0e7e0ecec7b6c6d071302e427d1bd3708c7991c2cb3b000a29c7
7
+ data.tar.gz: 607dde5d1e9b5ca02bda232b6bae305f23861e0d61636097f998554a4e1064cb0e8c6faa467adcb12e5209fba83ad6a19770bd37b9a5e87b21f1b777227f3f99
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.1.2] - 2023-09-26
8
+
9
+ * Fix `have_exact_props` RSpec matcher in the situation where shared props are defined in a lambda that outputs a hash with symbolized keys
10
+
11
+ ## [3.1.1] - 2023-08-21
12
+
13
+ * Fix broken partial reloads caused by comparing a list of symbolized keys with string keys from HashWithIndifferentAccess
14
+
7
15
  ## [3.1.0] - 2023-08-21
8
16
 
9
17
  ### Features
@@ -14,8 +14,7 @@ module InertiaRails
14
14
  # "Getters"
15
15
  def self.shared_data(controller)
16
16
  shared_plain_data.
17
- merge!(evaluated_blocks(controller, shared_blocks)).
18
- with_indifferent_access
17
+ merge!(evaluated_blocks(controller, shared_blocks))
19
18
  end
20
19
 
21
20
  def self.version
@@ -12,7 +12,7 @@ module InertiaRails
12
12
  @request = request
13
13
  @response = response
14
14
  @render_method = render_method
15
- @props = props ? props.with_indifferent_access : controller.inertia_view_assigns.with_indifferent_access
15
+ @props = props ? props : controller.inertia_view_assigns
16
16
  @view_data = view_data || {}
17
17
  @deep_merge = !deep_merge.nil? ? deep_merge : InertiaRails.deep_merge_shared_data?
18
18
  end
@@ -43,7 +43,12 @@ module InertiaRails
43
43
  end
44
44
 
45
45
  def computed_props
46
- _props = ::InertiaRails.shared_data(@controller).send(prop_merge_method, @props).select do |key, prop|
46
+ # Cast props to symbol keyed hash before merging so that we have a consistent data structure and
47
+ # avoid duplicate keys after merging.
48
+ #
49
+ # Functionally, this permits using either string or symbol keys in the controller. Since the results
50
+ # is cast to json, we should treat string/symbol keys as identical.
51
+ _props = ::InertiaRails.shared_data(@controller).deep_symbolize_keys.send(prop_merge_method, @props.deep_symbolize_keys).select do |key, prop|
47
52
  if rendering_partial_component?
48
53
  key.in? partial_keys
49
54
  else
@@ -51,7 +56,12 @@ module InertiaRails
51
56
  end
52
57
  end
53
58
 
54
- deep_transform_values(_props, lambda {|prop| prop.respond_to?(:call) ? @controller.instance_exec(&prop) : prop }).with_indifferent_access
59
+ deep_transform_values(
60
+ _props,
61
+ lambda do |prop|
62
+ prop.respond_to?(:call) ? @controller.instance_exec(&prop) : prop
63
+ end
64
+ )
55
65
  end
56
66
 
57
67
  def page
@@ -74,7 +74,8 @@ end
74
74
 
75
75
  RSpec::Matchers.define :have_exact_props do |expected_props|
76
76
  match do |inertia|
77
- expect(inertia.props).to eq expected_props.with_indifferent_access
77
+ # Computed props have symbolized keys.
78
+ expect(inertia.props).to eq expected_props.deep_symbolize_keys
78
79
  end
79
80
 
80
81
  failure_message do |inertia|
@@ -84,7 +85,8 @@ end
84
85
 
85
86
  RSpec::Matchers.define :include_props do |expected_props|
86
87
  match do |inertia|
87
- expect(inertia.props).to include expected_props.with_indifferent_access
88
+ # Computed props have symbolized keys.
89
+ expect(inertia.props).to include expected_props.deep_symbolize_keys
88
90
  end
89
91
 
90
92
  failure_message do |inertia|
@@ -1,3 +1,3 @@
1
1
  module InertiaRails
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inertia_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Knoles
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-08-21 00:00:00.000000000 Z
13
+ date: 2023-09-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails