From fe2632f34052edafc5a4b82c52beb9feac4547fc Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Thu, 9 Nov 2023 10:10:37 -0500 Subject: [PATCH] Add `actionview` bug report template Introduce Action View bug report template for contributors to reproduce issues with failing `ActionView::TestCase` instances. In addition to rendering ERB with the `inline:` keyword, the sample tests also include a `Helpers` module to demonstrate how to incorporate view helpers into the reproduction script. --- guides/bug_report_templates/action_view.rb | 34 +++++++++++++++++++ .../source/contributing_to_ruby_on_rails.md | 1 + 2 files changed, 35 insertions(+) create mode 100644 guides/bug_report_templates/action_view.rb diff --git a/guides/bug_report_templates/action_view.rb b/guides/bug_report_templates/action_view.rb new file mode 100644 index 0000000000..763739fa97 --- /dev/null +++ b/guides/bug_report_templates/action_view.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require "bundler/inline" + +gemfile(true) do + source "https://rubygems.org" + + git_source(:github) { |repo| "https://github.com/#{repo}.git" } + + gem "rails" + # If you want to test against edge Rails replace the previous line with this: + # gem "rails", github: "rails/rails", branch: "main" +end + +require "minitest/autorun" +require "action_view" + +class BugTest < ActionView::TestCase + helper do + def upcase(value) + value.upcase + end + end + + def test_stuff + render inline: <<~ERB, locals: { key: "value" } +

<%= upcase(key) %>

+ ERB + + element = rendered.html.at("p") + + assert_equal element.text, "VALUE" + end +end diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index dfa0553e6c..e5a2c03603 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -42,6 +42,7 @@ Having a way to reproduce your issue will help people confirm, investigate, and * Template for Active Record (models, database) issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record.rb) * Template for testing Active Record (migration) issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record_migrations.rb) * Template for Action Pack (controllers, routing) issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/action_controller.rb) +* Template for Action View (views, helpers) issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/action_view.rb) * Template for Active Job issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_job.rb) * Template for Active Storage issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_storage.rb) * Template for Action Mailer issues: [link](https://github.com/rails/rails/blob/main/guides/bug_report_templates/action_mailer.rb)