Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Implement RangeInput.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Bellantoni committed Sep 3, 2012
1 parent 9440708 commit 3bba2b4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/formtastic-bootstrap/inputs.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Inputs
autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input" autoload :PasswordInput, "formtastic-bootstrap/inputs/password_input"
autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input" autoload :PhoneInput, "formtastic-bootstrap/inputs/phone_input"
autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input" autoload :RadioInput, "formtastic-bootstrap/inputs/radio_input"
# autoload :RangeInput autoload :RangeInput, "formtastic-bootstrap/inputs/range_input"
# autoload :SearchInput # autoload :SearchInput
# autoload :SelectInput # autoload :SelectInput
autoload :StringInput, "formtastic-bootstrap/inputs/string_input" autoload :StringInput, "formtastic-bootstrap/inputs/string_input"
Expand Down
2 changes: 1 addition & 1 deletion lib/formtastic-bootstrap/inputs/range_input.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RangeInput < Formtastic::Inputs::RangeInput
include Base::Stringish include Base::Stringish


def to_html def to_html
generic_input_wrapping do bootstrap_wrapping do
builder.range_field(method, input_html_options) builder.range_field(method, input_html_options)
end end
end end
Expand Down
37 changes: 32 additions & 5 deletions spec/inputs/range_input_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding: utf-8 # encoding: utf-8
require 'spec_helper' require 'spec_helper'
require 'active_record'


describe 'range input' do describe 'range input' do


Expand All @@ -9,7 +8,6 @@
before do before do
@output_buffer = '' @output_buffer = ''
mock_everything mock_everything
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
end end


describe "when object is provided" do describe "when object is provided" do
Expand All @@ -19,10 +17,11 @@
end) end)
end end


it_should_have_bootstrap_horizontal_wrapping
it_should_have_input_wrapper_with_class(:range) it_should_have_input_wrapper_with_class(:range)
it_should_have_input_wrapper_with_class(:clearfix) it_should_have_input_wrapper_with_class(:input)
it_should_have_input_wrapper_with_class(:stringish) # might be removed it_should_have_input_wrapper_with_class(:numeric)
it_should_have_input_class_in_the_right_place it_should_have_input_wrapper_with_class(:stringish)
it_should_have_input_wrapper_with_id("author_age_input") it_should_have_input_wrapper_with_id("author_age_input")
it_should_have_label_with_text(/Age/) it_should_have_label_with_text(/Age/)
it_should_have_label_for("author_age") it_should_have_label_for("author_age")
Expand All @@ -44,6 +43,34 @@
it_should_have_label_and_input_with_id("context2_author_age") it_should_have_label_and_input_with_id("context2_author_age")


end 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 describe "when validations require a minimum value (:greater_than)" do
before do before do
Expand Down

0 comments on commit 3bba2b4

Please sign in to comment.