-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Open
Description
Steps to reproduce
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
# If you want to test against edge Rails replace the previous line with this:
# gem "rails", github: "rails/rails", branch: "main"
gem "haml"
end
require "action_controller/railtie"
require "action_view/railtie"
require "minitest/autorun"
class TestApp < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
config.eager_load = false
config.logger = Logger.new($stdout)
config.secret_key_base = "secret_key_base"
end
Rails.application.initialize!
class BugTest < ActionView::TestCase
setup do
@view_path = Pathname.new(Dir.mktmpdir)
ActionController::Base.prepend_view_path @view_path
end
teardown do
@view_path.rmtree
end
def test_action_view_render_template
view_file "posts/index.html.haml", <<~HAML
%h1 Posts
- posts.each do |post|
= render partial: "posts/post", locals: { post: post }
HAML
view_file "posts/_post.html.haml", <<~HAML
-# locals: (post:), haml-lint:disable LineLength
%p= upcase(post)
HAML
render template: "posts/index", locals: { posts: ["hello world"] }
assert_equal "hello world", rendered.html.at("p").text
end
private
def view_file(filename, contents)
pathname = @view_path.join(filename)
pathname.dirname.mkpath
pathname.write(contents.chomp)
end
endExpected behavior
The partial should be rendered as before. The bug was likely introduced with #56270. The example will work fine with Rails 8.0.x
Actual behavior
An ActionView::SyntaxErrorInTemplate exception is thrown.
System configuration
Rails version: 8.1.2
Ruby version: 4.0.0
felix-as
Metadata
Metadata
Assignees
Labels
No labels