Skip to content

Commit e1825c5

Browse files
committed
Re-introduce Base#format and Collection#format to fix Rails 7.1 tests
1 parent de55254 commit e1825c5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/view_component/base.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ def view_cache_dependencies
316316
[]
317317
end
318318

319+
# Rails expects us to define `format` on all renderables,
320+
# but we do not know the `format` of a ViewComponent until runtime.
321+
def format
322+
nil
323+
end
324+
319325
# The current request. Use sparingly as doing so introduces coupling that
320326
# inhibits encapsulation & reuse, often making testing difficult.
321327
#

lib/view_component/collection.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ def each(&block)
1919
components.each(&block)
2020
end
2121

22+
# Rails expects us to define `format` on all renderables,
23+
# but we do not know the `format` of a ViewComponent until runtime.
24+
def format
25+
nil
26+
end
27+
2228
private
2329

2430
def components

0 commit comments

Comments
 (0)