33require_relative "test_helper"
44
55class BootstrapConfigurationTest < ActionView ::TestCase
6+ teardown do
7+ # Unfortunately, it seems we have to manually reset each of the configuration options
8+ # that we change in our test cases.
9+ Rails . application . config . bootstrap_form . default_form_attributes = { }
10+ Rails . application . config . bootstrap_form . bogon = nil
11+ end
12+
613 test "has default form attributes" do
714 config = BootstrapForm ::Configuration . new
815
@@ -11,7 +18,9 @@ class BootstrapConfigurationTest < ActionView::TestCase
1118
1219 test "allows to set default_form_attributes with custom value" do
1320 config = BootstrapForm ::Configuration . new
14- config . default_form_attributes = { foo : "bar" }
21+ assert_deprecated ( BootstrapForm . deprecator ) do
22+ config . default_form_attributes = { foo : "bar" }
23+ end
1524
1625 assert_equal ( { foo : "bar" } , config . default_form_attributes )
1726 end
@@ -31,4 +40,21 @@ class BootstrapConfigurationTest < ActionView::TestCase
3140 end
3241 assert_equal ( "Unsupported default_form_attributes [1, 2, 3]" , exception . message )
3342 end
43+
44+ test "Use Rails configuration" do
45+ assert_nil Rails . application . config . bootstrap_form . bogon
46+ Rails . application . config . bootstrap_form . bogon = true
47+ assert Rails . application . config . bootstrap_form . bogon
48+ end
49+
50+ test "Support legacy configuration from Rails configuration" do
51+ assert_equal ( { } , Rails . application . config . bootstrap_form . default_form_attributes )
52+
53+ config = BootstrapForm ::Configuration . new
54+ assert_deprecated ( BootstrapForm . deprecator ) do
55+ config . default_form_attributes = { foo : "bar" }
56+ end
57+
58+ assert_equal ( { foo : "bar" } , Rails . application . config . bootstrap_form . default_form_attributes )
59+ end
3460end
0 commit comments