Skip to content

Commit

Permalink
Fixed specs
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Jun 30, 2011
1 parent 08945df commit 1b649ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/datagrid/filters/boolean_enum_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Datagrid::Filters::BooleanEnumFilter < Datagrid::Filters::EnumFilter
VALUES = {YES => true, NO => false}

def initialize(report, attribute, options = {}, &block)
options[:allow_blank] = true unless options.has_key?(:allow_blank)
options[:select] = VALUES.keys
super(report, attribute, options, &block)
end
Expand Down
6 changes: 5 additions & 1 deletion lib/datagrid/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def datagrid_enum_filter(attribute_or_filter, options = {})
end

def datagrid_integer_filter(attribute_or_filter, options = {})
text_field get_attribute(attribute_or_filter), options
filter = get_filter(attribute_or_filter)
if filter.multiple && self.object[filter.name].blank?
options[:value] = ""
end
text_field filter.name, options
end

def datagrid_string_filter(attribute_or_filter, options = {})
Expand Down
6 changes: 3 additions & 3 deletions spec/datagrid/form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class MyTemplate
let(:_filter) { :disabled }
it { should equal_to_dom(
'<select class="disabled boolean_enum_filter" id="report_disabled" name="report[disabled][]"><option value=""></option>
<option value="NO">NO</option>
<option value="YES">YES</option></select>'
)}
<option value="YES">YES</option>
<option value="NO">NO</option></select>'
)} #TODO: review unwanted [] in name here
end
context "with string filter" do
let(:grid) do
Expand Down

0 comments on commit 1b649ad

Please sign in to comment.