Permalink
Browse files

Make prepend/append work in bootstrap 3.x.

  • Loading branch information...
jtomaszewski committed Feb 8, 2014
1 parent 5a26414 commit 4c0b491671605a1a72d3b97920574ca26dd53045
Showing with 25 additions and 25 deletions.
  1. +4 −4 lib/formtastic-bootstrap/inputs/base/wrapping.rb
  2. +21 −21 spec/inputs/base/wrapping_spec.rb
@@ -33,7 +33,7 @@ def prepended_or_appended?(options)
def add_on_content(content)
return nil unless content
- template.content_tag(:span, content, :class => 'add-on')
+ template.content_tag(:span, content, :class => 'input-group-addon')
end
def form_group_wrapping(&block)
@@ -51,9 +51,9 @@ def wrapper_html_options
end
def add_on_wrapper_classes(options)
- [:prepend, :append, :prepend_content, :append_content].map do |key|
- "input-#{key.to_s.gsub('_content', '')}" if options[key]
- end
+ [:prepend, :append, :prepend_content, :append_content].find do |key|
+ options.has_key?(key)
+ end ? ['input-group'] : []
end
end
@@ -14,29 +14,29 @@
describe "text add ons" do
context "when appened with append option" do
- let(:options) { { :append => "text appended in add-on"} }
+ let(:options) { { :append => "text appended in addon"} }
- it "should have the appended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-append span.add-on", "text appended in add-on")
- output_buffer.should_not have_tag("form div.input-prepend")
+ it "should have the appended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group span.input-group-addon", "text appended in addon")
+ output_buffer.should_not have_tag("form div.input-group")
end
end
context "when prepended with prepend option" do
- let(:options) { { :prepend => "text prepended in add-on"} }
+ let(:options) { { :prepend => "text prepended in addon"} }
- it "should have the prepended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-prepend span.add-on", "text prepended in add-on")
- output_buffer.should_not have_tag("form div.input-append")
+ it "should have the prepended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group span.input-group-addon", "text prepended in addon")
+ output_buffer.should_not have_tag("form div.input-group")
end
end
context "when prepended and appened with prepend and append options" do
- let(:options) { { :prepend => "text prepended in add-on", :append => "text appended in add-on"} }
+ let(:options) { { :prepend => "text prepended in addon", :append => "text appended in addon"} }
- it "should have the prepended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-append span.add-on", "text appended in add-on")
- output_buffer.should have_tag("form div.input-prepend span.add-on", "text prepended in add-on")
+ it "should have the prepended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group span.input-group-addon", "text appended in addon")
+ output_buffer.should have_tag("form div.input-group span.input-group-addon", "text prepended in addon")
end
end
end
@@ -45,27 +45,27 @@
context "when appended with append_content option" do
let(:options) { { :append_content => content_tag(:a, "button appended", :class => "btn")} }
- it "should have the appended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-append a.btn", "button appended")
- output_buffer.should_not have_tag("form div.input-append span.add-on")
+ it "should have the appended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group a.btn", "button appended")
+ output_buffer.should_not have_tag("form div.input-group span.input-group-addon")
end
end
context "when prepended with prepend_content option" do
let(:options) { { :prepend_content => content_tag(:a, "button prepended", :class => "btn")} }
- it "should have the prepended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-prepend a.btn", "button prepended")
- output_buffer.should_not have_tag("form div.input-prepend span.add-on")
+ it "should have the prepended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group a.btn", "button prepended")
+ output_buffer.should_not have_tag("form div.input-group span.input-group-addon")
end
end
context "when prepended and appened with prepend and append options" do
let(:options) { { :prepend_content => content_tag(:a, "button prepended", :class => "btn"), :append_content => content_tag(:a, "button appended", :class => "btn")} }
- it "should have the prepended text to the input in an add-on span" do
- output_buffer.should have_tag("form div.input-prepend a.btn", "button prepended")
- output_buffer.should have_tag("form div.input-append a.btn", "button appended")
+ it "should have the prepended text to the input in an addon span" do
+ output_buffer.should have_tag("form div.input-group a.btn", "button prepended")
+ output_buffer.should have_tag("form div.input-group a.btn", "button appended")
end
end

0 comments on commit 4c0b491

Please sign in to comment.