Skip to content

Commit

Permalink
Expand CI Matrix
Browse files Browse the repository at this point in the history
Support Rails 7.1 and 7.2. Experiment with Ruby 3.3.
  • Loading branch information
seanpdoyle committed Sep 27, 2024
1 parent 50a2438 commit 738b01b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 12 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2"]
rails: ["6.0", "6.1", "7.0"]
ruby:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
rails:
- "6.1"
- "7.0"
- "7.1"
- "7.2"
include:
- ruby: "2.7"
rails: "5.2"
- ruby: "3.2"
rails: "main"
- { ruby: "3.2", rails: "main" }
- { ruby: "3.3", rails: "main" }
exclude:
- { ruby: "2.7", rails: "7.2" }
- { ruby: "3.0", rails: "7.2" }

env:
RAILS_VERSION: "${{ matrix.rails }}"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gemspec
# To use a debugger
# gem 'byebug', group: [:development, :test]

rails_version = ENV.fetch("RAILS_VERSION", "7.0")
rails_version = ENV.fetch("RAILS_VERSION", "7.2")

rails_constraint =
if rails_version == "main"
Expand Down
12 changes: 7 additions & 5 deletions lib/view_partial_form_builder/template_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ def label(object_name, method, content_or_options = nil, options = nil, &block)
private

def method_missing(name, *arguments, &block)
arguments_after_object_name = arguments.from(1)
if @builder.respond_to?(name)
arguments_after_object_name = arguments.from(1)

render(name, arguments: arguments_after_object_name, block: block) do
if @template.respond_to?(name)
render(name, arguments: arguments_after_object_name, block: block) do
@template.public_send(name, *arguments, &block)
else
super
end
elsif @template.respond_to?(name)
@template.public_send(name, *arguments, &block)
else
super
end
end

Expand Down
39 changes: 39 additions & 0 deletions test/view_partial_form_builder/template_proxy_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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

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

def render_with_template_proxy(template)
render inline: <<~ERB, locals: {template: template}
<% template_proxy = ViewPartialFormBuilder::TemplateProxy.new(builder: nil, template: self) %>
<%= render inline: template, locals: {template_proxy: template_proxy} %>
ERB
end
end

0 comments on commit 738b01b

Please sign in to comment.