8000 Improve rendering attributes for f.inputs · activeadmin/activeadmin@86aa14a · GitHub
[go: up one dir, main page]

Skip to content

Commit 86aa14a

Browse files
committed
Improve rendering attributes for f.inputs
1 parent 06cac27 commit 86aa14a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/active_admin/views/components/active_admin_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def build(form_builder, *args, &block)
132132
legend = args.shift if args.first.is_a?(::String)
133133
legend = html_options.delete(:name) if html_options.key?(:name)
134134
legend_tag = legend ? "<legend class=\"fieldset-title\">#{ERB::Util.html_escape(legend)}</legend>" : ""
135-
fieldset_attrs = html_options.map { |k, v| %Q{#{k}="#{v}"} }.join(" ")
135+
fieldset_attrs = tag.attributes html_options
136136
@opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
137137
@closing_tag = "</ol></fieldset>"
138138
super(*(args 8000 << html_options), &block)

spec/unit/form_builder_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def build_form(options = {}, form_object = Post.new, &block)
6262
context "with custom settings" do
6363
let :body do
6464
build_form do |f|
65-
f.inputs class: "custom_class", name: "custom_name", custom_attr: "custom_attr" do
65+
f.inputs class: "custom_class", name: "custom_name", custom_attr: "custom_attr", data: { test: "custom" } do
6666
f.input :title
6767
f.input :body
6868
end
@@ -80,6 +80,10 @@ def build_form(options = {}, form_object = Post.new, &block)
8080
it "should generate a fieldset with a custom attributes" do
8181
expect(body).to have_css("fieldset[custom_attr='custom_attr']")
8282
end
83+
84+
it "should use the rails helper for rendering attributes" do
85+
expect(body).to have_css("fieldset[data-test='custom']")
86+
end
8387
end
8488

8589
context "with XSS payload as name" do

0 commit comments

Comments
 (0)
0