diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index 60c61fff7..98f13801b 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -65,6 +65,21 @@ class BootstrapFieldsTest < ActionView::TestCase assert_equivalent_xml expected, @builder.file_field(:misc) end + test "file fields are wrapped correctly with error" do + @user.errors.add(:misc, "error for test") + expected = <<-HTML.strip_heredoc +
+ +
+ + +
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.file_field(:misc) } + end + test "hidden fields are supported" do expected = %{} assert_equivalent_xml expected, @builder.hidden_field(:misc) diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 216119e21..2ccfa7c8c 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -24,6 +24,21 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) assert_equivalent_xml expected, @builder.time_zone_select(:misc) end + test "time zone selects are wrapped correctly with error" do + @user.errors.add(:misc, "error for test") + expected = <<-HTML.strip_heredoc +
+ +
+ + +
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.time_zone_select(:misc) } + end + test "selects are wrapped correctly" do expected = <<-HTML.strip_heredoc
@@ -150,6 +165,21 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name) end + test "collection_selects are wrapped correctly with error" do + @user.errors.add(:status, "error for test") + expected = <<-HTML.strip_heredoc +
+ +
+ + +
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.collection_select(:status, [], :id, :name) } + end + test "collection_selects with options are wrapped correctly" do expected = <<-HTML.strip_heredoc
@@ -184,6 +214,21 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s) end + test "grouped_collection_selects are wrapped correctly with error" do + @user.errors.add(:status, "error for test") + expected = <<-HTML.strip_heredoc +
+ +
+ + +
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s) } + end + test "grouped_collection_selects with options are wrapped correctly" do expected = <<-HTML.strip_heredoc
@@ -230,6 +275,33 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) end end + test "date selects are wrapped correctly with error" do + @user.errors.add(:misc, "error for test") + Timecop.freeze(Time.utc(2012, 2, 3)) do + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ + + +
+
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.date_select(:misc) } + end + end + test "date selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do expected = <<-HTML.strip_heredoc @@ -304,6 +376,34 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) end end + test "time selects are wrapped correctly with error" do + @user.errors.add(:misc, "error for test") + Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ + + + + : + +
+
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.time_select(:misc) } + end + end + test "time selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = <<-HTML.strip_heredoc @@ -384,6 +484,41 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) end end + test "datetime selects are wrapped correctly with error" do + @user.errors.add(:misc, "error for test") + Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ + + + — + + : + +
+
error for test
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.datetime_select(:misc) } + end + end + test "datetime selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = <<-HTML.strip_heredoc