Skip to content

Commit

Permalink
Fix partial reload rendering because hash with indifferent access giv…
Browse files Browse the repository at this point in the history
…es keys as strings instead of symbols
  • Loading branch information
bknoles committed Aug 22, 2023
1 parent 6f249f1 commit 7fa0510
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/inertia_rails/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def layout
def computed_props
_props = ::InertiaRails.shared_data(@controller).send(prop_merge_method, @props).select do |key, prop|
if rendering_partial_component?
key.in? partial_keys
key.to_sym.in? partial_keys
else
!prop.is_a?(InertiaRails::Lazy)
end
Expand Down
8 changes: 6 additions & 2 deletions spec/inertia/rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

context 'partial rendering' do
let (:page) {
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey'}).send(:page)
InertiaRails::Renderer.new('TestComponent', controller, request, response, '', props: { sport: 'hockey' }).send(:page)
}
let(:headers) {{
'X-Inertia' => true,
Expand All @@ -76,6 +76,7 @@
before { get props_path, headers: headers }

it { is_expected.to eq page.to_json }
it { is_expected.to include('hockey') }
end

context 'with a non matching partial component header' do
Expand Down Expand Up @@ -107,13 +108,16 @@
}
let(:headers) {{
'X-Inertia' => true,
'X-Inertia-Partial-Data' => 'sport,level,grit',
'X-Inertia-Partial-Data' => 'sport,level',
'X-Inertia-Partial-Component' => 'TestComponent',
}}

before { get lazy_props_path, headers: headers }

it { is_expected.to eq page.to_json }
it { is_expected.to include('basketball') }
it { is_expected.to include('worse') }
it { is_expected.not_to include('intense') }
end
end
end
Expand Down

0 comments on commit 7fa0510

Please sign in to comment.