formtastic 2.1.0 → 4.0.0
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 +7 -0
- data/.gitattributes +1 -0
- data/.github/workflows/test.yml +61 -0
- data/.gitignore +4 -2
- data/CHANGELOG.md +52 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +105 -0
- data/MIT-LICENSE +1 -1
- data/{README.textile → README.md} +204 -219
- data/RELEASE_PROCESS +3 -1
- data/Rakefile +27 -29
- data/app/assets/stylesheets/formtastic.css +3 -2
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +11 -14
- data/gemfiles/rails_5.2/Gemfile +5 -0
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_6.1/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic/action_class_finder.rb +18 -0
- data/lib/formtastic/actions/button_action.rb +55 -60
- data/lib/formtastic/actions/input_action.rb +59 -57
- data/lib/formtastic/actions/link_action.rb +68 -67
- data/lib/formtastic/actions.rb +6 -3
- data/lib/formtastic/deprecation.rb +5 -0
- data/lib/formtastic/engine.rb +3 -1
- data/lib/formtastic/form_builder.rb +35 -16
- data/lib/formtastic/helpers/action_helper.rb +34 -28
- data/lib/formtastic/helpers/enum.rb +13 -0
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +16 -12
- data/lib/formtastic/helpers/form_helper.rb +19 -16
- data/lib/formtastic/helpers/input_helper.rb +69 -97
- data/lib/formtastic/helpers/inputs_helper.rb +35 -25
- data/lib/formtastic/helpers/reflection.rb +4 -4
- data/lib/formtastic/helpers.rb +1 -2
- data/lib/formtastic/html_attributes.rb +12 -1
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/input_class_finder.rb +18 -0
- data/lib/formtastic/inputs/base/choices.rb +2 -2
- data/lib/formtastic/inputs/base/collections.rb +46 -14
- data/lib/formtastic/inputs/base/database.rb +7 -2
- data/lib/formtastic/inputs/base/datetime_pickerish.rb +85 -0
- data/lib/formtastic/inputs/base/errors.rb +7 -7
- data/lib/formtastic/inputs/base/hints.rb +2 -2
- data/lib/formtastic/inputs/base/html.rb +10 -9
- data/lib/formtastic/inputs/base/labelling.rb +5 -8
- data/lib/formtastic/inputs/base/naming.rb +4 -4
- data/lib/formtastic/inputs/base/numeric.rb +1 -1
- data/lib/formtastic/inputs/base/options.rb +3 -4
- data/lib/formtastic/inputs/base/stringish.rb +10 -2
- data/lib/formtastic/inputs/base/timeish.rb +34 -22
- data/lib/formtastic/inputs/base/validations.rb +41 -13
- data/lib/formtastic/inputs/base/wrapping.rb +29 -26
- data/lib/formtastic/inputs/base.rb +22 -15
- data/lib/formtastic/inputs/boolean_input.rb +26 -12
- data/lib/formtastic/inputs/check_boxes_input.rb +39 -31
- data/lib/formtastic/inputs/color_input.rb +41 -0
- data/lib/formtastic/inputs/country_input.rb +24 -5
- data/lib/formtastic/inputs/datalist_input.rb +41 -0
- data/lib/formtastic/inputs/date_picker_input.rb +93 -0
- data/lib/formtastic/inputs/{date_input.rb → date_select_input.rb} +1 -1
- data/lib/formtastic/inputs/datetime_picker_input.rb +103 -0
- data/lib/formtastic/inputs/{datetime_input.rb → datetime_select_input.rb} +1 -1
- data/lib/formtastic/inputs/file_input.rb +2 -2
- data/lib/formtastic/inputs/hidden_input.rb +2 -6
- data/lib/formtastic/inputs/radio_input.rb +28 -22
- data/lib/formtastic/inputs/select_input.rb +36 -39
- data/lib/formtastic/inputs/time_picker_input.rb +99 -0
- data/lib/formtastic/inputs/{time_input.rb → time_select_input.rb} +6 -2
- data/lib/formtastic/inputs/time_zone_input.rb +16 -6
- data/lib/formtastic/inputs.rb +32 -21
- data/lib/formtastic/localized_string.rb +1 -1
- data/lib/formtastic/localizer.rb +24 -24
- data/lib/formtastic/namespaced_class_finder.rb +99 -0
- data/lib/formtastic/version.rb +1 -1
- data/lib/formtastic.rb +20 -10
- data/lib/generators/formtastic/form/form_generator.rb +10 -4
- data/lib/generators/formtastic/input/input_generator.rb +46 -0
- data/lib/generators/formtastic/install/install_generator.rb +5 -19
- data/lib/generators/templates/_form.html.slim +2 -2
- data/lib/generators/templates/formtastic.rb +46 -25
- data/lib/generators/templates/input.rb +19 -0
- data/sample/basic_inputs.html +23 -3
- data/script/integration-template.rb +74 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +12 -0
- data/spec/actions/button_action_spec.rb +8 -8
- data/spec/actions/generic_action_spec.rb +92 -56
- data/spec/actions/input_action_spec.rb +7 -7
- data/spec/actions/link_action_spec.rb +10 -10
- data/spec/builder/custom_builder_spec.rb +36 -20
- data/spec/builder/error_proc_spec.rb +4 -4
- data/spec/builder/semantic_fields_for_spec.rb +28 -29
- data/spec/fast_spec_helper.rb +12 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +45 -32
- data/spec/generators/formtastic/input/input_generator_spec.rb +124 -0
- data/spec/generators/formtastic/install/install_generator_spec.rb +9 -9
- data/spec/helpers/action_helper_spec.rb +75 -103
- data/spec/helpers/actions_helper_spec.rb +17 -17
- data/spec/helpers/form_helper_spec.rb +84 -33
- data/spec/helpers/input_helper_spec.rb +333 -285
- data/spec/helpers/inputs_helper_spec.rb +167 -121
- data/spec/helpers/reflection_helper_spec.rb +3 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +23 -23
- data/spec/i18n_spec.rb +26 -26
- data/spec/input_class_finder_spec.rb +10 -0
- data/spec/inputs/base/collections_spec.rb +76 -0
- data/spec/inputs/base/validations_spec.rb +480 -0
- data/spec/inputs/boolean_input_spec.rb +100 -65
- data/spec/inputs/check_boxes_input_spec.rb +200 -101
- data/spec/inputs/color_input_spec.rb +85 -0
- data/spec/inputs/country_input_spec.rb +20 -20
- data/spec/inputs/custom_input_spec.rb +3 -4
- data/spec/inputs/datalist_input_spec.rb +61 -0
- data/spec/inputs/date_picker_input_spec.rb +449 -0
- data/spec/inputs/date_select_input_spec.rb +249 -0
- data/spec/inputs/datetime_picker_input_spec.rb +490 -0
- data/spec/inputs/datetime_select_input_spec.rb +209 -0
- data/spec/inputs/email_input_spec.rb +5 -5
- data/spec/inputs/file_input_spec.rb +6 -6
- data/spec/inputs/hidden_input_spec.rb +22 -35
- data/spec/inputs/include_blank_spec.rb +11 -11
- data/spec/inputs/label_spec.rb +62 -25
- data/spec/inputs/number_input_spec.rb +112 -112
- data/spec/inputs/password_input_spec.rb +5 -5
- data/spec/inputs/phone_input_spec.rb +5 -5
- data/spec/inputs/placeholder_spec.rb +6 -6
- data/spec/inputs/radio_input_spec.rb +99 -55
- data/spec/inputs/range_input_spec.rb +66 -66
- data/spec/inputs/readonly_spec.rb +50 -0
- data/spec/inputs/search_input_spec.rb +5 -5
- data/spec/inputs/select_input_spec.rb +170 -170
- data/spec/inputs/string_input_spec.rb +68 -16
- data/spec/inputs/text_input_spec.rb +16 -16
- data/spec/inputs/time_picker_input_spec.rb +455 -0
- data/spec/inputs/time_select_input_spec.rb +261 -0
- data/spec/inputs/time_zone_input_spec.rb +54 -28
- data/spec/inputs/url_input_spec.rb +5 -5
- data/spec/inputs/with_options_spec.rb +7 -7
- data/spec/localizer_spec.rb +39 -17
- data/spec/namespaced_class_finder_spec.rb +79 -0
- data/spec/schema.rb +21 -0
- data/spec/spec_helper.rb +254 -221
- data/spec/support/custom_macros.rb +128 -95
- data/spec/support/shared_examples.rb +12 -0
- data/spec/support/specialized_class_finder_shared_example.rb +27 -0
- data/spec/support/test_environment.rb +26 -10
- metadata +177 -238
- data/.travis.yml +0 -8
- data/Appraisals +0 -11
- data/CHANGELOG +0 -371
- data/gemfiles/rails-3.0.gemfile +0 -7
- data/gemfiles/rails-3.1.gemfile +0 -7
- data/gemfiles/rails-3.2.gemfile +0 -7
- data/lib/formtastic/helpers/buttons_helper.rb +0 -310
- data/lib/formtastic/inputs/base/grouped_collections.rb +0 -77
- data/lib/formtastic/util.rb +0 -25
- data/lib/tasks/verify_rcov.rb +0 -44
- data/spec/helpers/buttons_helper_spec.rb +0 -166
- data/spec/helpers/commit_button_helper_spec.rb +0 -530
- data/spec/inputs/date_input_spec.rb +0 -227
- data/spec/inputs/datetime_input_spec.rb +0 -185
- data/spec/inputs/time_input_spec.rb +0 -267
- data/spec/support/deferred_garbage_collection.rb +0 -21
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
# --------------------------------------------------------------------------------------------------
|
|
4
|
-
# Please note: If you're subclassing Formtastic::FormBuilder, Formtastic uses
|
|
5
|
-
# class_attribute for these configuration attributes instead of the deprecated
|
|
6
|
-
# class_inheritable_attribute. The behaviour is slightly different with subclasses (especially
|
|
7
|
-
# around attributes with Hash or Array) values, so make sure you understand what's happening.
|
|
8
|
-
# See the documentation for class_attribute in ActiveSupport for more information.
|
|
9
|
-
# --------------------------------------------------------------------------------------------------
|
|
10
|
-
|
|
11
3
|
# Set the default text field size when input is a string. Default is nil.
|
|
12
4
|
# Formtastic::FormBuilder.default_text_field_size = 50
|
|
13
5
|
|
|
@@ -25,15 +17,15 @@
|
|
|
25
17
|
# Defaults to true.
|
|
26
18
|
# Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
|
27
19
|
|
|
28
|
-
# Set the string that will be appended to the labels/fieldsets which are required
|
|
20
|
+
# Set the string that will be appended to the labels/fieldsets which are required.
|
|
29
21
|
# It accepts string or procs and the default is a localized version of
|
|
30
22
|
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
|
31
23
|
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
|
32
|
-
# abbr tag, you can simply give a string as below
|
|
24
|
+
# abbr tag, you can simply give a string as below.
|
|
33
25
|
# Formtastic::FormBuilder.required_string = "(required)"
|
|
34
26
|
|
|
35
|
-
# Set the string that will be appended to the labels/fieldsets which are optional
|
|
36
|
-
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
|
27
|
+
# Set the string that will be appended to the labels/fieldsets which are optional.
|
|
28
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above).
|
|
37
29
|
# Formtastic::FormBuilder.optional_string = "(optional)"
|
|
38
30
|
|
|
39
31
|
# Set the way inline errors will be displayed.
|
|
@@ -41,7 +33,7 @@
|
|
|
41
33
|
# Formtastic::FormBuilder.inline_errors = :sentence
|
|
42
34
|
# Formtastic uses the following classes as default for hints, inline_errors and error list
|
|
43
35
|
|
|
44
|
-
# If you override the class here, please ensure to override it in your stylesheets as well
|
|
36
|
+
# If you override the class here, please ensure to override it in your stylesheets as well.
|
|
45
37
|
# Formtastic::FormBuilder.default_hint_class = "inline-hints"
|
|
46
38
|
# Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
|
|
47
39
|
# Formtastic::FormBuilder.default_error_list_class = "errors"
|
|
@@ -57,20 +49,14 @@
|
|
|
57
49
|
# Formtastic::FormBuilder.collection_label_methods = [
|
|
58
50
|
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
|
59
51
|
|
|
60
|
-
# Additionally, you can customize the order for specific types of inputs.
|
|
61
|
-
# This is configured on a type basis and if a type is not found it will
|
|
62
|
-
# fall back to the default order as defined by #inline_order
|
|
63
|
-
# Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
|
|
64
|
-
# Formtastic::FormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
|
|
65
|
-
|
|
66
52
|
# Specifies if labels/hints for input fields automatically be looked up using I18n.
|
|
67
53
|
# Default value: true. Overridden for specific fields by setting value to true,
|
|
68
54
|
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
|
|
69
55
|
# Formtastic::FormBuilder.i18n_lookups_by_default = false
|
|
70
56
|
|
|
71
57
|
# Specifies if I18n lookups of the default I18n Localizer should be cached to improve performance.
|
|
72
|
-
# Defaults to
|
|
73
|
-
# Formtastic::FormBuilder.i18n_cache_lookups =
|
|
58
|
+
# Defaults to true.
|
|
59
|
+
# Formtastic::FormBuilder.i18n_cache_lookups = false
|
|
74
60
|
|
|
75
61
|
# Specifies the class to use for localization lookups. You can create your own
|
|
76
62
|
# class and use it instead by subclassing Formtastic::Localizer (which is the default).
|
|
@@ -80,11 +66,46 @@
|
|
|
80
66
|
# specifying that class here. Defaults to Formtastic::FormBuilder.
|
|
81
67
|
# Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
|
|
82
68
|
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
# Formtastic::
|
|
69
|
+
# All formtastic forms have a class that indicates that they are just that. You
|
|
70
|
+
# can change it to any class you want.
|
|
71
|
+
# Formtastic::Helpers::FormHelper.default_form_class = 'formtastic'
|
|
72
|
+
|
|
73
|
+
# Formtastic will infer a class name from the model, array, string or symbol you pass to the
|
|
74
|
+
# form builder. You can customize the way that class is presented by overriding
|
|
75
|
+
# this proc.
|
|
76
|
+
# Formtastic::Helpers::FormHelper.default_form_model_class_proc = proc { |model_class_name| model_class_name }
|
|
77
|
+
|
|
78
|
+
# Allows to set a custom field_error_proc wrapper. By default this wrapper
|
|
79
|
+
# is disabled since `formtastic` already adds an error class to the LI tag
|
|
80
|
+
# containing the input.
|
|
81
|
+
# Formtastic::Helpers::FormHelper.formtastic_field_error_proc = proc { |html_tag, instance_tag| html_tag }
|
|
82
|
+
|
|
83
|
+
# You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
|
|
84
|
+
# and `<textarea>` tags by setting this to true (defaults to false).
|
|
85
|
+
# Formtastic::FormBuilder.use_required_attribute = false
|
|
86
86
|
|
|
87
87
|
# You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
|
|
88
|
-
# this to
|
|
88
|
+
# this to true. Doing so will omit the `novalidate` attribute from the `<form>` tag.
|
|
89
89
|
# See http://diveintohtml5.org/forms.html#validation for more info.
|
|
90
90
|
# Formtastic::FormBuilder.perform_browser_validations = true
|
|
91
|
+
|
|
92
|
+
# By creating custom input class finder, you can change how input classes are looked up.
|
|
93
|
+
# For example you can make it to search for TextInputFilter instead of TextInput.
|
|
94
|
+
# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders
|
|
95
|
+
# Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder
|
|
96
|
+
|
|
97
|
+
# Define custom namespaces in which to look up your Input classes. Default is
|
|
98
|
+
# to look up in the global scope and in Formtastic::Inputs.
|
|
99
|
+
# Formtastic::FormBuilder.input_namespaces = [ ::Object, ::MyInputsModule, ::Formtastic::Inputs ]
|
|
100
|
+
|
|
101
|
+
# By creating custom action class finder, you can change how action classes are looked up.
|
|
102
|
+
# For example you can make it to search for MyButtonAction instead of ButtonAction.
|
|
103
|
+
# See https://github.com/formtastic/formtastic/wiki/Custom-Class-Finders
|
|
104
|
+
# Formtastic::FormBuilder.action_class_finder = Formtastic::ActionClassFinder
|
|
105
|
+
|
|
106
|
+
# Define custom namespaces in which to look up your Action classes. Default is
|
|
107
|
+
# to look up in the global scope and in Formtastic::Actions.
|
|
108
|
+
# Formtastic::FormBuilder.action_namespaces = [ ::Object, ::MyActionsModule, ::Formtastic::Actions ]
|
|
109
|
+
|
|
110
|
+
# Which columns to skip when automatically rendering a form without any fields specified.
|
|
111
|
+
# Formtastic::FormBuilder.skipped_columns = [:created_at, :updated_at, :created_on, :updated_on, :lock_version, :version]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class <%= name.camelize %>Input <%= @extension_sentence %>
|
|
2
|
+
<%- if !options[:extend] -%>
|
|
3
|
+
include Formtastic::Inputs::Base
|
|
4
|
+
<%- end -%>
|
|
5
|
+
|
|
6
|
+
<%- if !options[:extend] || (options[:extend] == "extend") -%>
|
|
7
|
+
def to_html
|
|
8
|
+
# Add your custom input definition here.
|
|
9
|
+
<%- if options[:extend] == "extend" -%>
|
|
10
|
+
super
|
|
11
|
+
<%- end -%>
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
<%- else -%>
|
|
15
|
+
def input_html_options
|
|
16
|
+
# Add your custom input extension here.
|
|
17
|
+
end
|
|
18
|
+
<%- end -%>
|
|
19
|
+
end
|
data/sample/basic_inputs.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
<li class="input url stringish optional" id="gem_url_input">
|
|
37
37
|
<label class="label" for="gem_url">URL</label>
|
|
38
38
|
<input id="gem_url" name="gem[url]" type="url">
|
|
39
|
-
<p class="inline-hints">Example: https://github.com/
|
|
39
|
+
<p class="inline-hints">Example: https://github.com/formtastic/formtastic</p>
|
|
40
40
|
</li>
|
|
41
41
|
|
|
42
42
|
<li class="input password stringish required" id="gem_password_input">
|
|
@@ -101,7 +101,27 @@
|
|
|
101
101
|
</ol>
|
|
102
102
|
</fieldset>
|
|
103
103
|
</li>
|
|
104
|
-
|
|
104
|
+
|
|
105
|
+
<li class="input date_picker optional">
|
|
106
|
+
<label class="label" for="gem_expiry">Expiry date</label>
|
|
107
|
+
<input id="gem_expiry" name="gem[gem_expiry]" type="date" size="10" maxlength="10" min="2012-01-01" max="2012-12-31" step="1" value="2012-01-01">
|
|
108
|
+
</li>
|
|
109
|
+
|
|
110
|
+
<li class="input datetime_picker optional">
|
|
111
|
+
<label class="label" for="gem_expiry">Expiry datetime-local</label>
|
|
112
|
+
<input id="gem_expiry" name="gem[gem_expiry]" type="datetime-local" size="16" maxlength="16" min="2012-01-01T00:00" max="2012-12-31T23:59" step="1800">
|
|
113
|
+
</li>
|
|
114
|
+
|
|
115
|
+
<li class="input datetime_picker optional">
|
|
116
|
+
<label class="label" for="gem_expiry">Expiry datetime</label>
|
|
117
|
+
<input id="gem_expiry" name="gem[gem_expiry]" type="datetime" size="16" maxlength="16" min="2012-01-01T00:00" max="2012-12-31T23:59" step="1800">
|
|
118
|
+
</li>
|
|
119
|
+
|
|
120
|
+
<li class="input time_picker optional">
|
|
121
|
+
<label class="label" for="gem_expiry">Expiry time</label>
|
|
122
|
+
<input id="gem_expiry" name="gem[gem_expiry]" type="time" size="5" maxlength="5" min="T00:00" max="23:59" step="60">
|
|
123
|
+
</li>
|
|
124
|
+
|
|
105
125
|
<li class="input string stringish optional autofocus" id="gem_autofocus_input">
|
|
106
126
|
<label class="label" for="gem_autofocus">Autofocus</label>
|
|
107
127
|
<input id="gem_autofocus" name="gem[autofocus]" type="text" value="The focus is set to this field" autofocus="autofocus">
|
|
@@ -195,7 +215,7 @@
|
|
|
195
215
|
<button id="gem_submit" type="reset">Reset</button>
|
|
196
216
|
</li>
|
|
197
217
|
<li class="action link_action">
|
|
198
|
-
<a href="#">Cancel</
|
|
218
|
+
<a href="#">Cancel</a>
|
|
199
219
|
</li>
|
|
200
220
|
</ol>
|
|
201
221
|
</fieldset>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
gem 'formtastic', path: '..'
|
|
2
|
+
gem 'bcrypt', '~> 3.1.7'
|
|
3
|
+
gem 'rails-dom-testing', group: :test
|
|
4
|
+
gem 'rexml', '~> 3.2' # to compensate for missing dependency in selenium-webdriver
|
|
5
|
+
|
|
6
|
+
# to speed up bundle install, reuse the bundle path
|
|
7
|
+
def bundle_path
|
|
8
|
+
File.expand_path ENV.fetch('BUNDLE_PATH', 'vendor/bundle')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if Rails.version >= '6.2'
|
|
12
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails'"
|
|
13
|
+
elsif Rails.version >= '6.1'
|
|
14
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails', branch: '6-1-stable'"
|
|
15
|
+
elsif Rails.version >= '6.0'
|
|
16
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails', branch: '6-0-stable'"
|
|
17
|
+
elsif Rails.version >= '5.2'
|
|
18
|
+
gsub_file 'Gemfile', /gem 'rails'.*/, "gem 'rails', '~> #{Rails.version}', github: 'rails/rails', branch: '5-2-stable'"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
### Ensure Dummy App's Ruby version matches the current environments Ruby Version
|
|
22
|
+
ruby_version = "ruby '#{RUBY_VERSION}'"
|
|
23
|
+
gsub_file 'Gemfile', /ruby '\d+.\d+.\d+'/, ruby_version
|
|
24
|
+
|
|
25
|
+
if bundle_install?
|
|
26
|
+
def run_bundle
|
|
27
|
+
previous_bundle_path = bundle_path
|
|
28
|
+
|
|
29
|
+
require "bundler"
|
|
30
|
+
Bundler.with_clean_env do
|
|
31
|
+
system("bundle install --jobs=3 --retry=3 --path=#{previous_bundle_path}")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
in_root do
|
|
37
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path('Gemfile')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
formtastic = -> do
|
|
41
|
+
generate(:scaffold, 'user name:string password:digest')
|
|
42
|
+
generate('formtastic:install')
|
|
43
|
+
generate('formtastic:form', 'user name password:password --force')
|
|
44
|
+
|
|
45
|
+
rails_command('db:migrate')
|
|
46
|
+
|
|
47
|
+
in_root do
|
|
48
|
+
inject_into_class 'app/models/user.rb', 'User', " has_secure_password\n"
|
|
49
|
+
inject_into_file 'app/assets/stylesheets/application.css', " *= require formtastic\n", before: ' *= require_self'
|
|
50
|
+
inject_into_class 'test/controllers/users_controller_test.rb', 'UsersControllerTest', <<-RUBY
|
|
51
|
+
|
|
52
|
+
test "should show form" do
|
|
53
|
+
get edit_user_path(@user)
|
|
54
|
+
|
|
55
|
+
assert_select 'form' do
|
|
56
|
+
assert_select 'li.input.string' do
|
|
57
|
+
assert_select 'input#user_name[type=text]'
|
|
58
|
+
end
|
|
59
|
+
assert_select 'li.input.password' do
|
|
60
|
+
assert_select 'input#user_password[type=password]'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
assert_select 'fieldset.actions' do
|
|
64
|
+
assert_select 'li.action.input_action' do
|
|
65
|
+
assert_select 'input[type=submit]'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end # test "should show form"
|
|
70
|
+
RUBY
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
after_bundle(&formtastic)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
set -o verbose
|
|
5
|
+
|
|
6
|
+
test_app=dummy
|
|
7
|
+
|
|
8
|
+
rm -rf ${test_app}
|
|
9
|
+
|
|
10
|
+
bundle exec rails new ${test_app} \
|
|
11
|
+
--template=$(dirname "$0")/integration-template.rb \
|
|
12
|
+
--skip-bootsnap \
|
|
13
|
+
--skip-javascript \
|
|
14
|
+
--skip-spring \
|
|
15
|
+
--skip-turbolinks
|
|
16
|
+
|
|
17
|
+
cd ${test_app} && export BUNDLE_GEMFILE=Gemfile
|
|
18
|
+
|
|
19
|
+
bundle exec rake test
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
require 'formtastic/action_class_finder'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Formtastic::ActionClassFinder do
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
it_behaves_like 'Specialized Class Finder' do
|
|
9
|
+
let(:default) { Formtastic::Actions }
|
|
10
|
+
let(:namespaces_setting) { :action_namespaces }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
require 'spec_helper'
|
|
3
3
|
|
|
4
|
-
describe 'ButtonAction', 'when submitting' do
|
|
4
|
+
RSpec.describe 'ButtonAction', 'when submitting' do
|
|
5
5
|
|
|
6
6
|
include FormtasticSpecHelper
|
|
7
7
|
|
|
@@ -15,12 +15,12 @@ describe 'ButtonAction', 'when submitting' do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'should render a submit type of button' do
|
|
18
|
-
output_buffer.
|
|
18
|
+
expect(output_buffer).to have_tag('li.action.button_action button[@type="submit"]')
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
describe 'ButtonAction', 'when resetting' do
|
|
23
|
+
RSpec.describe 'ButtonAction', 'when resetting' do
|
|
24
24
|
|
|
25
25
|
include FormtasticSpecHelper
|
|
26
26
|
|
|
@@ -34,16 +34,16 @@ describe 'ButtonAction', 'when resetting' do
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'should render a reset type of button' do
|
|
37
|
-
output_buffer.
|
|
37
|
+
expect(output_buffer).to have_tag('li.action.button_action button[@type="reset"]', :text => "Reset Post")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it 'should not render a value attribute' do
|
|
41
|
-
output_buffer.
|
|
41
|
+
expect(output_buffer).not_to have_tag('li.action.button_action button[@value]')
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
describe 'InputAction', 'when cancelling' do
|
|
46
|
+
RSpec.describe 'InputAction', 'when cancelling' do
|
|
47
47
|
|
|
48
48
|
include FormtasticSpecHelper
|
|
49
49
|
|
|
@@ -53,11 +53,11 @@ describe 'InputAction', 'when cancelling' do
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it 'should raise an error' do
|
|
56
|
-
|
|
56
|
+
expect {
|
|
57
57
|
concat(semantic_form_for(@new_post) do |builder|
|
|
58
58
|
concat(builder.action(:cancel, :as => :button))
|
|
59
59
|
end)
|
|
60
|
-
}.
|
|
60
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
end
|