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,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'email input' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "when object is provided" do
|
|
14
|
+
before do
|
|
15
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
16
|
+
concat(builder.input(:email))
|
|
17
|
+
end)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it_should_have_input_wrapper_with_class(:email)
|
|
21
|
+
it_should_have_input_wrapper_with_class(:input)
|
|
22
|
+
it_should_have_input_wrapper_with_class(:stringish)
|
|
23
|
+
it_should_have_input_wrapper_with_id("post_email_input")
|
|
24
|
+
it_should_have_label_with_text(/Email/)
|
|
25
|
+
it_should_have_label_for("post_email")
|
|
26
|
+
it_should_have_input_with_id("post_email")
|
|
27
|
+
it_should_have_input_with_type(:email)
|
|
28
|
+
it_should_have_input_with_name("post[email]")
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe "when namespace is provided" do
|
|
33
|
+
|
|
34
|
+
before do
|
|
35
|
+
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
|
36
|
+
concat(builder.input(:email))
|
|
37
|
+
end)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it_should_have_input_wrapper_with_id("context2_post_email_input")
|
|
41
|
+
it_should_have_label_and_input_with_id("context2_post_email")
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "when index is provided" do
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
49
|
+
mock_everything
|
|
50
|
+
|
|
51
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
52
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
|
53
|
+
concat(author.input(:name, :as => :email))
|
|
54
|
+
end)
|
|
55
|
+
end)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'should index the id of the wrapper' do
|
|
59
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should index the id of the select tag' do
|
|
63
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should index the name of the select tag' do
|
|
67
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
describe "when required" do
|
|
74
|
+
it "should add the required attribute to the input's html options" do
|
|
75
|
+
with_config :use_required_attribute, true do
|
|
76
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
77
|
+
concat(builder.input(:title, :as => :email, :required => true))
|
|
78
|
+
end)
|
|
79
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'file input' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
|
|
12
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
13
|
+
concat(builder.input(:body, :as => :file))
|
|
14
|
+
end)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it_should_have_input_wrapper_with_class("file")
|
|
18
|
+
it_should_have_input_wrapper_with_class(:input)
|
|
19
|
+
it_should_have_input_wrapper_with_id("post_body_input")
|
|
20
|
+
it_should_have_label_with_text(/Body/)
|
|
21
|
+
it_should_have_label_for("post_body")
|
|
22
|
+
it_should_have_input_with_id("post_body")
|
|
23
|
+
it_should_have_input_with_name("post[body]")
|
|
24
|
+
it_should_apply_error_logic_for_input_type(:file)
|
|
25
|
+
|
|
26
|
+
it 'should use input_html to style inputs' do
|
|
27
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
28
|
+
concat(builder.input(:title, :as => :file, :input_html => { :class => 'myclass' }))
|
|
29
|
+
end)
|
|
30
|
+
expect(output_buffer.to_str).to have_tag("form li input.myclass")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe "when namespace is provided" do
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
37
|
+
mock_everything
|
|
38
|
+
|
|
39
|
+
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
|
40
|
+
concat(builder.input(:body, :as => :file))
|
|
41
|
+
end)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it_should_have_input_wrapper_with_id("context2_post_body_input")
|
|
45
|
+
it_should_have_label_and_input_with_id("context2_post_body")
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "when index is provided" do
|
|
50
|
+
|
|
51
|
+
before do
|
|
52
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
53
|
+
mock_everything
|
|
54
|
+
|
|
55
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
56
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
|
57
|
+
concat(author.input(:name, :as => :file))
|
|
58
|
+
end)
|
|
59
|
+
end)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should index the id of the wrapper' do
|
|
63
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should index the id of the select tag' do
|
|
67
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'should index the name of the select tag' do
|
|
71
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
context "when required" do
|
|
78
|
+
it "should add the required attribute to the input's html options" do
|
|
79
|
+
with_config :use_required_attribute, true do
|
|
80
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
81
|
+
concat(builder.input(:title, :as => :file, :required => true))
|
|
82
|
+
end)
|
|
83
|
+
expect(output_buffer.to_str).to have_tag("input[@required]")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'hidden input' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
|
|
12
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
13
|
+
concat(builder.input(:secret, :as => :hidden))
|
|
14
|
+
concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
|
|
15
|
+
concat(builder.input(:reviewer, :as => :hidden, :input_html => {:class => 'new_post_reviewer', :id => 'new_post_reviewer'}))
|
|
16
|
+
end)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it_should_have_input_wrapper_with_class("hidden")
|
|
20
|
+
it_should_have_input_wrapper_with_class(:input)
|
|
21
|
+
it_should_have_input_wrapper_with_id("post_secret_input")
|
|
22
|
+
it_should_not_have_a_label
|
|
23
|
+
|
|
24
|
+
it "should generate a input field" do
|
|
25
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret")
|
|
26
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@type=\"hidden\"]")
|
|
27
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@name=\"post[secret]\"]")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should get value from the object" do
|
|
31
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_secret[@type=\"hidden\"][@value=\"1\"]")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should pass any explicitly specified value - using :input_html options" do
|
|
35
|
+
expect(output_buffer.to_str).to have_tag("form li input#post_published[@type=\"hidden\"][@value=\"true\"]")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should pass any option specified using :input_html" do
|
|
39
|
+
expect(output_buffer.to_str).to have_tag("form li input#new_post_reviewer[@type=\"hidden\"][@class=\"new_post_reviewer\"]")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should not render inline errors" do
|
|
43
|
+
@errors = double('errors')
|
|
44
|
+
allow(@errors).to receive(:[]).with(errors_matcher(:secret)).and_return(["foo", "bah"])
|
|
45
|
+
allow(@new_post).to receive(:errors).and_return(@errors)
|
|
46
|
+
|
|
47
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
48
|
+
concat(builder.input(:secret, :as => :hidden))
|
|
49
|
+
end)
|
|
50
|
+
|
|
51
|
+
expect(output_buffer.to_str).not_to have_tag("form li p.inline-errors")
|
|
52
|
+
expect(output_buffer.to_str).not_to have_tag("form li ul.errors")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should not render inline hints" do
|
|
56
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
57
|
+
concat(builder.input(:secret, :as => :hidden, :hint => "all your base are belong to use"))
|
|
58
|
+
end)
|
|
59
|
+
|
|
60
|
+
expect(output_buffer.to_str).not_to have_tag("form li p.inline-hints")
|
|
61
|
+
expect(output_buffer.to_str).not_to have_tag("form li ul.hints")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "when namespace is provided" do
|
|
65
|
+
|
|
66
|
+
before do
|
|
67
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
68
|
+
mock_everything
|
|
69
|
+
|
|
70
|
+
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
|
71
|
+
concat(builder.input(:secret, :as => :hidden))
|
|
72
|
+
concat(builder.input(:published, :as => :hidden, :input_html => {:value => true}))
|
|
73
|
+
concat(builder.input(:reviewer, :as => :hidden, :input_html => {:class => 'new_post_reviewer', :id => 'new_post_reviewer'}))
|
|
74
|
+
end)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
attributes_to_check = [:secret, :published, :reviewer]
|
|
78
|
+
attributes_to_check.each do |a|
|
|
79
|
+
it_should_have_input_wrapper_with_id("context2_post_#{a}_input")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
(attributes_to_check - [:reviewer]).each do |a|
|
|
83
|
+
it_should_have_input_with_id("context2_post_#{a}")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe "when index is provided" do
|
|
89
|
+
|
|
90
|
+
before do
|
|
91
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
92
|
+
mock_everything
|
|
93
|
+
|
|
94
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
95
|
+
concat(builder.fields_for(:author, :index => 3) do |author|
|
|
96
|
+
concat(author.input(:name, :as => :hidden))
|
|
97
|
+
end)
|
|
98
|
+
end)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'should index the id of the wrapper' do
|
|
102
|
+
expect(output_buffer.to_str).to have_tag("li#post_author_attributes_3_name_input")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should index the id of the select tag' do
|
|
106
|
+
expect(output_buffer.to_str).to have_tag("input#post_author_attributes_3_name")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'should index the name of the select tag' do
|
|
110
|
+
expect(output_buffer.to_str).to have_tag("input[@name='post[author_attributes][3][name]']")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
context "when required" do
|
|
117
|
+
it "should not add the required attribute to the input's html options" do
|
|
118
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
119
|
+
concat(builder.input(:title, :as => :hidden, :required => true))
|
|
120
|
+
end)
|
|
121
|
+
expect(output_buffer.to_str).not_to have_tag("input[@required]")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
context "when :autofocus is provided in :input_html" do
|
|
126
|
+
it "should not add the autofocus attribute to the input's html options" do
|
|
127
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
128
|
+
concat(builder.input(:title, :as => :hidden, :input_html => {:autofocus => true}))
|
|
129
|
+
end)
|
|
130
|
+
expect(output_buffer.to_str).not_to have_tag("input[@autofocus]")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe "*select: options[:include_blank]" do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
|
|
12
|
+
allow(@new_post).to receive(:author_id).and_return(nil)
|
|
13
|
+
allow(@new_post).to receive(:publish_at).and_return(nil)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
SELECT_INPUT_TYPES = {
|
|
17
|
+
:select => :author,
|
|
18
|
+
:datetime_select => :publish_at,
|
|
19
|
+
:date_select => :publish_at,
|
|
20
|
+
:time_select => :publish_at
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SELECT_INPUT_TYPES.each do |as, attribute|
|
|
24
|
+
describe "for #{as} input" do
|
|
25
|
+
|
|
26
|
+
describe 'when :include_blank is not set' do
|
|
27
|
+
it 'blank value should be included if the default value specified in config is true' do
|
|
28
|
+
Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
|
29
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
30
|
+
concat(builder.input(attribute, :as => as))
|
|
31
|
+
end)
|
|
32
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'blank value should not be included if the default value specified in config is false' do
|
|
36
|
+
Formtastic::FormBuilder.include_blank_for_select_by_default = false
|
|
37
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
38
|
+
concat(builder.input(attribute, :as => as))
|
|
39
|
+
end)
|
|
40
|
+
expect(output_buffer.to_str).not_to have_tag("form li select option[@value='']", "")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
after do
|
|
44
|
+
Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'when :include_blank is set to false' do
|
|
49
|
+
it 'should not have a blank option' do
|
|
50
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
51
|
+
concat(builder.input(attribute, :as => as, :include_blank => false))
|
|
52
|
+
end)
|
|
53
|
+
expect(output_buffer.to_str).not_to have_tag("form li select option[@value='']", "")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe 'when :include_blank is set to true' do
|
|
58
|
+
it 'should have a blank select option' do
|
|
59
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
60
|
+
concat(builder.input(attribute, :as => as, :include_blank => true))
|
|
61
|
+
end)
|
|
62
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if as == :select
|
|
67
|
+
describe 'when :include_blank is set to a string' do
|
|
68
|
+
it 'should have a select option with blank value but that string as text' do
|
|
69
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
70
|
+
concat(builder.input(attribute, :as => as, :include_blank => 'string'))
|
|
71
|
+
end)
|
|
72
|
+
expect(output_buffer.to_str).to have_tag("form li select option[@value='']", "string")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'Formtastic::FormBuilder#label' do
|
|
5
|
+
|
|
6
|
+
include FormtasticSpecHelper
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
10
|
+
mock_everything
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should add "required string" only once with caching enabled' do
|
|
14
|
+
with_config :i18n_cache_lookups, true do
|
|
15
|
+
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => "I18n title" } } } }
|
|
16
|
+
required_string = "[req_string]"
|
|
17
|
+
default_required_str = Formtastic::FormBuilder.required_string
|
|
18
|
+
Formtastic::FormBuilder.required_string = required_string
|
|
19
|
+
|
|
20
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
21
|
+
builder.input(:title, :required => true, :label => true)
|
|
22
|
+
end)
|
|
23
|
+
@output_buffer = ActionView::OutputBuffer.new ''
|
|
24
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
25
|
+
builder.input(:title, :required => true, :label => true)
|
|
26
|
+
end)
|
|
27
|
+
|
|
28
|
+
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
|
|
29
|
+
Formtastic::FormBuilder.required_string = default_required_str
|
|
30
|
+
|
|
31
|
+
expect(output_buffer.to_s.scan(required_string).count).to eq(1)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should humanize the given attribute' do
|
|
36
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
37
|
+
builder.input(:title)
|
|
38
|
+
end)
|
|
39
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /Title/)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should apply a "for" attribute to the label' do
|
|
43
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
44
|
+
builder.input(:title)
|
|
45
|
+
end)
|
|
46
|
+
expect(output_buffer.to_str).to have_tag('label[for=post_title]')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should apply a "label" class to the label' do
|
|
50
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
51
|
+
builder.input(:title)
|
|
52
|
+
end)
|
|
53
|
+
expect(output_buffer.to_str).to have_tag('label.label')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'should use i18n instead of the method name when method given as a String' do
|
|
57
|
+
with_config :i18n_cache_lookups, true do
|
|
58
|
+
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => "I18n title" } } } }
|
|
59
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
60
|
+
builder.input("title")
|
|
61
|
+
end)
|
|
62
|
+
::I18n.backend.store_translations :en, { :formtastic => { :labels => { :post => { :title => nil } } } }
|
|
63
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /I18n title/)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'should humanize the given attribute for date fields' do
|
|
68
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
69
|
+
builder.input(:publish_at)
|
|
70
|
+
end)
|
|
71
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /Publish at/)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe 'when required is given' do
|
|
75
|
+
it 'should append a required note' do
|
|
76
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
77
|
+
builder.input(:title, :required => true)
|
|
78
|
+
end)
|
|
79
|
+
expect(output_buffer.to_str).to have_tag('label abbr', '*')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe "when label_html is given" do
|
|
84
|
+
it "should allow label_html to override the class" do
|
|
85
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
86
|
+
builder.input(:title, :label_html => { :class => 'my_class' } )
|
|
87
|
+
end)
|
|
88
|
+
expect(output_buffer.to_str).to have_tag('label.my_class', /Title/)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should allow label_html to add custom attributes" do
|
|
92
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
93
|
+
builder.input(:title, :label_html => { :data => { :tooltip => 'Great Tooltip' } } )
|
|
94
|
+
end)
|
|
95
|
+
aggregate_failures do
|
|
96
|
+
expect(output_buffer.to_str).to have_tag('label[data-tooltip="Great Tooltip"]')
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe 'when a collection is given' do
|
|
102
|
+
it 'should use a supplied label_method for simple collections' do
|
|
103
|
+
with_deprecation_silenced do
|
|
104
|
+
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
|
105
|
+
concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => :to_s, :member_label => proc {|f| ('Label_%s' % [f])}))
|
|
106
|
+
end)
|
|
107
|
+
end
|
|
108
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label', :text => /Label_[abc]/, :count => 3)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'should use a supplied value_method for simple collections' do
|
|
112
|
+
with_deprecation_silenced do
|
|
113
|
+
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
|
114
|
+
concat(builder.input(:author_id, :as => :check_boxes, :collection => [:a, :b, :c], :member_value => proc {|f| ('Value_%s' % [f.to_s])}))
|
|
115
|
+
end)
|
|
116
|
+
end
|
|
117
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_a"]')
|
|
118
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_b"]')
|
|
119
|
+
expect(output_buffer.to_str).to have_tag('form li fieldset ol li label input[value="Value_c"]')
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe 'when label is given' do
|
|
124
|
+
it 'should allow the text to be given as label option' do
|
|
125
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
126
|
+
builder.input(:title, :label => 'My label')
|
|
127
|
+
end)
|
|
128
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /My label/)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'should allow the text to be given as label option for date fields' do
|
|
132
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
133
|
+
builder.input(:publish_at, :label => 'My other label')
|
|
134
|
+
end)
|
|
135
|
+
expect(output_buffer.to_str).to have_tag('label', :text => /My other label/)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it 'should return nil if label is false' do
|
|
139
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
140
|
+
builder.input(:title, :label => false)
|
|
141
|
+
end)
|
|
142
|
+
expect(output_buffer.to_str).not_to have_tag('label')
|
|
143
|
+
expect(output_buffer.to_str).not_to include(">")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'should return nil if label is false for timeish fragments' do
|
|
147
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
148
|
+
builder.input(:title, :as => :time_select, :label => false)
|
|
149
|
+
end)
|
|
150
|
+
expect(output_buffer.to_str).not_to have_tag('li.time > label')
|
|
151
|
+
expect(output_buffer.to_str).not_to include(">")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'should html escape the label string by default' do
|
|
155
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
156
|
+
builder.input(:title, :label => '<b>My label</b>')
|
|
157
|
+
end)
|
|
158
|
+
expect(output_buffer.to_str).to include('<b>')
|
|
159
|
+
expect(output_buffer.to_str).not_to include('<b>')
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it 'should not html escape the label if configured that way' do
|
|
163
|
+
Formtastic::FormBuilder.escape_html_entities_in_hints_and_labels = false
|
|
164
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
165
|
+
builder.input(:title, :label => '<b>My label</b>')
|
|
166
|
+
end)
|
|
167
|
+
expect(output_buffer.to_str).to have_tag("label b", :text => "My label")
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'should not html escape the label string for html_safe strings' do
|
|
171
|
+
Formtastic::FormBuilder.escape_html_entities_in_hints_and_labels = true
|
|
172
|
+
concat(semantic_form_for(@new_post) do |builder|
|
|
173
|
+
builder.input(:title, :label => '<b>My label</b>'.html_safe)
|
|
174
|
+
end)
|
|
175
|
+
expect(output_buffer.to_str).to have_tag('label b')
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|