8000 fix regression in fa0edec4 · lest/activeadmin@9062494 · GitHub
[go: up one dir, main page]

10000 Skip to content

Commit 9062494

Browse files
committed
fix regression in fa0edec
Ref: activeadmin#2523, activeadmin#2832
1 parent 77c97d2 commit 9062494

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/active_admin/filters/forms.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def active_admin_filters_form_for(search, filters, options = {})
6666
form_for search, options do |f|
6767
filters.group_by{ |o| o[:attribute] }.each do |attribute, array|
6868
opts = array.last # grab last-defined `filter` call from DSL
69-
return if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
70-
return if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
69+
next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
70+
next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
7171

7272
f.filter attribute, opts.except(:if, :unless)
7373
end

spec/unit/filters/filter_form_builder_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ def filter(name, options = {})
328328
body.should_not have_tag "input", attributes: {name: "q[body_contains]"}
329329
end
330330
end
331+
it "should successfully keep rendering other filters after one is hidden" do
332+
filters = [{attribute: :body, verb => proc{ verb == :unless }}, {attribute: :author}]
333+
body = render_filter scope, filters
334+
body.should_not have_tag "input", attributes: {name: "q[body_contains]"}
335+
body.should have_tag "select", attributes: {name: "q[author_id_eq]"}
336+
end
331337
end
332338
end
333339
end

0 commit comments

Comments
 (0)
0