-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Action View bug report templates 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.
- Loading branch information
1 parent
60d05cd
commit d8ea067
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/inline" | ||
|
||
gemfile(true) do | ||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
gem "actionpack", "~> 7.1.0" | ||
gem "actionview", "~> 7.1.0" | ||
end | ||
|
||
require "minitest/autorun" | ||
require "action_view" | ||
|
||
class BuggyViewTest < ActionView::TestCase | ||
module Helpers | ||
def upcase(value) | ||
value.upcase | ||
end | ||
end | ||
|
||
def test_stuff | ||
view.extend Helpers | ||
|
||
render inline: <<~ERB, locals: { key: "value" } | ||
<p><%= upcase(key) %></p> | ||
ERB | ||
|
||
assert_includes rendered.html.at("p").text, "VALUE" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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", github: "rails/rails", branch: "main" | ||
end | ||
|
||
require "minitest/autorun" | ||
require "action_view" | ||
|
||
class BuggyViewTest < ActionView::TestCase | ||
module Helpers | ||
def upcase(value) | ||
value.upcase | ||
end | ||
end | ||
|
||
def test_stuff | ||
view.extend Helpers | ||
|
||
render inline: <<~ERB, locals: { key: "value" } | ||
<p><%= upcase(key) %></p> | ||
ERB | ||
|
||
assert_includes rendered.html.at("p").text, "VALUE" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters