-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Rails 7.1 and 7.2. Experiment with Ruby 3.3.
- Loading branch information
1 parent
50a2438
commit bd99582
Showing
9 changed files
with
114 additions
and
32 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
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ version links. | |
|
||
## main | ||
|
||
Expand matrix of supported versions to include `[email protected]` and `[email protected]`. | ||
|
||
## [0.2.1] - Jan 22, 2023 | ||
|
||
Add test coverage for `field_id` and `field_name`, and delegate to view context | ||
|
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
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,55 @@ | ||
require "test_helper" | ||
|
||
class ViewPartialFormBuilder::TemplateProxyTest < ActionView::TestCase | ||
test "#capture is delegated to the template" do | ||
render_with_template_proxy <<~ERB | ||
<% content = template_proxy.capture do %> | ||
Hello world | ||
<% end %> | ||
<%= content %> | ||
ERB | ||
|
||
assert_equal rendered.strip, "Hello world" | ||
end | ||
|
||
if Rails.version >= "7.0.0" | ||
test "#_object_for_form_builder is delegated to the template" do | ||
model_class = Class.new do | ||
def to_s | ||
"Hello from the model" | ||
end | ||
end | ||
|
||
render_with_template_proxy <<~ERB, model: model_class.new | ||
<%= template_proxy._object_for_form_builder(model) %> | ||
ERB | ||
|
||
assert_equal rendered.strip, "Hello from the model" | ||
end | ||
|
||
test "#field_id is delegated to the template" do | ||
render_with_template_proxy <<~ERB | ||
<%= template_proxy.field_id(:object_name, :method_name) %> | ||
ERB | ||
|
||
assert_equal rendered.strip, "object_name_method_name" | ||
end | ||
|
||
test "#field_name is delegated to the template" do | ||
render_with_template_proxy <<~ERB | ||
<%= template_proxy.field_name(:object_name, :method_name) %> | ||
ERB | ||
|
||
assert_equal rendered.strip, "object_name[method_name]" | ||
end | ||
end | ||
|
||
def render_with_template_proxy(template, **locals) | ||
render inline: <<~ERB, locals: {template: template, locals: locals} | ||
<% template_proxy = ViewPartialFormBuilder::TemplateProxy.new(builder: nil, template: self) %> | ||
<%= render inline: template, locals: {template_proxy: template_proxy, **locals} %> | ||
ERB | ||
end | ||
end |