Permalink
Browse files

Implement SearchInput.

  • Loading branch information...
1 parent 3bba2b4 commit 804a6d4310004bb3ca7c69d788a5dab6cd721c89 @mjbellantoni committed Sep 3, 2012
@@ -21,7 +21,7 @@ module Inputs
autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input"
autoload :RangeInput, "formtastic-bootstrap/inputs/range_input"
- # autoload :SearchInput
+ autoload :SearchInput, "formtastic-bootstrap/inputs/search_input"
# autoload :SelectInput
autoload :StringInput, "formtastic-bootstrap/inputs/string_input"
# autoload :TextInput
@@ -5,7 +5,7 @@ class SearchInput < Formtastic::Inputs::SearchInput
include Base::Stringish
def to_html
- generic_input_wrapping do
+ bootstrap_wrapping do
builder.search_field(method, input_html_options)
end
end
@@ -8,7 +8,6 @@
before do
@output_buffer = ''
mock_everything
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
end
describe "when object is provided" do
@@ -18,10 +17,10 @@
end)
end
+ it_should_have_bootstrap_horizontal_wrapping
it_should_have_input_wrapper_with_class(:search)
- it_should_have_input_wrapper_with_class(:clearfix)
+ it_should_have_input_wrapper_with_class(:input)
it_should_have_input_wrapper_with_class(:stringish)
- it_should_have_input_class_in_the_right_place
it_should_have_input_wrapper_with_id("post_search_input")
it_should_have_label_with_text(/Search/)
it_should_have_label_for("post_search")
@@ -44,6 +43,33 @@
end
+ describe "when index is provided" do
+
+ before do
+ @output_buffer = ''
+ mock_everything
+
+ concat(semantic_form_for(@new_post) do |builder|
+ concat(builder.fields_for(:author, :index => 3) do |author|
+ concat(author.input(:name, :as => :search))
+ end)
+ end)
+ end
+
+ it 'should index the id of the control-group' do
+ output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
+ end
+
+ it 'should index the id of the select tag' do
+ output_buffer.should have_tag("input#post_author_attributes_3_name")
+ end
+
+ it 'should index the name of the select tag' do
+ output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
+ end
+
+ end
+
describe "when required" do
it "should add the required attribute to the input's html options" do
with_config :use_required_attribute, true do

0 comments on commit 804a6d4

Please sign in to comment.