Skip to content
Browse files

Merge pull request #875 from pfeiffer/860_checkbox_integers

Make sure checkbox values with integers are checked
  • Loading branch information...
2 parents f4214c2 + 12c086b commit 6378c459629f4ba9985683cfef10eb68f3958b4f @justinfrench committed Jul 27, 2012
Showing with 16 additions and 2 deletions.
  1. +1 −1 lib/formtastic/inputs/base/collections.rb
  2. +15 −1 spec/inputs/check_boxes_input_spec.rb
View
2 lib/formtastic/inputs/base/collections.rb
@@ -113,7 +113,7 @@ def send_or_call(duck, object)
# Avoids an issue where `send_or_call` can be a String and duck can be something simple like
# `:first`, which obviously String responds to.
def send_or_call_or_object(duck, object)
- return object if object.is_a?(String) # TODO what about other classes etc?
+ return object if object.is_a?(String) || object.is_a?(Integer) # TODO what about other classes etc?
send_or_call(duck, object)
end
View
16 spec/inputs/check_boxes_input_spec.rb
@@ -441,7 +441,21 @@
it "should not check any items" do
output_buffer.should have_tag('form li input[@checked]', :count => 0)
- end
+ end
+
+ describe "and the attribute has values" do
+ before do
+ @fred.stub(:posts) { [1] }
+
+ concat(semantic_form_for(@fred) do |builder|
+ concat(builder.input(:posts, :as => :check_boxes, :collection => @_collection))
+ end)
+ end
+
+ it "should check the appropriate items" do
+ output_buffer.should have_tag("form li input[@value='1'][@checked]")
+ end
+ end
end
end

0 comments on commit 6378c45

Please sign in to comment.
Something went wrong with that request. Please try again.