Skip to content

Commit 472e4ba

Browse files
committed
Ensure format is in the type that rails expects
Rails expects the format to be a symbol. It filters formats against `Mime::SET.symbols` so formats which are unknown (or are known but are of an unexpected type) are not used in a cache keys for the Rails' `ActionView::Resolver::Cache`. This made the view cache unusable when there was multiple templates with the same name but different format and was the the reason the cache was disabled in [1]. [1] rspec#864
1 parent fc33b50 commit 472e4ba

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/rspec/rails/example/view_example_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _default_render_options
114114

115115
render_options = { :template => template }
116116
render_options[:handlers] = [handler] if handler
117-
render_options[:formats] = [format] if format
117+
render_options[:formats] = [format.to_sym] if format
118118
render_options[:locales] = [locale] if locale
119119

120120
render_options

spec/rspec/rails/example/view_example_group_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _assigns
121121
view_spec.render
122122

123123
if ::Rails::VERSION::STRING >= '3.2'
124-
expect(view_spec.received.first).to eq([{:template => "widgets/new", :locales=>['en'], :formats=>['html'], :handlers=>['erb']}, {}, nil])
124+
expect(view_spec.received.first).to eq([{:template => "widgets/new", :locales=>['en'], :formats=>[:html], :handlers=>['erb']}, {}, nil])
125125
else
126126
expect(view_spec.received.first).to eq([{:template => "widgets/new.en.html.erb"}, {}, nil])
127127
end

0 commit comments

Comments
 (0)