inertia_rails 3.1.1 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/inertia_rails/inertia_rails.rb +1 -2
- data/lib/inertia_rails/renderer.rb +14 -4
- data/lib/inertia_rails/rspec.rb +4 -2
- data/lib/inertia_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c07b523480214ac3e0bcc753b9fabff16e483cceb631a50626dace061664aa0
|
4
|
+
data.tar.gz: 9c03ea8d1195414ea9aad62f82893694466167361bc59c104f4cdf0e223a9853
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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.
|
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(
|
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
|
data/lib/inertia_rails/rspec.rb
CHANGED
@@ -74,7 +74,8 @@ end
|
|
74
74
|
|
75
75
|
RSpec::Matchers.define :have_exact_props do |expected_props|
|
76
76
|
match do |inertia|
|
77
|
-
|
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
|
-
|
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|
|
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.
|
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-
|
13
|
+
date: 2023-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|