Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement UrlInput.

  • Loading branch information...
commit b69089150e1c04d4abcaeb23d6760138eae03093 1 parent 8b7da1b
@mjbellantoni authored
View
6 lib/formtastic-bootstrap/inputs.rb
@@ -28,9 +28,9 @@ module Inputs
autoload :TimeInput, "formtastic-bootstrap/inputs/time_input"
# autoload :TimePickerInput # TODO Come back to this.
autoload :TimeSelectInput, "formtastic-bootstrap/inputs/time_select_input"
- # autoload :TimeZoneInput
- # autoload :Timeish
- # autoload :UrlInput
+ # autoload :TimeZoneInput # TODO Come back to this.
+ # autoload :Timeish # This seems like a mistake.
+ autoload :UrlInput, "formtastic-bootstrap/inputs/url_input"
end
end
View
2  lib/formtastic-bootstrap/inputs/url_input.rb
@@ -5,7 +5,7 @@ class UrlInput < Formtastic::Inputs::UrlInput
include Base::Stringish
def to_html
- generic_input_wrapping do
+ bootstrap_wrapping do
builder.url_field(method, input_html_options)
end
end
View
33 spec/inputs/url_input_spec.rb
@@ -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(:url)
- 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_url_input")
it_should_have_label_with_text(/Url/)
it_should_have_label_for("post_url")
@@ -44,6 +43,34 @@
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 => :url))
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.