inertia_rails 3.1.1 → 3.1.2

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
  SHA256:
3
- metadata.gz: 782c220b920be30740f826d2dbf34f61de80219947bda32a6e01b94991be2952
4
- data.tar.gz: fd5e8f3dbf11347a14074132fbf8035f03b87bb23981ce4de80f88ba4c5bdbf6
3
+ metadata.gz: 8c07b523480214ac3e0bcc753b9fabff16e483cceb631a50626dace061664aa0
4
+ data.tar.gz: 9c03ea8d1195414ea9aad62f82893694466167361bc59c104f4cdf0e223a9853
5
5
  SHA512:
6
- metadata.gz: 05eacfc4a2cd7b84e49759765285ba33925851709d7ce4f7fc1322346b7c98b9978e63c9cf43f9e8eb1147272ef8a718c6c3d7919caafe94cf56ba4521f46bbb
7
- data.tar.gz: ed94a885cfa3acb5133b81b30037c2e5f1a9fdc01ad4ebc6ac2457dfd1f5802bda2cef190825e184b5056b10794deae6da175c76fd44c69e21dd3d8134d36418
6
+ metadata.gz: af6a5413757d9808ecb55652ebba33555a8cade0655f9d701578c3dcce766f7b009b4ac65b4f0e7e0ecec7b6c6d071302e427d1bd3708c7991c2cb3b000a29c7
7
+ data.tar.gz: 607dde5d1e9b5ca02bda232b6bae305f23861e0d61636097f998554a4e1064cb0e8c6faa467adcb12e5209fba83ad6a19770bd37b9a5e87b21f1b777227f3f99
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ 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
+
7
11
  ## [3.1.1] - 2023-08-21
8
12
 
9
13
  * Fix broken partial reloads caused by comparing a list of symbolized keys with string keys from HashWithIndifferentAccess
@@ -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,15 +43,25 @@ 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
- key.to_sym.in? partial_keys
53
+ key.in? partial_keys
49
54
  else
50
55
  !prop.is_a?(InertiaRails::Lazy)
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.1"
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.1
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-22 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