comfy_bootstrap_form 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +3 -2
  5. data/LICENSE.md +1 -1
  6. data/README.md +32 -9
  7. data/bootstrap_form.gemspec +6 -3
  8. data/lib/bootstrap_form/version.rb +1 -1
  9. data/lib/bootstrap_form/view_helper.rb +30 -9
  10. metadata +5 -60
  11. data/demo/README.md +0 -18
  12. data/demo/Rakefile +0 -6
  13. data/demo/app/controllers/application_controller.rb +0 -2
  14. data/demo/app/controllers/bootstrap_controller.rb +0 -18
  15. data/demo/app/models/application_record.rb +0 -3
  16. data/demo/app/models/user.rb +0 -3
  17. data/demo/app/views/bootstrap/form.html.erb +0 -127
  18. data/demo/app/views/layouts/application.html.erb +0 -43
  19. data/demo/bin/bundle +0 -3
  20. data/demo/bin/rails +0 -4
  21. data/demo/bin/rake +0 -4
  22. data/demo/bin/setup +0 -36
  23. data/demo/bin/update +0 -31
  24. data/demo/bin/yarn +0 -11
  25. data/demo/config/application.rb +0 -24
  26. data/demo/config/boot.rb +0 -5
  27. data/demo/config/database.yml +0 -21
  28. data/demo/config/environment.rb +0 -5
  29. data/demo/config/environments/development.rb +0 -60
  30. data/demo/config/environments/test.rb +0 -48
  31. data/demo/config/initializers/application_controller_renderer.rb +0 -8
  32. data/demo/config/initializers/assets.rb +0 -14
  33. data/demo/config/initializers/backtrace_silencers.rb +0 -7
  34. data/demo/config/initializers/cookies_serializer.rb +0 -5
  35. data/demo/config/initializers/filter_parameter_logging.rb +0 -4
  36. data/demo/config/initializers/inflections.rb +0 -16
  37. data/demo/config/initializers/mime_types.rb +0 -4
  38. data/demo/config/initializers/wrap_parameters.rb +0 -14
  39. data/demo/config/locales/en.yml +0 -33
  40. data/demo/config/puma.rb +0 -56
  41. data/demo/config/routes.rb +0 -5
  42. data/demo/config/spring.rb +0 -6
  43. data/demo/config/storage.yml +0 -35
  44. data/demo/config.ru +0 -5
  45. data/demo/db/schema.rb +0 -14
  46. data/demo/form_preview_horizontal.png +0 -0
  47. data/demo/form_preview_horizontal_with_errors.png +0 -0
  48. data/demo/form_preview_inline.png +0 -0
  49. data/demo/form_preview_vertical.png +0 -0
  50. data/demo/log/.keep +0 -0
  51. data/demo/package.json +0 -5
  52. data/demo/public/favicon.ico +0 -0
  53. data/test/bootstrap_form/bootstrap_options_test.rb +0 -114
  54. data/test/bootstrap_form/fields_test.rb +0 -304
  55. data/test/bootstrap_form/fields_with_errors_test.rb +0 -111
  56. data/test/bootstrap_form/form_builder_test.rb +0 -17
  57. data/test/bootstrap_form/horizontal_form_test.rb +0 -160
  58. data/test/bootstrap_form/inline_form_test.rb +0 -68
  59. data/test/bootstrap_form/input_group_test.rb +0 -56
  60. data/test/bootstrap_form/radios_and_checkboxes_test.rb +0 -207
  61. data/test/bootstrap_form/submit_test.rb +0 -59
  62. data/test/bootstrap_form/view_helpers_test.rb +0 -99
  63. data/test/gemfiles/5.2.gemfile +0 -14
  64. data/test/test_helper.rb +0 -48
@@ -1,5 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- resources :users
3
-
4
- root to: "bootstrap#form"
5
- end
@@ -1,6 +0,0 @@
1
- %w[
2
- .ruby-version
3
- .rbenv-vars
4
- tmp/restart.txt
5
- tmp/caching-dev.txt
6
- ].each { |path| Spring.watch(path) }
@@ -1,35 +0,0 @@
1
- test:
2
- service: Disk
3
- root: <%= Rails.root.join("tmp/storage") %>
4
-
5
- local:
6
- service: Disk
7
- root: <%= Rails.root.join("storage") %>
8
-
9
- # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
10
- # amazon:
11
- # service: S3
12
- # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
13
- # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
14
- # region: us-east-1
15
- # bucket: your_own_bucket
16
-
17
- # Remember not to checkin your GCS keyfile to a repository
18
- # google:
19
- # service: GCS
20
- # project: your_project
21
- # keyfile: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
- # bucket: your_own_bucket
23
-
24
- # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
- # microsoft:
26
- # service: AzureStorage
27
- # path: your_azure_storage_path
28
- # storage_account_name: your_account_name
29
- # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
30
- # container: your_container_name
31
-
32
- # mirror:
33
- # service: Mirror
34
- # primary: local
35
- # mirrors: [ amazon, google, microsoft ]
data/demo/config.ru DELETED
@@ -1,5 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require_relative 'config/environment'
4
-
5
- run Rails.application
data/demo/db/schema.rb DELETED
@@ -1,14 +0,0 @@
1
- ActiveRecord::Schema.define(version: 1) do
2
-
3
- create_table :users, force: :cascade do |t|
4
- t.string :email
5
- t.string :password
6
- t.boolean :terms, default: false
7
- t.string :test
8
- t.string :bio
9
- t.string :color
10
- t.string :locale
11
- t.timestamps
12
- end
13
-
14
- end
Binary file
Binary file
Binary file
data/demo/log/.keep DELETED
File without changes
data/demo/package.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "name": "dummy",
3
- "private": true,
4
- "dependencies": {}
5
- }
File without changes
@@ -1,114 +0,0 @@
1
- require_relative "../test_helper"
2
-
3
- class BootstrapOptionsTest < ActionView::TestCase
4
-
5
- setup do
6
- options = { bootstrap: {
7
- layout: "horizontal",
8
- label: { hide: true }
9
- } }
10
- @builder = BootstrapForm::FormBuilder.new(:user, nil, self, options)
11
- end
12
-
13
- def test_defaults
14
- options = BootstrapForm::BootstrapOptions.new
15
- assert_equal "vertical", options.layout
16
- assert_equal "col-sm-2", options.label_col_class
17
- assert_equal "col-sm-10", options.control_col_class
18
- assert_equal "text-sm-right", options.label_align_class
19
- assert_equal "mr-sm-2", options.inline_margin_class
20
- assert_equal ({}), options.label
21
- assert_nil options.append
22
- assert_nil options.prepend
23
- assert_nil options.help
24
- refute options.check_inline
25
- end
26
-
27
- def test_with_set_options
28
- options = BootstrapForm::BootstrapOptions.new(
29
- layout: "horizontal",
30
- label_col_class: "col-md-4",
31
- control_col_class: "col-md-8",
32
- label_align_class: "text-md-left",
33
- inline_margin_class: "mr-md-4",
34
- label: { text: "test" },
35
- append: "a",
36
- prepend: "z",
37
- help: "help text",
38
- check_inline: "true"
39
- )
40
- assert_equal "horizontal", options.layout
41
- assert_equal "col-md-4", options.label_col_class
42
- assert_equal "col-md-8", options.control_col_class
43
- assert_equal "text-md-left", options.label_align_class
44
- assert_equal "mr-md-4", options.inline_margin_class
45
- assert_equal ({ text: "test" }), options.label
46
- assert_equal "a", options.append
47
- assert_equal "z", options.prepend
48
- assert_equal "help text", options.help
49
- assert options.check_inline
50
- end
51
-
52
- def test_with_set_invalid_options
53
- options = BootstrapForm::BootstrapOptions.new(invalid: "invalid")
54
- refute options.respond_to?(:invalid)
55
- end
56
-
57
- def test_horizontal
58
- options = BootstrapForm::BootstrapOptions.new
59
- refute options.horizontal?
60
-
61
- options = BootstrapForm::BootstrapOptions.new(layout: "horizontal")
62
- assert options.horizontal?
63
- end
64
-
65
- def test_inline
66
- options = BootstrapForm::BootstrapOptions.new
67
- refute options.inline?
68
-
69
- options = BootstrapForm::BootstrapOptions.new(layout: "inline")
70
- assert options.inline?
71
- end
72
-
73
- def test_offset_col_class
74
- options = BootstrapForm::BootstrapOptions.new
75
- assert_equal "offset-sm-2", options.offset_col_class
76
-
77
- options = BootstrapForm::BootstrapOptions.new(label_col_class: "col-md-4")
78
- assert_equal "offset-md-4", options.offset_col_class
79
- end
80
-
81
- def scoped
82
- options = BootstrapForm::BootstrapOptions.new
83
- refute options.horizontal?
84
-
85
- scoped_options = options.scoped(layout: "vertical")
86
- assert scoped_options.horizontal?
87
- refute options.horizontal?
88
- end
89
-
90
- def test_form_fields_global_options
91
- actual = @builder.text_field :email
92
- expected = <<-HTML
93
- <div class="form-group row">
94
- <label class="sr-only col-form-label col-sm-2 text-sm-right" for="user_email">Email</label>
95
- <div class="col-sm-10 offset-sm-2">
96
- <input class="form-control" id="user_email" name="user[email]" type="text"/>
97
- </div>
98
- </div>
99
- HTML
100
- assert_xml_equal expected, actual
101
- end
102
-
103
- def test_form_fields_global_options_override
104
- actual = @builder.text_field :email, bootstrap: { layout: "vertical" }
105
- expected = <<-HTML
106
- <div class="form-group">
107
- <label class="sr-only" for="user_email">Email</label>
108
- <input class="form-control" id="user_email" name="user[email]" type="text"/>
109
- </div>
110
- HTML
111
- assert_xml_equal expected, actual
112
- end
113
-
114
- end
@@ -1,304 +0,0 @@
1
- require_relative "../test_helper"
2
-
3
- class FieldsTest < ActionView::TestCase
4
-
5
- setup do
6
- @user = User.new
7
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
8
- end
9
-
10
- def test_text_field
11
- actual = @builder.text_field(:email)
12
- expected = <<-HTML
13
- <div class="form-group">
14
- <label for="user_email">Email</label>
15
- <input class="form-control" type="text" name="user[email]" id="user_email" />
16
- </div>
17
- HTML
18
- assert_xml_equal expected, actual
19
- end
20
-
21
- def test_text_field_label_text
22
- actual = @builder.text_field(:email, bootstrap: { label: { text: "Custom Label" } })
23
- expected = <<-HTML
24
- <div class="form-group">
25
- <label for="user_email">Custom Label</label>
26
- <input class="form-control" type="text" name="user[email]" id="user_email" />
27
- </div>
28
- HTML
29
- assert_xml_equal expected, actual
30
- end
31
-
32
- def test_text_field_label_css_class
33
- actual = @builder.text_field(:email, bootstrap: { label: { class: "custom_class" } })
34
- expected = <<-HTML
35
- <div class="form-group">
36
- <label class="custom_class" for="user_email">Email</label>
37
- <input class="form-control" type="text" name="user[email]" id="user_email" />
38
- </div>
39
- HTML
40
- assert_xml_equal expected, actual
41
- end
42
-
43
- def test_text_field_label_hide
44
- actual = @builder.text_field(:email, bootstrap: { label: { hide: true } })
45
- expected = <<-HTML
46
- <div class="form-group">
47
- <label class="sr-only" for="user_email">Email</label>
48
- <input class="form-control" type="text" name="user[email]" id="user_email" />
49
- </div>
50
- HTML
51
- assert_xml_equal expected, actual
52
- end
53
-
54
- def test_text_field_control_css_class
55
- actual = @builder.text_field(:email, class: "custom-class")
56
- expected = <<-HTML
57
- <div class="form-group">
58
- <label for="user_email">Email</label>
59
- <input class="custom-class form-control" type="text" name="user[email]" id="user_email" />
60
- </div>
61
- HTML
62
- assert_xml_equal expected, actual
63
- end
64
-
65
- def test_text_field_help_text
66
- actual = @builder.text_field(:email, bootstrap: { help: "help text" })
67
- expected = <<-HTML
68
- <div class="form-group">
69
- <label for="user_email">Email</label>
70
- <input class="form-control" type="text" name="user[email]" id="user_email" />
71
- <small class="form-text text-muted">help text</small>
72
- </div>
73
- HTML
74
- assert_xml_equal expected, actual
75
- end
76
-
77
- def test_select
78
- actual = @builder.select(:test, %w[a b])
79
- expected = <<-HTML
80
- <div class="form-group">
81
- <label for="user_test">Test</label>
82
- <select class="form-control" id="user_test" name="user[test]">
83
- <option value="a">a</option>
84
- <option value="b">b</option>
85
- </select>
86
- </div>
87
- HTML
88
- assert_xml_equal expected, actual
89
- end
90
-
91
- def test_select_control_css_class
92
- actual = @builder.select(:test, %w[a b], {}, class: "custom")
93
- expected = <<-HTML
94
- <div class="form-group">
95
- <label for="user_test">Test</label>
96
- <select class="custom form-control" id="user_test" name="user[test]">
97
- <option value="a">a</option>
98
- <option value="b">b</option>
99
- </select>
100
- </div>
101
- HTML
102
- assert_xml_equal expected, actual
103
- end
104
-
105
- def test_color_field
106
- actual = @builder.color_field(:test)
107
- expected = <<-HTML
108
- <div class="form-group">
109
- <label for="user_test">Test</label>
110
- <input class="form-control" type="color" name="user[test]" id="user_test" value="#000000"/>
111
- </div>
112
- HTML
113
- assert_xml_equal expected, actual
114
- end
115
-
116
- def test_date_field
117
- actual = @builder.date_field(:test)
118
- expected = <<-HTML
119
- <div class="form-group">
120
- <label for="user_test">Test</label>
121
- <input class="form-control" type="date" name="user[test]" id="user_test"/>
122
- </div>
123
- HTML
124
- assert_xml_equal expected, actual
125
- end
126
-
127
- def test_datetime_field
128
- actual = @builder.datetime_field(:test)
129
- expected = <<-HTML
130
- <div class="form-group">
131
- <label for="user_test">Test</label>
132
- <input class="form-control" type="datetime-local" name="user[test]" id="user_test"/>
133
- </div>
134
- HTML
135
- assert_xml_equal expected, actual
136
- end
137
-
138
- def test_email_field
139
- actual = @builder.email_field(:test)
140
- expected = <<-HTML
141
- <div class="form-group">
142
- <label for="user_test">Test</label>
143
- <input class="form-control" type="email" name="user[test]" id="user_test"/>
144
- </div>
145
- HTML
146
- assert_xml_equal expected, actual
147
- end
148
-
149
- def test_file_field
150
- actual = @builder.file_field(:test)
151
- expected = <<-HTML
152
- <div class="form-group">
153
- <label for="user_test">Test</label>
154
- <input class="form-control" type="file" name="user[test]" id="user_test"/>
155
- </div>
156
- HTML
157
- assert_xml_equal expected, actual
158
- end
159
-
160
- def test_month_field
161
- actual = @builder.month_field(:test)
162
- expected = <<-HTML
163
- <div class="form-group">
164
- <label for="user_test">Test</label>
165
- <input class="form-control" type="month" name="user[test]" id="user_test"/>
166
- </div>
167
- HTML
168
- assert_xml_equal expected, actual
169
- end
170
-
171
- def test_number_field
172
- actual = @builder.number_field(:test)
173
- expected = <<-HTML
174
- <div class="form-group">
175
- <label for="user_test">Test</label>
176
- <input class="form-control" type="number" name="user[test]" id="user_test"/>
177
- </div>
178
- HTML
179
- assert_xml_equal expected, actual
180
- end
181
-
182
- def test_password_field
183
- actual = @builder.password_field(:test)
184
- expected = <<-HTML
185
- <div class="form-group">
186
- <label for="user_test">Test</label>
187
- <input class="form-control" type="password" name="user[test]" id="user_test"/>
188
- </div>
189
- HTML
190
- assert_xml_equal expected, actual
191
- end
192
-
193
- def test_phone_field
194
- actual = @builder.phone_field(:test)
195
- expected = <<-HTML
196
- <div class="form-group">
197
- <label for="user_test">Test</label>
198
- <input class="form-control" type="tel" name="user[test]" id="user_test"/>
199
- </div>
200
- HTML
201
- assert_xml_equal expected, actual
202
- end
203
-
204
- def test_range_field
205
- actual = @builder.range_field(:test)
206
- expected = <<-HTML
207
- <div class="form-group">
208
- <label for="user_test">Test</label>
209
- <input class="form-control" type="range" name="user[test]" id="user_test"/>
210
- </div>
211
- HTML
212
- assert_xml_equal expected, actual
213
- end
214
-
215
- def test_search_field
216
- actual = @builder.search_field(:test)
217
- expected = <<-HTML
218
- <div class="form-group">
219
- <label for="user_test">Test</label>
220
- <input class="form-control" type="search" name="user[test]" id="user_test"/>
221
- </div>
222
- HTML
223
- assert_xml_equal expected, actual
224
- end
225
-
226
- def test_text_area
227
- actual = @builder.text_area(:test)
228
- expected = <<-HTML
229
- <div class="form-group">
230
- <label for="user_test">Test</label>
231
- <textarea class="form-control" name="user[test]" id="user_test"/></textarea>
232
- </div>
233
- HTML
234
- assert_xml_equal expected, actual
235
- end
236
-
237
- def test_time_field
238
- actual = @builder.time_field(:test)
239
- expected = <<-HTML
240
- <div class="form-group">
241
- <label for="user_test">Test</label>
242
- <input class="form-control" type="time" name="user[test]" id="user_test"/>
243
- </div>
244
- HTML
245
- assert_xml_equal expected, actual
246
- end
247
-
248
- def test_url_field
249
- actual = @builder.url_field(:test)
250
- expected = <<-HTML
251
- <div class="form-group">
252
- <label for="user_test">Test</label>
253
- <input class="form-control" type="url" name="user[test]" id="user_test"/>
254
- </div>
255
- HTML
256
- assert_xml_equal expected, actual
257
- end
258
-
259
- def test_week_field
260
- actual = @builder.week_field(:test)
261
- expected = <<-HTML
262
- <div class="form-group">
263
- <label for="user_test">Test</label>
264
- <input class="form-control" type="week" name="user[test]" id="user_test"/>
265
- </div>
266
- HTML
267
- assert_xml_equal expected, actual
268
- end
269
-
270
- def test_plaintext
271
- actual = @builder.plaintext(:test)
272
- expected = <<-HTML
273
- <div class="form-group">
274
- <label for="user_test">Test</label>
275
- <input class="form-control-plaintext" readonly="readonly" type="text" name="user[test]" id="user_test"/>
276
- </div>
277
- HTML
278
- assert_xml_equal expected, actual
279
- end
280
-
281
- def test_form_group
282
- actual = @builder.form_group do
283
- "test"
284
- end
285
- expected = <<-HTML
286
- <div class="form-group">test</div>
287
- HTML
288
- assert_xml_equal expected, actual
289
- end
290
-
291
- def test_form_group_with_label
292
- actual = @builder.form_group(bootstrap: { label: { text: "Test" } }) do
293
- "test"
294
- end
295
- expected = <<-HTML
296
- <div class="form-group">
297
- <label>Test</label>
298
- test
299
- </div>
300
- HTML
301
- assert_xml_equal expected, actual
302
- end
303
-
304
- end