Browse files

Implement TimeZoneInput.

  • Loading branch information...
1 parent e2cc8bc commit cc12e39ce1e4593c80b4d3428e663d9ec8b86748 @mjbellantoni committed Sep 4, 2012
View
2 lib/formtastic-bootstrap/inputs.rb
@@ -28,7 +28,7 @@ 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 # TODO Come back to this.
+ autoload :TimeZoneInput, "formtastic-bootstrap/inputs/time_zone_input"
# autoload :Timeish # This seems like a mistake.
autoload :UrlInput, "formtastic-bootstrap/inputs/url_input"
View
2 lib/formtastic-bootstrap/inputs/time_zone_input.rb
@@ -4,7 +4,7 @@ class TimeZoneInput < Formtastic::Inputs::TimeZoneInput
include Base
def to_html
- generic_input_wrapping do
+ bootstrap_wrapping do
builder.time_zone_select(method, priority_zones, input_options, input_html_options)
end
end
View
36 spec/inputs/time_zone_input_spec.rb
@@ -8,43 +8,42 @@
before do
@output_buffer = ''
mock_everything
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:time_zone))
end)
end
+ it_should_have_bootstrap_horizontal_wrapping
it_should_have_input_wrapper_with_class("time_zone")
- it_should_have_input_wrapper_with_class(:clearfix)
+ it_should_have_input_wrapper_with_class(:input)
it_should_have_input_wrapper_with_id("post_time_zone_input")
it_should_apply_error_logic_for_input_type(:time_zone)
it 'should generate a label for the input' do
- output_buffer.should have_tag('form div label')
- output_buffer.should have_tag('form div label[@for="post_time_zone"]')
- output_buffer.should have_tag('form div label', /Time zone/)
+ output_buffer.should have_tag('form div.control-group label.control-label')
+ output_buffer.should have_tag('form div.control-group label.control-label[@for="post_time_zone"]')
+ output_buffer.should have_tag('form div.control-group label.control-label', /Time zone/)
end
it "should generate a select" do
- output_buffer.should have_tag("form div select")
- output_buffer.should have_tag("form div select#post_time_zone")
- output_buffer.should have_tag("form div select[@name=\"post[time_zone]\"]")
+ output_buffer.should have_tag("form div.control-group div.controls select")
+ output_buffer.should have_tag("form div.control-group div.controls select#post_time_zone")
+ output_buffer.should have_tag("form div.control-group div.controls select[@name=\"post[time_zone]\"]")
end
it 'should use input_html to style inputs' do
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:time_zone, :input_html => { :class => 'myclass' }))
end)
- output_buffer.should have_tag("form div select.myclass")
+ output_buffer.should have_tag("form div.control-group div.controls select.myclass")
end
describe "when namespace is provided" do
before do
@output_buffer = ''
mock_everything
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
concat(builder.input(:time_zone))
@@ -62,7 +61,6 @@
before do
@output_buffer = ''
mock_everything
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
concat(semantic_form_for(@new_post) do |builder|
concat(builder.fields_for(:author, :index => 3) do |author|
@@ -71,8 +69,8 @@
end)
end
- it 'should index the id of the wrapper' do
- output_buffer.should have_tag("div#post_author_attributes_3_name_input")
+ 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
@@ -94,15 +92,15 @@
end
it 'should generate labels' do
- output_buffer.should have_tag('form div label')
- output_buffer.should have_tag('form div label[@for="project_time_zone"]')
- output_buffer.should have_tag('form div label', /Time zone/)
+ output_buffer.should have_tag('form div.control-group label.control-label')
+ output_buffer.should have_tag('form div.control-group label.control-label[@for="project_time_zone"]')
+ output_buffer.should have_tag('form div.control-group label.control-label', /Time zone/)
end
it 'should generate select inputs' do
- output_buffer.should have_tag("form div select")
- output_buffer.should have_tag("form div select#project_time_zone")
- output_buffer.should have_tag("form div select[@name=\"project[time_zone]\"]")
+ output_buffer.should have_tag("form div.control-group div.controls select")
+ output_buffer.should have_tag("form div.control-group div.controls select#project_time_zone")
+ output_buffer.should have_tag("form div.control-group div.controls select[@name=\"project[time_zone]\"]")
end
end

1 comment on commit cc12e39

@kristianmandrup

Are you targeting Twitter Bootstrap 2.0.4 or 2.1? How far are you from the next release? The version I hacked together doesn't work well with TS 2.1 unfortunately :(

Please sign in to comment.