mega-safe-tool 0.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 +7 -0
- data/formtastic-6.0.0/Appraisals +23 -0
- data/formtastic-6.0.0/CONTRIBUTING.md +27 -0
- data/formtastic-6.0.0/Gemfile +8 -0
- data/formtastic-6.0.0/MIT-LICENSE +20 -0
- data/formtastic-6.0.0/README.md +600 -0
- data/formtastic-6.0.0/RELEASE_PROCESS +7 -0
- data/formtastic-6.0.0/Rakefile +54 -0
- data/formtastic-6.0.0/bin/appraisal +8 -0
- data/formtastic-6.0.0/formtastic.gemspec +45 -0
- data/formtastic-6.0.0/gemfiles/rails_72.gemfile +9 -0
- data/formtastic-6.0.0/gemfiles/rails_80.gemfile +9 -0
- data/formtastic-6.0.0/gemfiles/rails_81.gemfile +9 -0
- data/formtastic-6.0.0/gemfiles/rails_edge.gemfile +9 -0
- data/formtastic-6.0.0/lib/formtastic/action_class_finder.rb +19 -0
- data/formtastic-6.0.0/lib/formtastic/actions/base.rb +157 -0
- data/formtastic-6.0.0/lib/formtastic/actions/button_action.rb +68 -0
- data/formtastic-6.0.0/lib/formtastic/actions/buttonish.rb +18 -0
- data/formtastic-6.0.0/lib/formtastic/actions/input_action.rb +71 -0
- data/formtastic-6.0.0/lib/formtastic/actions/link_action.rb +89 -0
- data/formtastic-6.0.0/lib/formtastic/actions.rb +15 -0
- data/formtastic-6.0.0/lib/formtastic/deprecation.rb +6 -0
- data/formtastic-6.0.0/lib/formtastic/form_builder.rb +109 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/action_helper.rb +115 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/actions_helper.rb +169 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/enum.rb +14 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/errors_helper.rb +139 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/fieldset_wrapper.rb +85 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/file_column_detection.rb +17 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/form_helper.rb +204 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/input_helper.rb +349 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/inputs_helper.rb +421 -0
- data/formtastic-6.0.0/lib/formtastic/helpers/reflection.rb +38 -0
- data/formtastic-6.0.0/lib/formtastic/helpers.rb +16 -0
- data/formtastic-6.0.0/lib/formtastic/html_attributes.rb +33 -0
- data/formtastic-6.0.0/lib/formtastic/i18n.rb +33 -0
- data/formtastic-6.0.0/lib/formtastic/input_class_finder.rb +19 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/aria.rb +26 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/associations.rb +32 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/choices.rb +109 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/collections.rb +158 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/database.rb +20 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/datetime_pickerish.rb +86 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/errors.rb +59 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/fileish.rb +24 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/hints.rb +32 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/html.rb +54 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/labelling.rb +53 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/naming.rb +43 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/numeric.rb +51 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/options.rb +18 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/placeholder.rb +18 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/stringish.rb +39 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/timeish.rb +246 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/validations.rb +250 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base/wrapping.rb +51 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/base.rb +79 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/boolean_input.rb +119 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/check_boxes_input.rb +198 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/color_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/country_input.rb +90 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/datalist_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/date_picker_input.rb +94 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/date_select_input.rb +35 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/datetime_picker_input.rb +104 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/datetime_select_input.rb +13 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/email_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/file_input.rb +43 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/hidden_input.rb +63 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/number_input.rb +89 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/password_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/phone_input.rb +43 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/radio_input.rb +164 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/range_input.rb +96 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/search_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/select_input.rb +236 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/string_input.rb +37 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/text_input.rb +49 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/time_picker_input.rb +100 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/time_select_input.rb +39 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/time_zone_input.rb +59 -0
- data/formtastic-6.0.0/lib/formtastic/inputs/url_input.rb +42 -0
- data/formtastic-6.0.0/lib/formtastic/inputs.rb +43 -0
- data/formtastic-6.0.0/lib/formtastic/localized_string.rb +18 -0
- data/formtastic-6.0.0/lib/formtastic/localizer.rb +151 -0
- data/formtastic-6.0.0/lib/formtastic/namespaced_class_finder.rb +98 -0
- data/formtastic-6.0.0/lib/formtastic/version.rb +4 -0
- data/formtastic-6.0.0/lib/formtastic.rb +48 -0
- data/formtastic-6.0.0/lib/generators/formtastic/form/form_generator.rb +111 -0
- data/formtastic-6.0.0/lib/generators/formtastic/input/input_generator.rb +47 -0
- data/formtastic-6.0.0/lib/generators/formtastic/install/install_generator.rb +23 -0
- data/formtastic-6.0.0/lib/generators/formtastic/stylesheets/stylesheets_generator.rb +15 -0
- data/formtastic-6.0.0/lib/generators/templates/_form.html.erb +11 -0
- data/formtastic-6.0.0/lib/generators/templates/_form.html.haml +8 -0
- data/formtastic-6.0.0/lib/generators/templates/_form.html.slim +8 -0
- data/formtastic-6.0.0/lib/generators/templates/formtastic.css +289 -0
- data/formtastic-6.0.0/lib/generators/templates/formtastic.rb +118 -0
- data/formtastic-6.0.0/lib/generators/templates/input.rb +19 -0
- data/formtastic-6.0.0/lib/locale/en.yml +10 -0
- data/formtastic-6.0.0/sample/basic_inputs.html +224 -0
- data/formtastic-6.0.0/sample/config.ru +69 -0
- data/formtastic-6.0.0/sample/index.html +14 -0
- data/formtastic-6.0.0/script/integration-template.rb +76 -0
- data/formtastic-6.0.0/script/integration.sh +32 -0
- data/formtastic-6.0.0/spec/action_class_finder_spec.rb +12 -0
- data/formtastic-6.0.0/spec/actions/button_action_spec.rb +63 -0
- data/formtastic-6.0.0/spec/actions/generic_action_spec.rb +521 -0
- data/formtastic-6.0.0/spec/actions/input_action_spec.rb +59 -0
- data/formtastic-6.0.0/spec/actions/link_action_spec.rb +92 -0
- data/formtastic-6.0.0/spec/builder/custom_builder_spec.rb +132 -0
- data/formtastic-6.0.0/spec/builder/error_proc_spec.rb +27 -0
- data/formtastic-6.0.0/spec/builder/semantic_fields_for_spec.rb +213 -0
- data/formtastic-6.0.0/spec/fast_spec_helper.rb +12 -0
- data/formtastic-6.0.0/spec/generators/formtastic/form/form_generator_spec.rb +132 -0
- data/formtastic-6.0.0/spec/generators/formtastic/input/input_generator_spec.rb +125 -0
- data/formtastic-6.0.0/spec/generators/formtastic/install/install_generator_spec.rb +48 -0
- data/formtastic-6.0.0/spec/generators/formtastic/stylesheets/stylesheets_generator_spec.rb +22 -0
- data/formtastic-6.0.0/spec/helpers/action_helper_spec.rb +338 -0
- data/formtastic-6.0.0/spec/helpers/actions_helper_spec.rb +143 -0
- data/formtastic-6.0.0/spec/helpers/form_helper_spec.rb +224 -0
- data/formtastic-6.0.0/spec/helpers/input_helper_spec.rb +991 -0
- data/formtastic-6.0.0/spec/helpers/inputs_helper_spec.rb +669 -0
- data/formtastic-6.0.0/spec/helpers/reflection_helper_spec.rb +32 -0
- data/formtastic-6.0.0/spec/helpers/semantic_errors_helper_spec.rb +220 -0
- data/formtastic-6.0.0/spec/i18n_spec.rb +210 -0
- data/formtastic-6.0.0/spec/input_class_finder_spec.rb +10 -0
- data/formtastic-6.0.0/spec/inputs/base/collections_spec.rb +119 -0
- data/formtastic-6.0.0/spec/inputs/base/validations_spec.rb +481 -0
- data/formtastic-6.0.0/spec/inputs/boolean_input_spec.rb +254 -0
- data/formtastic-6.0.0/spec/inputs/check_boxes_input_spec.rb +547 -0
- data/formtastic-6.0.0/spec/inputs/color_input_spec.rb +85 -0
- data/formtastic-6.0.0/spec/inputs/country_input_spec.rb +133 -0
- data/formtastic-6.0.0/spec/inputs/custom_input_spec.rb +51 -0
- data/formtastic-6.0.0/spec/inputs/datalist_input_spec.rb +61 -0
- data/formtastic-6.0.0/spec/inputs/date_picker_input_spec.rb +449 -0
- data/formtastic-6.0.0/spec/inputs/date_select_input_spec.rb +249 -0
- data/formtastic-6.0.0/spec/inputs/datetime_picker_input_spec.rb +490 -0
- data/formtastic-6.0.0/spec/inputs/datetime_select_input_spec.rb +209 -0
- data/formtastic-6.0.0/spec/inputs/email_input_spec.rb +85 -0
- data/formtastic-6.0.0/spec/inputs/file_input_spec.rb +89 -0
- data/formtastic-6.0.0/spec/inputs/hidden_input_spec.rb +135 -0
- data/formtastic-6.0.0/spec/inputs/include_blank_spec.rb +78 -0
- data/formtastic-6.0.0/spec/inputs/label_spec.rb +181 -0
- data/formtastic-6.0.0/spec/inputs/number_input_spec.rb +815 -0
- data/formtastic-6.0.0/spec/inputs/password_input_spec.rb +99 -0
- data/formtastic-6.0.0/spec/inputs/phone_input_spec.rb +85 -0
- data/formtastic-6.0.0/spec/inputs/placeholder_spec.rb +71 -0
- data/formtastic-6.0.0/spec/inputs/radio_input_spec.rb +326 -0
- data/formtastic-6.0.0/spec/inputs/range_input_spec.rb +505 -0
- data/formtastic-6.0.0/spec/inputs/readonly_spec.rb +50 -0
- data/formtastic-6.0.0/spec/inputs/search_input_spec.rb +84 -0
- data/formtastic-6.0.0/spec/inputs/select_input_spec.rb +661 -0
- data/formtastic-6.0.0/spec/inputs/string_input_spec.rb +326 -0
- data/formtastic-6.0.0/spec/inputs/text_input_spec.rb +187 -0
- data/formtastic-6.0.0/spec/inputs/time_picker_input_spec.rb +455 -0
- data/formtastic-6.0.0/spec/inputs/time_select_input_spec.rb +261 -0
- data/formtastic-6.0.0/spec/inputs/time_zone_input_spec.rb +143 -0
- data/formtastic-6.0.0/spec/inputs/url_input_spec.rb +85 -0
- data/formtastic-6.0.0/spec/inputs/with_options_spec.rb +43 -0
- data/formtastic-6.0.0/spec/localizer_spec.rb +130 -0
- data/formtastic-6.0.0/spec/namespaced_class_finder_spec.rb +90 -0
- data/formtastic-6.0.0/spec/schema.rb +22 -0
- data/formtastic-6.0.0/spec/spec.opts +2 -0
- data/formtastic-6.0.0/spec/spec_helper.rb +466 -0
- data/formtastic-6.0.0/spec/support/custom_macros.rb +570 -0
- data/formtastic-6.0.0/spec/support/deprecation.rb +7 -0
- data/formtastic-6.0.0/spec/support/shared_examples.rb +13 -0
- data/formtastic-6.0.0/spec/support/specialized_class_finder_shared_example.rb +27 -0
- data/formtastic-6.0.0/spec/support/test_environment.rb +46 -0
- data/mega-safe-tool.gemspec +11 -0
- metadata +209 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'FormHelper' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#semantic_form_for' do
|
|
14
|
+
|
|
15
|
+
it 'yields an instance of Formtastic::FormBuilder' do
|
|
16
|
+
semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
17
|
+
expect(builder.class).to eq(Formtastic::FormBuilder)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'adds a class of "formtastic" to the generated form' do
|
|
22
|
+
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
23
|
+
end)
|
|
24
|
+
expect(output_buffer.to_str).to have_tag("form.formtastic")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'does not add "novalidate" attribute to the generated form when configured to do so' do
|
|
28
|
+
with_config :perform_browser_validations, true do
|
|
29
|
+
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
30
|
+
end)
|
|
31
|
+
expect(output_buffer.to_str).not_to have_tag("form[@novalidate]")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'adds "novalidate" attribute to the generated form when configured to do so' do
|
|
36
|
+
with_config :perform_browser_validations, false do
|
|
37
|
+
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
38
|
+
end)
|
|
39
|
+
expect(output_buffer.to_str).to have_tag("form[@novalidate]")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'allows form HTML to override "novalidate" attribute when configured to validate' do
|
|
44
|
+
with_config :perform_browser_validations, false do
|
|
45
|
+
concat(semantic_form_for(@new_post, :url => '/hello', :html => { :novalidate => true }) do |builder|
|
|
46
|
+
end)
|
|
47
|
+
expect(output_buffer.to_str).to have_tag("form[@novalidate]")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'allows form HTML to override "novalidate" attribute when configured to not validate' do
|
|
52
|
+
with_config :perform_browser_validations, true do
|
|
53
|
+
concat(semantic_form_for(@new_post, :url => '/hello', :html => { :novalidate => false }) do |builder|
|
|
54
|
+
end)
|
|
55
|
+
expect(output_buffer.to_str).not_to have_tag("form[@novalidate]")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'adds a class of "xyz" to the generated form' do
|
|
60
|
+
Formtastic::Helpers::FormHelper.default_form_class = 'xyz'
|
|
61
|
+
concat(semantic_form_for(::Post.new, :as => :post, :url => '/hello') do |builder|
|
|
62
|
+
end)
|
|
63
|
+
expect(output_buffer.to_str).to have_tag("form.xyz")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'omits the leading spaces from the classes in the generated form when the default class is nil' do
|
|
67
|
+
Formtastic::Helpers::FormHelper.default_form_class = nil
|
|
68
|
+
concat(semantic_form_for(::Post.new, :as => :post, :url => '/hello') do |builder|
|
|
69
|
+
end)
|
|
70
|
+
expect(output_buffer.to_str).to have_tag("form[class='post']")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'adds class matching the object name to the generated form when a symbol is provided' do
|
|
74
|
+
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
75
|
+
end)
|
|
76
|
+
expect(output_buffer.to_str).to have_tag("form.post")
|
|
77
|
+
|
|
78
|
+
concat(semantic_form_for(:project, :url => '/hello') do |builder|
|
|
79
|
+
end)
|
|
80
|
+
expect(output_buffer.to_str).to have_tag("form.project")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'adds class matching the :as option when provided' do
|
|
84
|
+
concat(semantic_form_for(@new_post, :as => :message, :url => '/hello') do |builder|
|
|
85
|
+
end)
|
|
86
|
+
expect(output_buffer.to_str).to have_tag("form.message")
|
|
87
|
+
|
|
88
|
+
concat(semantic_form_for([:admins, @new_post], :as => :message, :url => '/hello') do |builder|
|
|
89
|
+
end)
|
|
90
|
+
expect(output_buffer.to_str).to have_tag("form.message")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'adds class matching the object\'s class to the generated form when an object is provided' do
|
|
94
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
95
|
+
end)
|
|
96
|
+
expect(output_buffer.to_str).to have_tag("form.post")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'adds a namespaced class to the generated form' do
|
|
100
|
+
concat(semantic_form_for(::Namespaced::Post.new, :url => '/hello') do |builder|
|
|
101
|
+
end)
|
|
102
|
+
expect(output_buffer.to_str).to have_tag("form.namespaced_post")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'adds a customized class to the generated form' do
|
|
106
|
+
Formtastic::Helpers::FormHelper.default_form_model_class_proc = lambda { |model_class_name| "#{model_class_name}_form" }
|
|
107
|
+
concat(semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
108
|
+
end)
|
|
109
|
+
expect(output_buffer.to_str).to have_tag("form.post_form")
|
|
110
|
+
|
|
111
|
+
concat(semantic_form_for(:project, :url => '/hello') do |builder|
|
|
112
|
+
end)
|
|
113
|
+
expect(output_buffer.to_str).to have_tag("form.project_form")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe 'allows :html options' do
|
|
117
|
+
before(:example) do
|
|
118
|
+
concat(semantic_form_for(@new_post, :url => '/hello', :html => { :id => "something-special", :class => "something-extra", :multipart => true }) do |builder|
|
|
119
|
+
end)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'to add a id of "something-special" to generated form' do
|
|
123
|
+
expect(output_buffer.to_str).to have_tag("form#something-special")
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it 'to add a class of "something-extra" to generated form' do
|
|
127
|
+
expect(output_buffer.to_str).to have_tag("form.something-extra")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'to add enctype="multipart/form-data"' do
|
|
131
|
+
expect(output_buffer.to_str).to have_tag('form[@enctype="multipart/form-data"]')
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'can be called with a resource-oriented style' do
|
|
136
|
+
semantic_form_for(@new_post) do |builder|
|
|
137
|
+
expect(builder.object.class).to eq(::Post)
|
|
138
|
+
expect(builder.object_name).to eq("post")
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'can be called with a generic style and instance variable' do
|
|
143
|
+
semantic_form_for(@new_post, :as => :post, :url => new_post_path) do |builder|
|
|
144
|
+
expect(builder.object.class).to eq(::Post)
|
|
145
|
+
expect(builder.object_name.to_s).to eq("post") # TODO: is this forced .to_s a bad assumption somewhere?
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'can be called with a generic style and inline object' do
|
|
150
|
+
semantic_form_for(@new_post, :url => new_post_path) do |builder|
|
|
151
|
+
expect(builder.object.class).to eq(::Post)
|
|
152
|
+
expect(builder.object_name.to_s).to eq("post") # TODO: is this forced .to_s a bad assumption somewhere?
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe 'ActionView::Base.field_error_proc' do
|
|
157
|
+
around do |ex|
|
|
158
|
+
error_proc = Formtastic::Helpers::FormHelper.formtastic_field_error_proc
|
|
159
|
+
ex.run
|
|
160
|
+
Formtastic::Helpers::FormHelper.formtastic_field_error_proc = error_proc
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'is set to no-op wrapper by default' do
|
|
164
|
+
semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
165
|
+
expect(::ActionView::Base.field_error_proc.call("html", nil)).to eq("html")
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'is set to the configured custom field_error_proc' do
|
|
170
|
+
field_error_proc = double()
|
|
171
|
+
Formtastic::Helpers::FormHelper.formtastic_field_error_proc = field_error_proc
|
|
172
|
+
semantic_form_for(@new_post, :url => '/hello') do |builder|
|
|
173
|
+
expect(::ActionView::Base.field_error_proc).to eq(field_error_proc)
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it 'is restored to its original value after the form is rendered' do
|
|
178
|
+
expect do
|
|
179
|
+
Formtastic::Helpers::FormHelper.formtastic_field_error_proc = proc {""}
|
|
180
|
+
semantic_form_for(@new_post, :url => '/hello') { |builder| }
|
|
181
|
+
end.not_to change(::ActionView::Base, :field_error_proc)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
describe "with :builder option" do
|
|
186
|
+
it "yields an instance of the given builder" do
|
|
187
|
+
class MyAwesomeCustomBuilder < Formtastic::FormBuilder
|
|
188
|
+
end
|
|
189
|
+
semantic_form_for(@new_post, :url => '/hello', :builder => MyAwesomeCustomBuilder) do |builder|
|
|
190
|
+
expect(builder.class).to eq(MyAwesomeCustomBuilder)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
describe 'with :namespace option' do
|
|
196
|
+
it "should set the custom_namespace" do
|
|
197
|
+
semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
|
198
|
+
expect(builder.dom_id_namespace).to eq('context2')
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
describe 'without :namespace option' do
|
|
204
|
+
it 'defaults to class settings' do
|
|
205
|
+
expect(Formtastic::FormBuilder).to receive(:custom_namespace).and_return('context2')
|
|
206
|
+
|
|
207
|
+
semantic_form_for(@new_post) do |builder|
|
|
208
|
+
expect(builder.dom_id_namespace).to eq('context2')
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
describe '#semantic_fields_for' do
|
|
216
|
+
it 'yields an instance of Formtastic::FormBuilder' do
|
|
217
|
+
semantic_fields_for(@new_post) do |builder|
|
|
218
|
+
expect(builder.class).to be(Formtastic::FormBuilder)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
end
|
|
224
|
+
|