From e83bf64b9f1ea00e6cb8d8aa7858a140729a5e24 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Sun, 4 Feb 2018 16:27:28 -0800 Subject: [PATCH 1/4] Test selects error. --- test/bootstrap_selects_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 216119e21..cd6832c20 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
From 073a1e3862aa3cdd0a1da2926ea108365b71a357 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Sun, 4 Feb 2018 16:46:51 -0800 Subject: [PATCH 2/4] Add tests for date, time, datetime selects. --- test/bootstrap_selects_test.rb | 90 ++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index cd6832c20..9c95defdb 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -245,6 +245,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 @@ -319,6 +346,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 @@ -399,6 +454,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, @builder.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 From 844e1335a2eb206dcbc8bd1971ccbffee426d5d9 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Sun, 4 Feb 2018 16:52:09 -0800 Subject: [PATCH 3/4] date, time, datetime tests pass with old implementation. --- test/bootstrap_selects_test.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 9c95defdb..a746ad24a 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -253,14 +253,14 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
-
- #{options_range(start: 2007, stop: 2017, selected: 2012)} - #{options_range(start: 1, stop: 12, selected: 2, months: true)} - #{options_range(start: 1, stop: 31, selected: 3)}
@@ -354,15 +354,15 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
-
+
- #{options_range(start: "00", stop: "23", selected: "12")} : - #{options_range(start: "00", stop: "59", selected: "00")}
@@ -462,22 +462,22 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
-
- #{options_range(start: 2007, stop: 2017, selected: 2012)} - #{options_range(start: 1, stop: 12, selected: 2, months: true)} - #{options_range(start: 1, stop: 31, selected: 3)} — - #{options_range(start: "00", stop: "23", selected: "12")} : - #{options_range(start: "00", stop: "59", selected: "00")}
@@ -485,7 +485,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
HTML - assert_equivalent_xml expected, @builder.datetime_select(:misc) + assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| f.datetime_select(:misc) } end end From 365dbf21e718cae9d7b3892e78124f583d19ce9c Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Mon, 5 Feb 2018 08:33:03 -0800 Subject: [PATCH 4/4] Tests for file and collection selects. --- test/bootstrap_fields_test.rb | 15 +++++++++++++++ test/bootstrap_selects_test.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) 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 a746ad24a..2ccfa7c8c 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -165,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
@@ -199,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