require 'test_helper' class BootstrapSelectsTest < ActionView::TestCase include BootstrapForm::Helper def setup setup_test_fixture end test "time zone selects are wrapped correctly" do expected = %{
} assert_equal expected, @builder.time_zone_select(:misc) end test "selects are wrapped correctly" do expected = %{
} assert_equal expected, @builder.select(:status, [['activated', 1], ['blocked', 2]]) end test "bootstrap_specific options are handled correctly" do expected = %{
Help!
} assert_equal expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "My Status Label", help: "Help!" ) end test "selects with options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], prompt: "Please Select") end test "selects with both options and html_options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], { prompt: "Please Select" }, class: "my-select") end if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("4.1.0") test "selects with block use block as content" do expected = %{
} select = @builder.select(:status) do content_tag(:option) { 'Option 1' } + content_tag(:option) { 'Option 2' } end assert_equal expected, select end end test "selects render labels properly" do expected = %{
} assert_equal expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "User Status") end test "collection_selects are wrapped correctly" do expected = %{
} assert_equal expected, @builder.collection_select(:status, [], :id, :name) end test "collection_selects with options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.collection_select(:status, [], :id, :name, prompt: "Please Select") end test "collection_selects with options and html_options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.collection_select(:status, [], :id, :name, { prompt: "Please Select" }, class: "my-select") end test "grouped_collection_selects are wrapped correctly" do expected = %{
} assert_equal expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s) end test "grouped_collection_selects with options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, prompt: "Please Select") end test "grouped_collection_selects with options and html_options are wrapped correctly" do expected = %{
} assert_equal expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, { prompt: "Please Select" }, class: "my-select") end test "date selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do expected = %{
\n\n\n
} assert_equal expected, @builder.date_select(:misc) end end test "date selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do expected = %{
\n\n\n
} assert_equal expected, @builder.date_select(:misc, include_blank: true) end end test "date selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do expected = %{
\n\n\n
} assert_equal expected, @builder.date_select(:misc, { include_blank: true }, class: "my-date-select") end end test "time selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = %{
\n\n\n\n : \n
} assert_equal expected, @builder.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 = %{
\n\n\n\n : \n
} assert_equal expected, @builder.time_select(:misc, include_blank: true) end end test "time selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = %{
\n\n\n\n : \n
} assert_equal expected, @builder.time_select(:misc, { include_blank: true }, class: "my-time-select") end end test "datetime selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = %{
\n\n\n — \n : \n
} assert_equal 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 = %{
\n\n\n — \n : \n
} assert_equal expected, @builder.datetime_select(:misc, include_blank: true) end end test "datetime selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do expected = %{
\n\n\n — \n : \n
} assert_equal expected, @builder.datetime_select(:misc, { include_blank: true }, class: "my-datetime-select") end end end