comfy_bootstrap_form 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -2
- data/.travis.yml +2 -0
- data/Gemfile +3 -2
- data/LICENSE.md +1 -1
- data/README.md +32 -9
- data/bootstrap_form.gemspec +6 -3
- data/lib/bootstrap_form/version.rb +1 -1
- data/lib/bootstrap_form/view_helper.rb +30 -9
- metadata +5 -60
- data/demo/README.md +0 -18
- data/demo/Rakefile +0 -6
- data/demo/app/controllers/application_controller.rb +0 -2
- data/demo/app/controllers/bootstrap_controller.rb +0 -18
- data/demo/app/models/application_record.rb +0 -3
- data/demo/app/models/user.rb +0 -3
- data/demo/app/views/bootstrap/form.html.erb +0 -127
- data/demo/app/views/layouts/application.html.erb +0 -43
- data/demo/bin/bundle +0 -3
- data/demo/bin/rails +0 -4
- data/demo/bin/rake +0 -4
- data/demo/bin/setup +0 -36
- data/demo/bin/update +0 -31
- data/demo/bin/yarn +0 -11
- data/demo/config/application.rb +0 -24
- data/demo/config/boot.rb +0 -5
- data/demo/config/database.yml +0 -21
- data/demo/config/environment.rb +0 -5
- data/demo/config/environments/development.rb +0 -60
- data/demo/config/environments/test.rb +0 -48
- data/demo/config/initializers/application_controller_renderer.rb +0 -8
- data/demo/config/initializers/assets.rb +0 -14
- data/demo/config/initializers/backtrace_silencers.rb +0 -7
- data/demo/config/initializers/cookies_serializer.rb +0 -5
- data/demo/config/initializers/filter_parameter_logging.rb +0 -4
- data/demo/config/initializers/inflections.rb +0 -16
- data/demo/config/initializers/mime_types.rb +0 -4
- data/demo/config/initializers/wrap_parameters.rb +0 -14
- data/demo/config/locales/en.yml +0 -33
- data/demo/config/puma.rb +0 -56
- data/demo/config/routes.rb +0 -5
- data/demo/config/spring.rb +0 -6
- data/demo/config/storage.yml +0 -35
- data/demo/config.ru +0 -5
- data/demo/db/schema.rb +0 -14
- data/demo/form_preview_horizontal.png +0 -0
- data/demo/form_preview_horizontal_with_errors.png +0 -0
- data/demo/form_preview_inline.png +0 -0
- data/demo/form_preview_vertical.png +0 -0
- data/demo/log/.keep +0 -0
- data/demo/package.json +0 -5
- data/demo/public/favicon.ico +0 -0
- data/test/bootstrap_form/bootstrap_options_test.rb +0 -114
- data/test/bootstrap_form/fields_test.rb +0 -304
- data/test/bootstrap_form/fields_with_errors_test.rb +0 -111
- data/test/bootstrap_form/form_builder_test.rb +0 -17
- data/test/bootstrap_form/horizontal_form_test.rb +0 -160
- data/test/bootstrap_form/inline_form_test.rb +0 -68
- data/test/bootstrap_form/input_group_test.rb +0 -56
- data/test/bootstrap_form/radios_and_checkboxes_test.rb +0 -207
- data/test/bootstrap_form/submit_test.rb +0 -59
- data/test/bootstrap_form/view_helpers_test.rb +0 -99
- data/test/gemfiles/5.2.gemfile +0 -14
- data/test/test_helper.rb +0 -48
@@ -1,111 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class FieldsWithErrorsTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@user = User.new
|
7
|
-
@user.errors.add(:test, "invalid")
|
8
|
-
|
9
|
-
@builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
|
10
|
-
|
11
|
-
@original_proc = ActionView::Base.field_error_proc
|
12
|
-
ActionView::Base.field_error_proc = proc { |input, _instance| input }
|
13
|
-
end
|
14
|
-
|
15
|
-
teardown do
|
16
|
-
ActionView::Base.field_error_proc = @original_proc
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_text_field_with_error
|
20
|
-
actual = @builder.text_field(:test)
|
21
|
-
expected = <<-HTML
|
22
|
-
<div class="form-group">
|
23
|
-
<label for="user_test">Test</label>
|
24
|
-
<input class="form-control is-invalid" id="user_test" name="user[test]" type="text"/>
|
25
|
-
<div class="invalid-feedback">invalid</div>
|
26
|
-
</div>
|
27
|
-
HTML
|
28
|
-
assert_xml_equal expected, actual
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_check_box_with_error
|
32
|
-
actual = @builder.check_box(:test)
|
33
|
-
expected = <<-HTML
|
34
|
-
<fieldset class="form-group">
|
35
|
-
<div class="form-check">
|
36
|
-
<input name="user[test]" type="hidden" value="0"/>
|
37
|
-
<input class="form-check-input is-invalid" id="user_test" name="user[test]" type="checkbox" value="1"/>
|
38
|
-
<label class="form-check-label" for="user_test">Test</label>
|
39
|
-
<div class="invalid-feedback">invalid</div>
|
40
|
-
</div>
|
41
|
-
</fieldset>
|
42
|
-
HTML
|
43
|
-
assert_xml_equal expected, actual
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_collection_radio_buttons_with_error_and_help
|
47
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, bootstrap: { help: "help text" })
|
48
|
-
expected = <<-HTML
|
49
|
-
<fieldset class="form-group">
|
50
|
-
<legend class="col-form-label pt-0">Test</legend>
|
51
|
-
<div class="form-check">
|
52
|
-
<input class="form-check-input is-invalid" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
53
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
54
|
-
</div>
|
55
|
-
<div class="form-check">
|
56
|
-
<input class="form-check-input is-invalid" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
57
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
58
|
-
<div class="invalid-feedback">invalid</div>
|
59
|
-
<small class="form-text text-muted">help text</small>
|
60
|
-
</div>
|
61
|
-
</fieldset>
|
62
|
-
HTML
|
63
|
-
assert_xml_equal expected, actual
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_collection_radio_buttons_inline_with_error_and_help
|
67
|
-
options = { bootstrap: {
|
68
|
-
check_inline: true,
|
69
|
-
help: "help text"
|
70
|
-
} }
|
71
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
72
|
-
expected = <<-HTML
|
73
|
-
<fieldset class="form-group">
|
74
|
-
<legend class="col-form-label pt-0">Test</legend>
|
75
|
-
<div class="form-check form-check-inline">
|
76
|
-
<input class="form-check-input is-invalid" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
77
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
78
|
-
</div>
|
79
|
-
<div class="form-check form-check-inline">
|
80
|
-
<input class="form-check-input is-invalid" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
81
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
82
|
-
</div>
|
83
|
-
<div class="invalid-feedback">invalid</div>
|
84
|
-
<small class="form-text text-muted">help text</small>
|
85
|
-
</fieldset>
|
86
|
-
HTML
|
87
|
-
assert_xml_equal expected, actual
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_text_field_with_input_group_error
|
91
|
-
actual = @builder.text_field(:test, bootstrap: { prepend: "A", append: "Z", help: "help text" })
|
92
|
-
expected = <<-HTML
|
93
|
-
<div class="form-group">
|
94
|
-
<label for="user_test">Test</label>
|
95
|
-
<div class="input-group">
|
96
|
-
<div class="input-group-prepend">
|
97
|
-
<span class="input-group-text">A</span>
|
98
|
-
</div>
|
99
|
-
<input class="form-control is-invalid" id="user_test" name="user[test]" type="text"/>
|
100
|
-
<div class="input-group-append">
|
101
|
-
<span class="input-group-text">Z</span>
|
102
|
-
</div>
|
103
|
-
<div class="invalid-feedback">invalid</div>
|
104
|
-
</div>
|
105
|
-
<small class="form-text text-muted">help text</small>
|
106
|
-
</div>
|
107
|
-
HTML
|
108
|
-
assert_xml_equal expected, actual
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class FormBuilderTest < ActionView::TestCase
|
4
|
-
|
5
|
-
def test_initialization
|
6
|
-
builder = BootstrapForm::FormBuilder.new(nil, nil, self, {})
|
7
|
-
assert builder.form_bootstrap.is_a?(BootstrapForm::BootstrapOptions)
|
8
|
-
assert_equal "vertical", builder.form_bootstrap.layout
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_initialization_with_options
|
12
|
-
options = { bootstrap: { layout: "horizontal" } }
|
13
|
-
builder = BootstrapForm::FormBuilder.new(nil, nil, self, options)
|
14
|
-
assert_equal "horizontal", builder.form_bootstrap.layout
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,160 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class HorizontalFormTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@user = User.new
|
7
|
-
@builder = BootstrapForm::FormBuilder.new(:user, @user, self, bootstrap: { layout: :horizontal })
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_text_field
|
11
|
-
actual = @builder.text_field(:email)
|
12
|
-
expected = <<-HTML
|
13
|
-
<div class="form-group row">
|
14
|
-
<label class="col-form-label col-sm-2 text-sm-right" for="user_email">Email</label>
|
15
|
-
<div class="col-sm-10">
|
16
|
-
<input class="form-control" type="text" name="user[email]" id="user_email" />
|
17
|
-
</div>
|
18
|
-
</div>
|
19
|
-
HTML
|
20
|
-
assert_xml_equal expected, actual
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_text_field_with_no_label
|
24
|
-
actual = @builder.text_field(:email, bootstrap: { label: { hide: true } })
|
25
|
-
expected = <<-HTML
|
26
|
-
<div class="form-group row">
|
27
|
-
<label class="sr-only col-form-label col-sm-2 text-sm-right" for="user_email">Email</label>
|
28
|
-
<div class="col-sm-10 offset-sm-2">
|
29
|
-
<input class="form-control" type="text" name="user[email]" id="user_email" />
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
HTML
|
33
|
-
assert_xml_equal expected, actual
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_check_box
|
37
|
-
actual = @builder.check_box(:terms)
|
38
|
-
expected = <<-HTML
|
39
|
-
<fieldset class="form-group row">
|
40
|
-
<div class="col-sm-10 offset-sm-2">
|
41
|
-
<div class="form-check">
|
42
|
-
<input name="user[terms]" type="hidden" value="0"/>
|
43
|
-
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1"/>
|
44
|
-
<label class="form-check-label" for="user_terms">Terms</label>
|
45
|
-
</div>
|
46
|
-
</div>
|
47
|
-
</fieldset>
|
48
|
-
HTML
|
49
|
-
assert_xml_equal expected, actual
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_collection_radio_buttons
|
53
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize)
|
54
|
-
expected = <<-HTML
|
55
|
-
<fieldset class="form-group">
|
56
|
-
<div class="row">
|
57
|
-
<legend class="col-form-label pt-0 col-sm-2 text-sm-right">Test</legend>
|
58
|
-
<div class="col-sm-10">
|
59
|
-
<div class="form-check">
|
60
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
61
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
62
|
-
</div>
|
63
|
-
<div class="form-check">
|
64
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
65
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
66
|
-
</div>
|
67
|
-
</div>
|
68
|
-
</div>
|
69
|
-
</fieldset>
|
70
|
-
HTML
|
71
|
-
assert_xml_equal expected, actual
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_collection_check_boxes_with_no_label
|
75
|
-
actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize, bootstrap: { label: { hide: true } })
|
76
|
-
expected = <<-HTML
|
77
|
-
<input id="user_test" multiple="multiple" name="user[test][]" type="hidden" value=""/>
|
78
|
-
<fieldset class="form-group">
|
79
|
-
<div class="row">
|
80
|
-
<div class="col-sm-10 offset-sm-2">
|
81
|
-
<div class="form-check">
|
82
|
-
<input class="form-check-input" id="user_test_a" name="user[test][]" type="checkbox" value="a"/>
|
83
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
84
|
-
</div>
|
85
|
-
<div class="form-check">
|
86
|
-
<input class="form-check-input" id="user_test_b" name="user[test][]" type="checkbox" value="b"/>
|
87
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
88
|
-
</div>
|
89
|
-
</div>
|
90
|
-
</div>
|
91
|
-
</fieldset>
|
92
|
-
HTML
|
93
|
-
assert_xml_equal expected, actual
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_submit
|
97
|
-
actual = @builder.submit
|
98
|
-
expected = <<-HTML
|
99
|
-
<div class="form-group row">
|
100
|
-
<div class="col-sm-10 offset-sm-2">
|
101
|
-
<input class="btn" data-disable-with="Create User" name="commit" type="submit" value="Create User"/>
|
102
|
-
</div>
|
103
|
-
</div>
|
104
|
-
HTML
|
105
|
-
assert_xml_equal expected, actual
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_input_group_with_options
|
109
|
-
options = { bootstrap: {
|
110
|
-
prepend: "prepend",
|
111
|
-
append: "append",
|
112
|
-
help: "help me"
|
113
|
-
} }
|
114
|
-
actual = @builder.text_field(:test, options)
|
115
|
-
expected = <<-HTML
|
116
|
-
<div class="form-group row">
|
117
|
-
<label class="col-form-label col-sm-2 text-sm-right" for="user_test">Test</label>
|
118
|
-
<div class="col-sm-10">
|
119
|
-
<div class="input-group">
|
120
|
-
<div class="input-group-prepend">
|
121
|
-
<span class="input-group-text">prepend</span>
|
122
|
-
</div>
|
123
|
-
<input class="form-control" id="user_test" name="user[test]" type="text"/>
|
124
|
-
<div class="input-group-append">
|
125
|
-
<span class="input-group-text">append</span>
|
126
|
-
</div>
|
127
|
-
</div>
|
128
|
-
<small class="form-text text-muted">help me</small>
|
129
|
-
</div>
|
130
|
-
</div>
|
131
|
-
HTML
|
132
|
-
assert_xml_equal expected, actual
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_form_group
|
136
|
-
actual = @builder.form_group do
|
137
|
-
"test"
|
138
|
-
end
|
139
|
-
expected = <<-HTML
|
140
|
-
<div class="form-group row">
|
141
|
-
<div class="col-sm-10 offset-sm-2">test</div>
|
142
|
-
</div>
|
143
|
-
HTML
|
144
|
-
assert_xml_equal expected, actual
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_form_group_with_label
|
148
|
-
actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
|
149
|
-
"test"
|
150
|
-
end
|
151
|
-
expected = <<-HTML
|
152
|
-
<div class="form-group row">
|
153
|
-
<label class="col-form-label col-sm-2 text-sm-right">Test</label>
|
154
|
-
<div class="col-sm-10">test</div>
|
155
|
-
</div>
|
156
|
-
HTML
|
157
|
-
assert_xml_equal expected, actual
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class InlineFormTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@user = User.new
|
7
|
-
@builder = BootstrapForm::FormBuilder.new(:user, @user, self, bootstrap: { layout: :inline })
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_text_field
|
11
|
-
actual = @builder.text_field(:email)
|
12
|
-
expected = <<-HTML
|
13
|
-
<div class="form-group mr-sm-2">
|
14
|
-
<label class="mr-sm-2" for="user_email">Email</label>
|
15
|
-
<input class="form-control" id="user_email" name="user[email]" type="text"/>
|
16
|
-
</div>
|
17
|
-
HTML
|
18
|
-
assert_xml_equal expected, actual
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_check_box
|
22
|
-
actual = @builder.check_box(:terms)
|
23
|
-
expected = <<-HTML
|
24
|
-
<fieldset class="form-group mr-sm-2">
|
25
|
-
<div class="form-check">
|
26
|
-
<input name="user[terms]" type="hidden" value="0"/>
|
27
|
-
<input class="form-check-input" id="user_terms" name="user[terms]" type="checkbox" value="1"/>
|
28
|
-
<label class="form-check-label" for="user_terms">Terms</label>
|
29
|
-
</div>
|
30
|
-
</fieldset>
|
31
|
-
HTML
|
32
|
-
assert_xml_equal expected, actual
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_submit
|
36
|
-
actual = @builder.submit
|
37
|
-
expected = <<-HTML
|
38
|
-
<div class="form-group">
|
39
|
-
<input class="btn" data-disable-with="Create User" name="commit" type="submit" value="Create User"/>
|
40
|
-
</div>
|
41
|
-
HTML
|
42
|
-
assert_xml_equal expected, actual
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_form_group
|
46
|
-
actual = @builder.form_group do
|
47
|
-
"test"
|
48
|
-
end
|
49
|
-
expected = <<-HTML
|
50
|
-
<div class="form-group mr-sm-2">test</div>
|
51
|
-
HTML
|
52
|
-
assert_xml_equal expected, actual
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_form_group_with_label
|
56
|
-
actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
|
57
|
-
"test"
|
58
|
-
end
|
59
|
-
expected = <<-HTML
|
60
|
-
<div class="form-group mr-sm-2">
|
61
|
-
<label class="mr-sm-2">Test</label>
|
62
|
-
test
|
63
|
-
</div>
|
64
|
-
HTML
|
65
|
-
assert_xml_equal expected, actual
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class InputGroupTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@user = User.new
|
7
|
-
@builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_input_group
|
11
|
-
options = { bootstrap: {
|
12
|
-
prepend: "prepend",
|
13
|
-
append: "append"
|
14
|
-
} }
|
15
|
-
actual = @builder.text_field(:test, options)
|
16
|
-
expected = <<-HTML
|
17
|
-
<div class="form-group">
|
18
|
-
<label for="user_test">Test</label>
|
19
|
-
<div class="input-group">
|
20
|
-
<div class="input-group-prepend">
|
21
|
-
<span class="input-group-text">prepend</span>
|
22
|
-
</div>
|
23
|
-
<input class="form-control" id="user_test" name="user[test]" type="text"/>
|
24
|
-
<div class="input-group-append">
|
25
|
-
<span class="input-group-text">append</span>
|
26
|
-
</div>
|
27
|
-
</div>
|
28
|
-
</div>
|
29
|
-
HTML
|
30
|
-
assert_xml_equal expected, actual
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_input_group_with_html
|
34
|
-
options = { bootstrap: {
|
35
|
-
prepend: { html: "<button>Go</button>".html_safe },
|
36
|
-
append: { html: "<button>Stop</button>".html_safe }
|
37
|
-
} }
|
38
|
-
actual = @builder.text_field(:test, options)
|
39
|
-
expected = <<-HTML
|
40
|
-
<div class="form-group">
|
41
|
-
<label for="user_test">Test</label>
|
42
|
-
<div class="input-group">
|
43
|
-
<div class="input-group-prepend">
|
44
|
-
<button>Go</button>
|
45
|
-
</div>
|
46
|
-
<input class="form-control" id="user_test" name="user[test]" type="text"/>
|
47
|
-
<div class="input-group-append">
|
48
|
-
<button>Stop</button>
|
49
|
-
</div>
|
50
|
-
</div>
|
51
|
-
</div>
|
52
|
-
HTML
|
53
|
-
assert_xml_equal expected, actual
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,207 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class RadiosAndCheckboxessTest < ActionView::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@user = User.new
|
7
|
-
@builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_checkbox
|
11
|
-
actual = @builder.check_box(:test)
|
12
|
-
expected = <<-HTML
|
13
|
-
<fieldset class="form-group">
|
14
|
-
<div class="form-check">
|
15
|
-
<input name="user[test]" type="hidden" value="0"/>
|
16
|
-
<input class="form-check-input" id="user_test" name="user[test]" type="checkbox" value="1"/>
|
17
|
-
<label class="form-check-label" for="user_test">Test</label>
|
18
|
-
</div>
|
19
|
-
</fieldset>
|
20
|
-
HTML
|
21
|
-
assert_xml_equal expected, actual
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_checkbox_with_label
|
25
|
-
actual = @builder.check_box(:test, bootstrap: { label: { text: "Custom" } })
|
26
|
-
expected = <<-HTML
|
27
|
-
<fieldset class="form-group">
|
28
|
-
<div class="form-check">
|
29
|
-
<input name="user[test]" type="hidden" value="0"/>
|
30
|
-
<input class="form-check-input" id="user_test" name="user[test]" type="checkbox" value="1"/>
|
31
|
-
<label class="form-check-label" for="user_test">Custom</label>
|
32
|
-
</div>
|
33
|
-
</fieldset>
|
34
|
-
HTML
|
35
|
-
assert_xml_equal expected, actual
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_checkbox_with_help
|
39
|
-
actual = @builder.check_box(:test, bootstrap: { help: "help me" })
|
40
|
-
expected = <<-HTML
|
41
|
-
<fieldset class="form-group">
|
42
|
-
<div class="form-check">
|
43
|
-
<input name="user[test]" type="hidden" value="0"/>
|
44
|
-
<input class="form-check-input" id="user_test" name="user[test]" type="checkbox" value="1"/>
|
45
|
-
<label class="form-check-label" for="user_test">Test</label>
|
46
|
-
<small class="form-text text-muted">help me</small>
|
47
|
-
</div>
|
48
|
-
</fieldset>
|
49
|
-
HTML
|
50
|
-
assert_xml_equal expected, actual
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_collection_check_boxes
|
54
|
-
actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize)
|
55
|
-
expected = <<-HTML
|
56
|
-
<input id="user_test" multiple="multiple" name="user[test][]" type="hidden" value=""/>
|
57
|
-
<fieldset class="form-group">
|
58
|
-
<legend class="col-form-label pt-0">Test</legend>
|
59
|
-
<div class="form-check">
|
60
|
-
<input class="form-check-input" id="user_test_a" name="user[test][]" type="checkbox" value="a"/>
|
61
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
62
|
-
</div>
|
63
|
-
<div class="form-check">
|
64
|
-
<input class="form-check-input" id="user_test_b" name="user[test][]" type="checkbox" value="b"/>
|
65
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
66
|
-
</div>
|
67
|
-
</fieldset>
|
68
|
-
HTML
|
69
|
-
assert_xml_equal expected, actual
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_collection_checkboxes_without_hidden_field
|
73
|
-
actual = @builder.collection_check_boxes(:test, %w[a b], :to_s, :titleize, include_hidden: false)
|
74
|
-
expected = <<-HTML
|
75
|
-
<fieldset class="form-group">
|
76
|
-
<legend class="col-form-label pt-0">Test</legend>
|
77
|
-
<div class="form-check">
|
78
|
-
<input class="form-check-input" id="user_test_a" name="user[test][]" type="checkbox" value="a"/>
|
79
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
80
|
-
</div>
|
81
|
-
<div class="form-check">
|
82
|
-
<input class="form-check-input" id="user_test_b" name="user[test][]" type="checkbox" value="b"/>
|
83
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
84
|
-
</div>
|
85
|
-
</fieldset>
|
86
|
-
HTML
|
87
|
-
assert_xml_equal expected, actual
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_radio_buttons
|
91
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize)
|
92
|
-
expected = <<-HTML
|
93
|
-
<fieldset class="form-group">
|
94
|
-
<legend class="col-form-label pt-0">Test</legend>
|
95
|
-
<div class="form-check">
|
96
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
97
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
98
|
-
</div>
|
99
|
-
<div class="form-check">
|
100
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
101
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
102
|
-
</div>
|
103
|
-
</fieldset>
|
104
|
-
HTML
|
105
|
-
assert_xml_equal expected, actual
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_radio_buttons_inline
|
109
|
-
options = { bootstrap: { check_inline: true } }
|
110
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
111
|
-
expected = <<-HTML
|
112
|
-
<fieldset class="form-group">
|
113
|
-
<legend class="col-form-label pt-0">Test</legend>
|
114
|
-
<div class="form-check form-check-inline">
|
115
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
116
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
117
|
-
</div>
|
118
|
-
<div class="form-check form-check-inline">
|
119
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
120
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
121
|
-
</div>
|
122
|
-
</fieldset>
|
123
|
-
HTML
|
124
|
-
assert_xml_equal expected, actual
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_radio_buttons_custom_label
|
128
|
-
options = { bootstrap: { label: { text: "Custom" } } }
|
129
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
130
|
-
expected = <<-HTML
|
131
|
-
<fieldset class="form-group">
|
132
|
-
<legend class="col-form-label pt-0">Custom</legend>
|
133
|
-
<div class="form-check">
|
134
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
135
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
136
|
-
</div>
|
137
|
-
<div class="form-check">
|
138
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
139
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
140
|
-
</div>
|
141
|
-
</fieldset>
|
142
|
-
HTML
|
143
|
-
assert_xml_equal expected, actual
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_radio_buttons_no_label
|
147
|
-
options = { bootstrap: { label: { hide: true } } }
|
148
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
149
|
-
expected = <<-HTML
|
150
|
-
<fieldset class="form-group">
|
151
|
-
<div class="form-check">
|
152
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
153
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
154
|
-
</div>
|
155
|
-
<div class="form-check">
|
156
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
157
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
158
|
-
</div>
|
159
|
-
</fieldset>
|
160
|
-
HTML
|
161
|
-
assert_xml_equal expected, actual
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_radio_buttons_with_help
|
165
|
-
options = { bootstrap: { help: "help me" } }
|
166
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
167
|
-
expected = <<-HTML
|
168
|
-
<fieldset class="form-group">
|
169
|
-
<legend class="col-form-label pt-0">Test</legend>
|
170
|
-
<div class="form-check">
|
171
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
172
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
173
|
-
</div>
|
174
|
-
<div class="form-check">
|
175
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
176
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
177
|
-
<small class="form-text text-muted">help me</small>
|
178
|
-
</div>
|
179
|
-
</fieldset>
|
180
|
-
HTML
|
181
|
-
assert_xml_equal expected, actual
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_radio_buttons_with_inline_help
|
185
|
-
options = { bootstrap: {
|
186
|
-
check_inline: true,
|
187
|
-
help: "help me"
|
188
|
-
} }
|
189
|
-
actual = @builder.collection_radio_buttons(:test, %w[a b], :to_s, :titleize, options)
|
190
|
-
expected = <<-HTML
|
191
|
-
<fieldset class="form-group">
|
192
|
-
<legend class="col-form-label pt-0">Test</legend>
|
193
|
-
<div class="form-check form-check-inline">
|
194
|
-
<input class="form-check-input" id="user_test_a" name="user[test]" type="radio" value="a"/>
|
195
|
-
<label class="form-check-label" for="user_test_a">A</label>
|
196
|
-
</div>
|
197
|
-
<div class="form-check form-check-inline">
|
198
|
-
<input class="form-check-input" id="user_test_b" name="user[test]" type="radio" value="b"/>
|
199
|
-
<label class="form-check-label" for="user_test_b">B</label>
|
200
|
-
</div>
|
201
|
-
<small class="form-text text-muted">help me</small>
|
202
|
-
</fieldset>
|
203
|
-
HTML
|
204
|
-
assert_xml_equal expected, actual
|
205
|
-
end
|
206
|
-
|
207
|
-
end
|