Skip to content

Commit b690891

Browse files
author
Matthew Bellantoni
committed
Implement UrlInput.
1 parent 8b7da1b commit b690891

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

lib/formtastic-bootstrap/inputs.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ module Inputs
2828
autoload :TimeInput, "formtastic-bootstrap/inputs/time_input"
2929
# autoload :TimePickerInput # TODO Come back to this.
3030
autoload :TimeSelectInput, "formtastic-bootstrap/inputs/time_select_input"
31-
# autoload :TimeZoneInput
32-
# autoload :Timeish
33-
# autoload :UrlInput
31+
# autoload :TimeZoneInput # TODO Come back to this.
32+
# autoload :Timeish # This seems like a mistake.
33+
autoload :UrlInput, "formtastic-bootstrap/inputs/url_input"
3434

3535
end
3636
end

lib/formtastic-bootstrap/inputs/url_input.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class UrlInput < Formtastic::Inputs::UrlInput
55
include Base::Stringish
66

77
def to_html
8-
generic_input_wrapping do
8+
bootstrap_wrapping do
99
builder.url_field(method, input_html_options)
1010
end
1111
end

spec/inputs/url_input_spec.rb

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
before do
99
@output_buffer = ''
1010
mock_everything
11-
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
1211
end
1312

1413
describe "when object is provided" do
@@ -18,10 +17,10 @@
1817
end)
1918
end
2019

20+
it_should_have_bootstrap_horizontal_wrapping
2121
it_should_have_input_wrapper_with_class(:url)
22-
it_should_have_input_wrapper_with_class(:clearfix)
22+
it_should_have_input_wrapper_with_class(:input)
2323
it_should_have_input_wrapper_with_class(:stringish)
24-
it_should_have_input_class_in_the_right_place
2524
it_should_have_input_wrapper_with_id("post_url_input")
2625
it_should_have_label_with_text(/Url/)
2726
it_should_have_label_for("post_url")
@@ -44,6 +43,34 @@
4443

4544
end
4645

46+
describe "when index is provided" do
47+
48+
before do
49+
@output_buffer = ''
50+
mock_everything
51+
52+
concat(semantic_form_for(@new_post) do |builder|
53+
concat(builder.fields_for(:author, :index => 3) do |author|
54+
concat(author.input(:name, :as => :url))
55+
end)
56+
end)
57+
end
58+
59+
it 'should index the id of the control-group' do
60+
output_buffer.should have_tag("div.control-group#post_author_attributes_3_name_input")
61+
end
62+
63+
it 'should index the id of the select tag' do
64+
output_buffer.should have_tag("input#post_author_attributes_3_name")
65+
end
66+
67+
it 'should index the name of the select tag' do
68+
output_buffer.should have_tag("input[@name='post[author_attributes][3][name]']")
69+
end
70+
71+
end
72+
73+
4774
describe "when required" do
4875
it "should add the required attribute to the input's html options" do
4976
with_config :use_required_attribute, true do

0 commit comments

Comments
 (0)