Permalink
Browse files

Implement RangeInput.

  • Loading branch information...
1 parent 9440708 commit 3bba2b4b812d5a69f0d119816e58500d27469e66 @mjbellantoni committed Sep 3, 2012
@@ -20,7 +20,7 @@ module Inputs
autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input"
autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input"
- # autoload :RangeInput
+ autoload :RangeInput, "formtastic-bootstrap/inputs/range_input"
# autoload :SearchInput
# autoload :SelectInput
autoload :StringInput, "formtastic-bootstrap/inputs/string_input"
@@ -5,7 +5,7 @@ class RangeInput < Formtastic::Inputs::RangeInput
include Base::Stringish
def to_html
- generic_input_wrapping do
+ bootstrap_wrapping do
builder.range_field(method, input_html_options)
end
end
@@ -1,6 +1,5 @@
# encoding: utf-8
require 'spec_helper'
-require 'active_record'
describe 'range input' do
@@ -9,7 +8,6 @@
before do
@output_buffer = ''
mock_everything
- Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
end
describe "when object is provided" do
@@ -19,10 +17,11 @@
end)
end
+ it_should_have_bootstrap_horizontal_wrapping
it_should_have_input_wrapper_with_class(:range)
- it_should_have_input_wrapper_with_class(:clearfix)
- it_should_have_input_wrapper_with_class(:stringish) # might be removed
- it_should_have_input_class_in_the_right_place
+ it_should_have_input_wrapper_with_class(:input)
+ it_should_have_input_wrapper_with_class(:numeric)
+ it_should_have_input_wrapper_with_class(:stringish)
it_should_have_input_wrapper_with_id("author_age_input")
it_should_have_label_with_text(/Age/)
it_should_have_label_for("author_age")
@@ -44,6 +43,34 @@
it_should_have_label_and_input_with_id("context2_author_age")
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 => :range))
+ 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 validations require a minimum value (:greater_than)" do
before do

0 comments on commit 3bba2b4

Please sign in to comment.