Skip to content

Commit 00ea539

Browse files
committed
Fix a helper spec that was failing in CI with ViewComponent 3
- test had begun failing w/VC 3.25.0 - specific VC change `Fix stale render context on reused component instances` is the culprit; After 3.25.0, `#render_in` resets `@_helpers` to `nil` on every call so it's re-derived fresh from the view context's controller; the test's anonymous controller doesn't have the `helper_method :blacklight_config` delegation, causing a `NameError`
1 parent fa1df27 commit 00ea539

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

spec/helpers/blacklight_helper_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,24 @@
172172
end
173173

174174
it "ignores missing templates" do
175+
# ViewComponent 3.25.0 (Jun 5, 2026) introduced a change that
176+
# broke this test. For VC3 we need to stub the blacklight_config
177+
# method on the helper to avoid a NameError.
178+
if ViewComponent::VERSION::MAJOR == 3
179+
config = blacklight_config
180+
Blacklight::DocumentHelperBehavior.define_method(:blacklight_config) { config }
181+
end
175182
blacklight_config.view.view_type(partials: %w[index_header a b])
176-
177183
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
178184
expect(response).to have_css "div#documents"
185+
ensure
186+
if ViewComponent::VERSION::MAJOR == 3
187+
begin
188+
Blacklight::DocumentHelperBehavior.remove_method(:blacklight_config)
189+
rescue StandardError
190+
nil
191+
end
192+
end
179193
end
180194

181195
context 'with a template partial provided by the view config' do

0 commit comments

Comments
 (0)