Skip to content

Commit

Permalink
Merge pull request formtastic#875 from pfeiffer/860_checkbox_integers
Browse files Browse the repository at this point in the history
Make sure checkbox values with integers are checked
  • Loading branch information
justinfrench committed Jul 28, 2012
2 parents f4214c2 + 12c086b commit 6378c45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/formtastic/inputs/base/collections.rb
Expand Up @@ -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

Expand Down
16 changes: 15 additions & 1 deletion spec/inputs/check_boxes_input_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 6378c45

Please sign in to comment.