Skip to content

Commit

Permalink
fix regression in fa0edec
Browse files Browse the repository at this point in the history
Ref: #2523, #2832
  • Loading branch information
seanlinsley committed Dec 30, 2013
1 parent 77c97d2 commit 9062494
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/active_admin/filters/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def active_admin_filters_form_for(search, filters, options = {})
form_for search, options do |f|
filters.group_by{ |o| o[:attribute] }.each do |attribute, array|
opts = array.last # grab last-defined `filter` call from DSL
return if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
return if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])

f.filter attribute, opts.except(:if, :unless)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/filters/filter_form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ def filter(name, options = {})
body.should_not have_tag "input", attributes: {name: "q[body_contains]"}
end
end
it "should successfully keep rendering other filters after one is hidden" do
filters = [{attribute: :body, verb => proc{ verb == :unless }}, {attribute: :author}]
body = render_filter scope, filters
body.should_not have_tag "input", attributes: {name: "q[body_contains]"}
body.should have_tag "select", attributes: {name: "q[author_id_eq]"}
end
end
end
end
Expand Down

0 comments on commit 9062494

Please sign in to comment.