Skip to content

Commit 11a72cb

Browse files
author
Matthew Bellantoni
committed
Implement PasswordInput.
1 parent 003fe29 commit 11a72cb

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

lib/formtastic-bootstrap/inputs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module Inputs
1818
autoload :NumberInput, "formtastic-bootstrap/inputs/number_input"
1919
# autoload :NumericInput # TODO Where does Formtastic actually define this?
2020
autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input"
21-
# autoload :PhoneInput
21+
autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
2222
# autoload :RadioInput
2323
# autoload :RangeInput
2424
# autoload :SearchInput

lib/formtastic-bootstrap/inputs/phone_input.rb

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

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

spec/inputs/phone_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(:phone)
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_phone_input")
2625
it_should_have_label_with_text(/Phone/)
2726
it_should_have_label_for("post_phone")
@@ -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 => :phone))
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)