formtastic 3.1.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/test.yml +61 -0
  4. data/.gitignore +3 -2
  5. data/CHANGELOG.md +61 -0
  6. data/Gemfile.lock +140 -0
  7. data/MIT-LICENSE +1 -1
  8. data/{README.textile → README.md} +183 -167
  9. data/RELEASE_PROCESS +3 -1
  10. data/Rakefile +20 -1
  11. data/app/assets/stylesheets/formtastic.css +1 -1
  12. data/bin/appraisal +8 -0
  13. data/formtastic.gemspec +12 -16
  14. data/gemfiles/rails_6.0/Gemfile +5 -0
  15. data/gemfiles/rails_6.1/Gemfile +5 -0
  16. data/gemfiles/rails_7.0/Gemfile +5 -0
  17. data/gemfiles/rails_7.1/Gemfile +5 -0
  18. data/gemfiles/rails_edge/Gemfile +13 -0
  19. data/lib/formtastic/action_class_finder.rb +1 -0
  20. data/lib/formtastic/actions/base.rb +1 -0
  21. data/lib/formtastic/actions/button_action.rb +1 -0
  22. data/lib/formtastic/actions/buttonish.rb +1 -0
  23. data/lib/formtastic/actions/input_action.rb +1 -0
  24. data/lib/formtastic/actions/link_action.rb +1 -0
  25. data/lib/formtastic/actions.rb +7 -3
  26. data/lib/formtastic/deprecation.rb +2 -38
  27. data/lib/formtastic/engine.rb +4 -1
  28. data/lib/formtastic/form_builder.rb +12 -24
  29. data/lib/formtastic/helpers/action_helper.rb +2 -48
  30. data/lib/formtastic/helpers/actions_helper.rb +1 -0
  31. data/lib/formtastic/helpers/enum.rb +14 -0
  32. data/lib/formtastic/helpers/errors_helper.rb +3 -2
  33. data/lib/formtastic/helpers/fieldset_wrapper.rb +14 -9
  34. data/lib/formtastic/helpers/file_column_detection.rb +1 -0
  35. data/lib/formtastic/helpers/form_helper.rb +2 -1
  36. data/lib/formtastic/helpers/input_helper.rb +20 -76
  37. data/lib/formtastic/helpers/inputs_helper.rb +29 -23
  38. data/lib/formtastic/helpers/reflection.rb +1 -0
  39. data/lib/formtastic/helpers.rb +2 -2
  40. data/lib/formtastic/html_attributes.rb +1 -0
  41. data/lib/formtastic/i18n.rb +2 -1
  42. data/lib/formtastic/input_class_finder.rb +1 -0
  43. data/lib/formtastic/inputs/base/associations.rb +1 -0
  44. data/lib/formtastic/inputs/base/choices.rb +3 -2
  45. data/lib/formtastic/inputs/base/collections.rb +46 -10
  46. data/lib/formtastic/inputs/base/database.rb +5 -7
  47. data/lib/formtastic/inputs/base/datetime_pickerish.rb +1 -0
  48. data/lib/formtastic/inputs/base/errors.rb +7 -6
  49. data/lib/formtastic/inputs/base/fileish.rb +1 -0
  50. data/lib/formtastic/inputs/base/hints.rb +2 -1
  51. data/lib/formtastic/inputs/base/html.rb +9 -7
  52. data/lib/formtastic/inputs/base/labelling.rb +3 -2
  53. data/lib/formtastic/inputs/base/naming.rb +5 -4
  54. data/lib/formtastic/inputs/base/numeric.rb +1 -0
  55. data/lib/formtastic/inputs/base/options.rb +3 -3
  56. data/lib/formtastic/inputs/base/placeholder.rb +1 -0
  57. data/lib/formtastic/inputs/base/stringish.rb +1 -0
  58. data/lib/formtastic/inputs/base/timeish.rb +9 -4
  59. data/lib/formtastic/inputs/base/validations.rb +39 -12
  60. data/lib/formtastic/inputs/base/wrapping.rb +1 -0
  61. data/lib/formtastic/inputs/base.rb +3 -2
  62. data/lib/formtastic/inputs/boolean_input.rb +2 -1
  63. data/lib/formtastic/inputs/check_boxes_input.rb +15 -6
  64. data/lib/formtastic/inputs/color_input.rb +1 -1
  65. data/lib/formtastic/inputs/country_input.rb +4 -1
  66. data/lib/formtastic/inputs/datalist_input.rb +1 -0
  67. data/lib/formtastic/inputs/date_picker_input.rb +1 -0
  68. data/lib/formtastic/inputs/date_select_input.rb +1 -0
  69. data/lib/formtastic/inputs/datetime_picker_input.rb +1 -0
  70. data/lib/formtastic/inputs/datetime_select_input.rb +1 -0
  71. data/lib/formtastic/inputs/email_input.rb +1 -0
  72. data/lib/formtastic/inputs/file_input.rb +1 -0
  73. data/lib/formtastic/inputs/hidden_input.rb +3 -2
  74. data/lib/formtastic/inputs/number_input.rb +1 -0
  75. data/lib/formtastic/inputs/password_input.rb +1 -0
  76. data/lib/formtastic/inputs/phone_input.rb +1 -0
  77. data/lib/formtastic/inputs/radio_input.rb +21 -0
  78. data/lib/formtastic/inputs/range_input.rb +1 -0
  79. data/lib/formtastic/inputs/search_input.rb +1 -0
  80. data/lib/formtastic/inputs/select_input.rb +30 -1
  81. data/lib/formtastic/inputs/string_input.rb +1 -0
  82. data/lib/formtastic/inputs/text_input.rb +1 -0
  83. data/lib/formtastic/inputs/time_picker_input.rb +1 -0
  84. data/lib/formtastic/inputs/time_select_input.rb +1 -0
  85. data/lib/formtastic/inputs/time_zone_input.rb +17 -6
  86. data/lib/formtastic/inputs/url_input.rb +1 -0
  87. data/lib/formtastic/inputs.rb +33 -29
  88. data/lib/formtastic/localized_string.rb +1 -0
  89. data/lib/formtastic/localizer.rb +21 -22
  90. data/lib/formtastic/namespaced_class_finder.rb +8 -9
  91. data/lib/formtastic/version.rb +2 -1
  92. data/lib/formtastic.rb +10 -11
  93. data/lib/generators/formtastic/form/form_generator.rb +2 -1
  94. data/lib/generators/formtastic/input/input_generator.rb +47 -0
  95. data/lib/generators/formtastic/install/install_generator.rb +1 -0
  96. data/lib/generators/templates/formtastic.rb +15 -13
  97. data/lib/generators/templates/input.rb +19 -0
  98. data/sample/basic_inputs.html +1 -1
  99. data/script/integration-template.rb +73 -0
  100. data/script/integration.sh +19 -0
  101. data/spec/action_class_finder_spec.rb +2 -1
  102. data/spec/actions/button_action_spec.rb +21 -20
  103. data/spec/actions/generic_action_spec.rb +134 -133
  104. data/spec/actions/input_action_spec.rb +20 -19
  105. data/spec/actions/link_action_spec.rb +30 -29
  106. data/spec/builder/custom_builder_spec.rb +39 -22
  107. data/spec/builder/error_proc_spec.rb +6 -5
  108. data/spec/builder/semantic_fields_for_spec.rb +46 -45
  109. data/spec/fast_spec_helper.rb +13 -0
  110. data/spec/generators/formtastic/form/form_generator_spec.rb +33 -32
  111. data/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
  112. data/spec/generators/formtastic/install/install_generator_spec.rb +10 -9
  113. data/spec/helpers/action_helper_spec.rb +329 -10
  114. data/spec/helpers/actions_helper_spec.rb +43 -42
  115. data/spec/helpers/form_helper_spec.rb +45 -38
  116. data/spec/helpers/input_helper_spec.rb +976 -2
  117. data/spec/helpers/inputs_helper_spec.rb +217 -202
  118. data/spec/helpers/reflection_helper_spec.rb +7 -6
  119. data/spec/helpers/semantic_errors_helper_spec.rb +26 -25
  120. data/spec/i18n_spec.rb +30 -29
  121. data/spec/input_class_finder_spec.rb +2 -1
  122. data/spec/inputs/base/collections_spec.rb +78 -0
  123. data/spec/inputs/base/validations_spec.rb +481 -0
  124. data/spec/inputs/boolean_input_spec.rb +73 -72
  125. data/spec/inputs/check_boxes_input_spec.rb +169 -121
  126. data/spec/inputs/color_input_spec.rb +53 -64
  127. data/spec/inputs/country_input_spec.rb +23 -22
  128. data/spec/inputs/custom_input_spec.rb +3 -6
  129. data/spec/inputs/datalist_input_spec.rb +3 -2
  130. data/spec/inputs/date_picker_input_spec.rb +114 -113
  131. data/spec/inputs/date_select_input_spec.rb +76 -61
  132. data/spec/inputs/datetime_picker_input_spec.rb +123 -122
  133. data/spec/inputs/datetime_select_input_spec.rb +85 -68
  134. data/spec/inputs/email_input_spec.rb +17 -16
  135. data/spec/inputs/file_input_spec.rb +18 -17
  136. data/spec/inputs/hidden_input_spec.rb +32 -31
  137. data/spec/inputs/include_blank_spec.rb +10 -9
  138. data/spec/inputs/label_spec.rb +26 -25
  139. data/spec/inputs/number_input_spec.rb +212 -211
  140. data/spec/inputs/password_input_spec.rb +17 -16
  141. data/spec/inputs/phone_input_spec.rb +17 -16
  142. data/spec/inputs/placeholder_spec.rb +18 -17
  143. data/spec/inputs/radio_input_spec.rb +92 -65
  144. data/spec/inputs/range_input_spec.rb +136 -135
  145. data/spec/inputs/readonly_spec.rb +51 -0
  146. data/spec/inputs/search_input_spec.rb +16 -15
  147. data/spec/inputs/select_input_spec.rb +209 -102
  148. data/spec/inputs/string_input_spec.rb +51 -50
  149. data/spec/inputs/text_input_spec.rb +34 -33
  150. data/spec/inputs/time_picker_input_spec.rb +115 -114
  151. data/spec/inputs/time_select_input_spec.rb +84 -70
  152. data/spec/inputs/time_zone_input_spec.rb +58 -31
  153. data/spec/inputs/url_input_spec.rb +17 -16
  154. data/spec/inputs/with_options_spec.rb +9 -8
  155. data/spec/localizer_spec.rb +18 -17
  156. data/spec/namespaced_class_finder_spec.rb +18 -6
  157. data/spec/schema.rb +22 -0
  158. data/spec/spec_helper.rb +172 -260
  159. data/spec/support/custom_macros.rb +74 -76
  160. data/spec/support/deprecation.rb +2 -1
  161. data/spec/support/shared_examples.rb +2 -1233
  162. data/spec/support/specialized_class_finder_shared_example.rb +1 -0
  163. data/spec/support/test_environment.rb +24 -9
  164. metadata +78 -170
  165. data/.travis.yml +0 -29
  166. data/Appraisals +0 -29
  167. data/CHANGELOG +0 -39
  168. data/DEPRECATIONS +0 -49
  169. data/gemfiles/rails_3.2.gemfile +0 -7
  170. data/gemfiles/rails_4.0.4.gemfile +0 -7
  171. data/gemfiles/rails_4.1.gemfile +0 -7
  172. data/gemfiles/rails_4.2.gemfile +0 -7
  173. data/gemfiles/rails_4.gemfile +0 -7
  174. data/gemfiles/rails_edge.gemfile +0 -10
  175. data/lib/formtastic/util.rb +0 -57
  176. data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
  177. data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
  178. data/spec/support/deferred_garbage_collection.rb +0 -21
  179. data/spec/util_spec.rb +0 -66
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 70272678a1b436280de8d89add80583ca886cac153f6d4e43be93e6a641c344f
4
+ data.tar.gz: d2549407b0a3c5d21e7afe24cfd21bd008c9ca957bd06cf2d59fb7b3101fa042
5
+ SHA512:
6
+ metadata.gz: 4164b15cb0dc3eb5d2d90f257977d59b8459a1708f4520ba6ff1708eaf9dd898f2713d9f59945c1d50c2b481e2175c0e3d7af6259c9f1e715a836aac0dd0e53b
7
+ data.tar.gz: e93800c9ca16ea4afb445f5a95cb56e1dd0224f06654ef8af7b13dba8ddb4c520e09c4b49c760d10a7e71d6f381f9b6fb91bbe61e26e1cab83823c7e2dc827de
data/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ CHANGELOG merge=union
@@ -0,0 +1,61 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ ci:
9
+ runs-on: ubuntu-latest
10
+ needs: test
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ test:
14
+ runs-on: ubuntu-20.04
15
+
16
+ strategy:
17
+ fail-fast: false
18
+
19
+ matrix:
20
+ gemfile:
21
+ - gemfiles/rails_6.0/Gemfile
22
+ - gemfiles/rails_6.1/Gemfile
23
+ - gemfiles/rails_7.0/Gemfile
24
+ - gemfiles/rails_7.1/Gemfile
25
+ - gemfiles/rails_edge/Gemfile
26
+
27
+ ruby:
28
+ - 2.6.6
29
+ - 2.7.2
30
+ - 3.0.0
31
+
32
+ exclude:
33
+ - ruby: 2.6.6
34
+ gemfile: gemfiles/rails_7.0/Gemfile
35
+ - ruby: 2.6.6
36
+ gemfile: gemfiles/rails_7.1/Gemfile
37
+ - ruby: 2.6.6
38
+ gemfile: gemfiles/rails_edge/Gemfile
39
+
40
+ env:
41
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
42
+
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+
46
+ - uses: actions/setup-node@v2
47
+ with:
48
+ node-version: 11
49
+
50
+ - name: Set up Ruby
51
+ uses: ruby/setup-ruby@v1
52
+ with:
53
+ ruby-version: ${{ matrix.ruby }}
54
+ bundler-cache: true
55
+ bundler: latest
56
+
57
+ - name: Run tests
58
+ run: |
59
+ bundle exec rake spec
60
+ script/integration.sh
61
+ continue-on-error: ${{ matrix.gemfile == 'gemfiles/rails_edge/Gemfile' }}
data/.gitignore CHANGED
@@ -9,9 +9,10 @@ pkg
9
9
  log/*
10
10
  .rvmrc
11
11
  .ruby-version
12
+ \.ruby-gemset
12
13
  .bundle
13
- Gemfile.lock
14
14
  .yardoc
15
15
  doc/
16
16
  tmp
17
- gemfiles/*.lock
17
+ gemfiles/*/Gemfile.lock
18
+ /dummy/
data/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ ## 5.0.0
2
+ * Added support for Rails 7.1 ([#1371](https://github.com/formtastic/formtastic/pull/1371))
3
+ * Removed support for Rails < 6.0.0 ([#1354](https://github.com/formtastic/formtastic/pull/1354))
4
+ * Removed support for Rubies < 2.6.0 ([#1332](https://github.com/formtastic/formtastic/pull/1332), [#1355](https://github.com/formtastic/formtastic.git/pull/1355))
5
+ * Added support for scopes in relations ([#1343](https://github.com/formtastic/formtastic/pull/1343))
6
+ * Fixed I18n lookup for enum values in nested select fields ([#1342](https://github.com/formtastic/formtastic/pull/1342))
7
+ * Fixed faster input class lookup ([#1336](https://github.com/formtastic/formtastic/pull/1336))
8
+ * Use frozen_string_literal internally ([#1339](https://github.com/formtastic/formtastic/pull/1339))
9
+
10
+ ## 4.0.0
11
+ * Fixed default_columns_for_object when object has non-standard foreign keys (#1241)
12
+ * Fixed missing constants in production (#911)
13
+ * Removed support for Rails 3 and 4.0 (#1108)
14
+ * Removed deprecated input/action finder methods (#1139)
15
+ * Changed boolean label padding to margin (#1202)
16
+ * Added mapping hstore column to text input (#1203)
17
+ * Added support for Rails 5 Attributes API (#1188)
18
+ * Changed required Ruby version to >= 2.0 (#1210)
19
+ * Default to input types text for json & jsonb, string for citext columns (#1229)
20
+ * Allow symbols for numericality options (#1258)
21
+ * Support for rubies under 2.4.0 has been dropped (#1292)
22
+ * Support for Rails under 5.2.0 has been dropped (#1293)
23
+ * Support for Rails 6.0 has been added (#1300)
24
+ * Support for Rails 6.1 has been added (#1324)
25
+ * Support for Ruby 3 has been added (#1323)
26
+
27
+ ## 3.1.2
28
+
29
+ * Fixed that we specified 4.0.4 instead of 4.1 in the Rails version deprecation message
30
+
31
+ ## 3.1.1
32
+
33
+ * Fixed class custom input & action class loading in test environments
34
+ * Added documentation of custom input & action class finders
35
+ * Added a link to documentation & wiki from custom class deprecation warnings
36
+
37
+ ## 3.1.0
38
+
39
+ * Performance and documentation improvements
40
+
41
+ ## 3.1.0.rc2
42
+
43
+ * Deprecated :member_value and :member_label options
44
+
45
+ ## 3.1.0.rc1
46
+
47
+ * Deprecated support for Rails version < 4.1.0
48
+ * Fixed synchronization issues with custom_namespace configuration
49
+ * Fixed bug where boolean (checkbox) inputs were not being correctly checked (also in 2.3.1)
50
+ * Fixed (silenced) Rails 5 deprecation on column_for_attribute that we're handling fine
51
+ * Added new DatalistInput (:as => :datalist) for HTML5 datalists
52
+ * Added configurable namespaces for custom inputs
53
+ * Various performance and documentation improvements
54
+
55
+ ---
56
+
57
+ See 3.0-stable branch for 3.0.x changes
58
+ https://github.com/formtastic/formtastic/blob/3.0-stable/CHANGELOG
59
+
60
+ See 2.3-stable branch for 2.3.x and earlier releases
61
+ https://github.com/formtastic/formtastic/blob/2.3-stable/CHANGELOG
data/Gemfile.lock ADDED
@@ -0,0 +1,140 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ formtastic (4.0.0)
5
+ actionpack (>= 6.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (7.1.1)
11
+ actionview (= 7.1.1)
12
+ activesupport (= 7.1.1)
13
+ nokogiri (>= 1.8.5)
14
+ rack (>= 2.2.4)
15
+ rack-session (>= 1.0.1)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.2)
18
+ rails-html-sanitizer (~> 1.6)
19
+ actionview (7.1.1)
20
+ activesupport (= 7.1.1)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.11)
23
+ rails-dom-testing (~> 2.2)
24
+ rails-html-sanitizer (~> 1.6)
25
+ activesupport (7.1.1)
26
+ base64
27
+ bigdecimal
28
+ concurrent-ruby (~> 1.0, >= 1.0.2)
29
+ connection_pool (>= 2.2.5)
30
+ drb
31
+ i18n (>= 1.6, < 2)
32
+ minitest (>= 5.1)
33
+ mutex_m
34
+ tzinfo (~> 2.0)
35
+ ammeter (1.1.5)
36
+ activesupport (>= 3.0)
37
+ railties (>= 3.0)
38
+ rspec-rails (>= 2.2)
39
+ base64 (0.1.1)
40
+ bigdecimal (3.1.4)
41
+ builder (3.2.4)
42
+ concurrent-ruby (1.2.2)
43
+ connection_pool (2.4.1)
44
+ crass (1.0.6)
45
+ diff-lcs (1.5.0)
46
+ drb (2.1.1)
47
+ ruby2_keywords
48
+ erubi (1.12.0)
49
+ i18n (1.14.1)
50
+ concurrent-ruby (~> 1.0)
51
+ io-console (0.6.0)
52
+ irb (1.8.1)
53
+ rdoc
54
+ reline (>= 0.3.8)
55
+ loofah (2.21.4)
56
+ crass (~> 1.0.2)
57
+ nokogiri (>= 1.12.0)
58
+ mini_portile2 (2.8.4)
59
+ minitest (5.20.0)
60
+ mutex_m (0.1.2)
61
+ nokogiri (1.15.4)
62
+ mini_portile2 (~> 2.8.2)
63
+ racc (~> 1.4)
64
+ psych (5.1.1)
65
+ stringio
66
+ racc (1.7.1)
67
+ rack (3.0.8)
68
+ rack-session (2.0.0)
69
+ rack (>= 3.0.0)
70
+ rack-test (2.1.0)
71
+ rack (>= 1.3)
72
+ rackup (2.1.0)
73
+ rack (>= 3)
74
+ webrick (~> 1.8)
75
+ rails-dom-testing (2.2.0)
76
+ activesupport (>= 5.0.0)
77
+ minitest
78
+ nokogiri (>= 1.6)
79
+ rails-html-sanitizer (1.6.0)
80
+ loofah (~> 2.21)
81
+ nokogiri (~> 1.14)
82
+ railties (7.1.1)
83
+ actionpack (= 7.1.1)
84
+ activesupport (= 7.1.1)
85
+ irb
86
+ rackup (>= 1.0.0)
87
+ rake (>= 12.2)
88
+ thor (~> 1.0, >= 1.2.2)
89
+ zeitwerk (~> 2.6)
90
+ rake (13.0.6)
91
+ rdoc (6.5.0)
92
+ psych (>= 4.0.0)
93
+ reline (0.3.9)
94
+ io-console (~> 0.5)
95
+ rspec-core (3.12.2)
96
+ rspec-support (~> 3.12.0)
97
+ rspec-dom-testing (0.1.0)
98
+ rails-dom-testing (>= 1.0, < 3)
99
+ rspec-expectations (~> 3.0)
100
+ rspec-expectations (3.12.3)
101
+ diff-lcs (>= 1.2.0, < 2.0)
102
+ rspec-support (~> 3.12.0)
103
+ rspec-mocks (3.12.6)
104
+ diff-lcs (>= 1.2.0, < 2.0)
105
+ rspec-support (~> 3.12.0)
106
+ rspec-rails (6.0.3)
107
+ actionpack (>= 6.1)
108
+ activesupport (>= 6.1)
109
+ railties (>= 6.1)
110
+ rspec-core (~> 3.12)
111
+ rspec-expectations (~> 3.12)
112
+ rspec-mocks (~> 3.12)
113
+ rspec-support (~> 3.12)
114
+ rspec-support (3.12.1)
115
+ ruby2_keywords (0.0.5)
116
+ sqlite3 (1.6.7)
117
+ mini_portile2 (~> 2.8.0)
118
+ stringio (3.0.8)
119
+ thor (1.2.2)
120
+ tzinfo (2.0.6)
121
+ concurrent-ruby (~> 1.0)
122
+ webrick (1.8.1)
123
+ yard (0.9.34)
124
+ zeitwerk (2.6.12)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ ammeter (~> 1.1.3)
131
+ formtastic!
132
+ rake
133
+ rspec-dom-testing (>= 0.1.0)
134
+ rspec-mocks (~> 3.12.2)
135
+ rspec-rails (>= 4.0)
136
+ sqlite3 (~> 1.4)
137
+ yard (~> 0.9.20)
138
+
139
+ BUNDLED WITH
140
+ 2.3.18
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2010 Justin French
1
+ Copyright (c) 2008-2021
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the