formtastic 3.1.1 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.gitignore +3 -2
- data/.travis.yml +29 -24
- data/CHANGELOG.md +49 -0
- data/DEPRECATIONS +4 -1
- data/Gemfile.lock +104 -0
- data/{README.textile → README.md} +178 -166
- data/Rakefile +20 -1
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +9 -15
- data/gemfiles/rails_5.2/Gemfile +5 -0
- data/gemfiles/rails_6.0/Gemfile +5 -0
- data/gemfiles/rails_edge/Gemfile +13 -0
- data/lib/formtastic.rb +9 -11
- data/lib/formtastic/actions.rb +6 -3
- data/lib/formtastic/deprecation.rb +1 -38
- data/lib/formtastic/engine.rb +3 -1
- data/lib/formtastic/form_builder.rb +11 -24
- data/lib/formtastic/helpers.rb +1 -1
- data/lib/formtastic/helpers/action_helper.rb +1 -48
- data/lib/formtastic/helpers/enum.rb +13 -0
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +13 -9
- data/lib/formtastic/helpers/form_helper.rb +1 -1
- data/lib/formtastic/helpers/input_helper.rb +23 -77
- data/lib/formtastic/helpers/inputs_helper.rb +27 -22
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/inputs.rb +32 -29
- data/lib/formtastic/inputs/base/choices.rb +1 -1
- data/lib/formtastic/inputs/base/collections.rb +43 -10
- data/lib/formtastic/inputs/base/database.rb +7 -2
- data/lib/formtastic/inputs/base/errors.rb +4 -4
- data/lib/formtastic/inputs/base/hints.rb +1 -1
- data/lib/formtastic/inputs/base/html.rb +7 -6
- data/lib/formtastic/inputs/base/naming.rb +4 -4
- data/lib/formtastic/inputs/base/options.rb +2 -3
- data/lib/formtastic/inputs/base/timeish.rb +5 -1
- data/lib/formtastic/inputs/base/validations.rb +38 -12
- data/lib/formtastic/inputs/check_boxes_input.rb +13 -5
- data/lib/formtastic/inputs/color_input.rb +0 -1
- data/lib/formtastic/inputs/country_input.rb +3 -1
- data/lib/formtastic/inputs/radio_input.rb +20 -0
- data/lib/formtastic/inputs/select_input.rb +29 -1
- data/lib/formtastic/inputs/time_zone_input.rb +16 -6
- data/lib/formtastic/localizer.rb +20 -22
- data/lib/formtastic/namespaced_class_finder.rb +1 -1
- data/lib/formtastic/version.rb +1 -1
- data/lib/generators/formtastic/form/form_generator.rb +1 -1
- data/lib/generators/formtastic/input/input_generator.rb +46 -0
- data/lib/generators/templates/formtastic.rb +14 -13
- data/lib/generators/templates/input.rb +19 -0
- data/script/integration-template.rb +71 -0
- data/script/integration.sh +19 -0
- data/spec/action_class_finder_spec.rb +1 -1
- data/spec/actions/button_action_spec.rb +8 -8
- data/spec/actions/generic_action_spec.rb +60 -60
- 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 +27 -27
- data/spec/fast_spec_helper.rb +12 -0
- data/spec/generators/formtastic/form/form_generator_spec.rb +25 -25
- 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 +328 -10
- data/spec/helpers/actions_helper_spec.rb +17 -17
- data/spec/helpers/form_helper_spec.rb +37 -37
- data/spec/helpers/input_helper_spec.rb +975 -2
- data/spec/helpers/inputs_helper_spec.rb +120 -105
- data/spec/helpers/reflection_helper_spec.rb +3 -3
- data/spec/helpers/semantic_errors_helper_spec.rb +22 -22
- data/spec/i18n_spec.rb +26 -26
- data/spec/input_class_finder_spec.rb +1 -1
- 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 +55 -55
- data/spec/inputs/check_boxes_input_spec.rb +155 -108
- data/spec/inputs/color_input_spec.rb +51 -63
- data/spec/inputs/country_input_spec.rb +20 -20
- data/spec/inputs/custom_input_spec.rb +2 -6
- data/spec/inputs/datalist_input_spec.rb +1 -1
- data/spec/inputs/date_picker_input_spec.rb +42 -42
- data/spec/inputs/date_select_input_spec.rb +51 -37
- data/spec/inputs/datetime_picker_input_spec.rb +46 -46
- data/spec/inputs/datetime_select_input_spec.rb +53 -37
- 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 +18 -18
- data/spec/inputs/include_blank_spec.rb +8 -8
- data/spec/inputs/label_spec.rb +20 -20
- 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 +5 -5
- data/spec/inputs/radio_input_spec.rb +84 -58
- 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 +149 -93
- data/spec/inputs/string_input_spec.rb +23 -23
- data/spec/inputs/text_input_spec.rb +16 -16
- data/spec/inputs/time_picker_input_spec.rb +43 -43
- data/spec/inputs/time_select_input_spec.rb +67 -54
- 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 +17 -17
- data/spec/namespaced_class_finder_spec.rb +2 -2
- data/spec/schema.rb +21 -0
- data/spec/spec_helper.rb +165 -253
- data/spec/support/custom_macros.rb +72 -75
- data/spec/support/shared_examples.rb +0 -1232
- data/spec/support/test_environment.rb +23 -9
- metadata +67 -174
- data/Appraisals +0 -29
- data/CHANGELOG +0 -31
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.0.4.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_4.2.gemfile +0 -7
- data/gemfiles/rails_4.gemfile +0 -7
- data/gemfiles/rails_edge.gemfile +0 -10
- data/lib/formtastic/util.rb +0 -53
- data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
- data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
- data/spec/support/deferred_garbage_collection.rb +0 -21
- data/spec/util_spec.rb +0 -66
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'color input' do
|
4
|
+
RSpec.describe 'color input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -10,85 +10,73 @@ describe 'color input' do
|
|
10
10
|
mock_everything
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
concat(builder.input(:color))
|
19
|
-
end)
|
20
|
-
}.to raise_error "The :color input requires the color_field form helper, which is only available in Rails 4+"
|
21
|
-
end
|
13
|
+
describe "when object is provided" do
|
14
|
+
before do
|
15
|
+
concat(semantic_form_for(@new_post) do |builder|
|
16
|
+
concat(builder.input(:color))
|
17
|
+
end)
|
22
18
|
end
|
23
|
-
else
|
24
|
-
describe "when object is provided" do
|
25
|
-
before do
|
26
|
-
concat(semantic_form_for(@new_post) do |builder|
|
27
|
-
concat(builder.input(:color))
|
28
|
-
end)
|
29
|
-
end
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
it_should_have_input_wrapper_with_class(:color)
|
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_color_input")
|
24
|
+
it_should_have_label_with_text(/Color/)
|
25
|
+
it_should_have_label_for("post_color")
|
26
|
+
it_should_have_input_with_id("post_color")
|
27
|
+
it_should_have_input_with_type(:color)
|
28
|
+
it_should_have_input_with_name("post[color]")
|
40
29
|
|
41
|
-
|
30
|
+
end
|
42
31
|
|
43
|
-
|
32
|
+
describe "when namespace is provided" do
|
44
33
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
34
|
+
before do
|
35
|
+
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
36
|
+
concat(builder.input(:color))
|
37
|
+
end)
|
38
|
+
end
|
50
39
|
|
51
|
-
|
52
|
-
|
40
|
+
it_should_have_input_wrapper_with_id("context2_post_color_input")
|
41
|
+
it_should_have_label_and_input_with_id("context2_post_color")
|
53
42
|
|
54
|
-
|
43
|
+
end
|
55
44
|
|
56
|
-
|
45
|
+
describe "when index is provided" do
|
57
46
|
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
before do
|
48
|
+
@output_buffer = ''
|
49
|
+
mock_everything
|
61
50
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end)
|
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 => :color))
|
66
54
|
end)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should index the id of the wrapper' do
|
70
|
-
output_buffer.should have_tag("li#post_author_attributes_3_name_input")
|
71
|
-
end
|
55
|
+
end)
|
56
|
+
end
|
72
57
|
|
73
|
-
|
74
|
-
|
75
|
-
|
58
|
+
it 'should index the id of the wrapper' do
|
59
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
60
|
+
end
|
76
61
|
|
77
|
-
|
78
|
-
|
79
|
-
|
62
|
+
it 'should index the id of the select tag' do
|
63
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
64
|
+
end
|
80
65
|
|
66
|
+
it 'should index the name of the select tag' do
|
67
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
81
68
|
end
|
82
69
|
|
70
|
+
end
|
71
|
+
|
83
72
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
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 => :color, :required => true))
|
78
|
+
end)
|
79
|
+
expect(output_buffer).to have_tag("input[@required]")
|
92
80
|
end
|
93
81
|
end
|
94
82
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'country input' do
|
4
|
+
RSpec.describe 'country input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -13,11 +13,11 @@ describe 'country input' do
|
|
13
13
|
describe "when country_select is not available as a helper from a plugin" do
|
14
14
|
|
15
15
|
it "should raise an error, sugesting the author installs a plugin" do
|
16
|
-
|
16
|
+
expect {
|
17
17
|
semantic_form_for(@new_post) do |builder|
|
18
18
|
concat(builder.input(:country, :as => :country))
|
19
19
|
end
|
20
|
-
}.
|
20
|
+
}.to raise_error(Formtastic::Inputs::CountryInput::CountrySelectPluginMissing)
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -26,7 +26,7 @@ describe 'country input' do
|
|
26
26
|
|
27
27
|
before do
|
28
28
|
concat(semantic_form_for(@new_post) do |builder|
|
29
|
-
builder.
|
29
|
+
allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
|
30
30
|
concat(builder.input(:country, :as => :country))
|
31
31
|
end)
|
32
32
|
end
|
@@ -39,13 +39,13 @@ describe 'country input' do
|
|
39
39
|
#it_should_apply_error_logic_for_input_type(:country)
|
40
40
|
|
41
41
|
it 'should generate a label for the input' do
|
42
|
-
output_buffer.
|
43
|
-
output_buffer.
|
44
|
-
output_buffer.
|
42
|
+
expect(output_buffer).to have_tag('form li label')
|
43
|
+
expect(output_buffer).to have_tag('form li label[@for="post_country"]')
|
44
|
+
expect(output_buffer).to have_tag('form li label', :text => /Country/)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should generate a select" do
|
48
|
-
output_buffer.
|
48
|
+
expect(output_buffer).to have_tag("form li select")
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -55,8 +55,8 @@ describe 'country input' do
|
|
55
55
|
it "should be passed down to the country_select helper when provided" do
|
56
56
|
priority_countries = ["Foo", "Bah"]
|
57
57
|
semantic_form_for(@new_post) do |builder|
|
58
|
-
builder.
|
59
|
-
builder.
|
58
|
+
allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
|
59
|
+
expect(builder).to receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
|
60
60
|
|
61
61
|
concat(builder.input(:country, :as => :country, :priority_countries => priority_countries))
|
62
62
|
end
|
@@ -64,12 +64,12 @@ describe 'country input' do
|
|
64
64
|
|
65
65
|
it "should default to the @@priority_countries config when absent" do
|
66
66
|
priority_countries = Formtastic::FormBuilder.priority_countries
|
67
|
-
priority_countries.
|
68
|
-
priority_countries.
|
67
|
+
expect(priority_countries).not_to be_empty
|
68
|
+
expect(priority_countries).not_to be_nil
|
69
69
|
|
70
70
|
semantic_form_for(@new_post) do |builder|
|
71
|
-
builder.
|
72
|
-
builder.
|
71
|
+
allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
|
72
|
+
expect(builder).to receive(:country_select).with(:country, priority_countries, {}, {:id => "post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
|
73
73
|
|
74
74
|
concat(builder.input(:country, :as => :country))
|
75
75
|
end
|
@@ -84,8 +84,8 @@ describe 'country input' do
|
|
84
84
|
mock_everything
|
85
85
|
|
86
86
|
concat(semantic_form_for(@new_post, :namespace => 'context2') do |builder|
|
87
|
-
builder.
|
88
|
-
builder.
|
87
|
+
allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
|
88
|
+
expect(builder).to receive(:country_select).with(:country, [], {}, {:id => "context2_post_country", :required => false, :autofocus => false, :readonly => false}).and_return("<select><option>...</option></select>".html_safe)
|
89
89
|
concat(builder.input(:country, :priority_countries => []))
|
90
90
|
end)
|
91
91
|
end
|
@@ -101,13 +101,13 @@ describe 'country input' do
|
|
101
101
|
|
102
102
|
before do
|
103
103
|
concat(semantic_form_for(@new_post) do |builder|
|
104
|
-
builder.
|
104
|
+
allow(builder).to receive(:country_select).and_return("<select><option>...</option></select>".html_safe)
|
105
105
|
concat(builder.input(:country))
|
106
106
|
end)
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should render a country input" do
|
110
|
-
output_buffer.
|
110
|
+
expect(output_buffer).to have_tag "form li.country"
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -121,8 +121,8 @@ describe 'country input' do
|
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should render a country input" do
|
124
|
-
output_buffer.
|
125
|
-
output_buffer.
|
124
|
+
expect(output_buffer).not_to have_tag "form li.country"
|
125
|
+
expect(output_buffer).to have_tag "form li.string", :count => 2
|
126
126
|
end
|
127
127
|
|
128
128
|
end
|
@@ -11,11 +11,7 @@ module TestInputs
|
|
11
11
|
@method = :title
|
12
12
|
@options = {}
|
13
13
|
@proc = Proc.new {}
|
14
|
-
|
15
|
-
@builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
|
16
|
-
else
|
17
|
-
@builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options, @proc)
|
18
|
-
end
|
14
|
+
@builder = Formtastic::FormBuilder.new(@object_name, @object, @template, @options)
|
19
15
|
[@builder, @template, @object, @object_name, @method, @options]
|
20
16
|
end
|
21
17
|
|
@@ -31,7 +27,7 @@ module TestInputs
|
|
31
27
|
|
32
28
|
end
|
33
29
|
|
34
|
-
describe 'AnyCustomInput' do
|
30
|
+
RSpec.describe 'AnyCustomInput' do
|
35
31
|
|
36
32
|
include TestInputs
|
37
33
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'date_picker input' do
|
4
|
+
RSpec.describe 'date_picker input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -40,7 +40,7 @@ describe 'date_picker input' do
|
|
40
40
|
concat(f.input(:publish_at, :as => :date_picker))
|
41
41
|
end
|
42
42
|
)
|
43
|
-
output_buffer.
|
43
|
+
expect(output_buffer).to have_tag "input[size='10']"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "can be set from :input_html options" do
|
@@ -49,7 +49,7 @@ describe 'date_picker input' do
|
|
49
49
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :size => "11" }))
|
50
50
|
end
|
51
51
|
)
|
52
|
-
output_buffer.
|
52
|
+
expect(output_buffer).to have_tag "input[size='11']"
|
53
53
|
end
|
54
54
|
|
55
55
|
it "can be set from options (ignoring input_html)" do
|
@@ -58,7 +58,7 @@ describe 'date_picker input' do
|
|
58
58
|
concat(f.input(:publish_at, :as => :date_picker, :size => '12', :input_html => { :size => "11" }))
|
59
59
|
end
|
60
60
|
)
|
61
|
-
output_buffer.
|
61
|
+
expect(output_buffer).to have_tag "input[size='12']"
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -71,7 +71,7 @@ describe 'date_picker input' do
|
|
71
71
|
concat(f.input(:publish_at, :as => :date_picker))
|
72
72
|
end
|
73
73
|
)
|
74
|
-
output_buffer.
|
74
|
+
expect(output_buffer).to have_tag "input[maxlength='10']"
|
75
75
|
end
|
76
76
|
|
77
77
|
it "can be set from :input_html options" do
|
@@ -80,7 +80,7 @@ describe 'date_picker input' do
|
|
80
80
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :maxlength => "11" }))
|
81
81
|
end
|
82
82
|
)
|
83
|
-
output_buffer.
|
83
|
+
expect(output_buffer).to have_tag "input[maxlength='11']"
|
84
84
|
end
|
85
85
|
|
86
86
|
it "can be set from options (ignoring input_html)" do
|
@@ -89,7 +89,7 @@ describe 'date_picker input' do
|
|
89
89
|
concat(f.input(:publish_at, :as => :date_picker, :maxlength => 12, :input_html => { :maxlength => "11" }))
|
90
90
|
end
|
91
91
|
)
|
92
|
-
output_buffer.
|
92
|
+
expect(output_buffer).to have_tag "input[maxlength='12']"
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -104,7 +104,7 @@ describe 'date_picker input' do
|
|
104
104
|
concat(f.input(:publish_at, :as => :date_picker ))
|
105
105
|
end
|
106
106
|
)
|
107
|
-
output_buffer.
|
107
|
+
expect(output_buffer).not_to have_tag "li input[value]"
|
108
108
|
end
|
109
109
|
|
110
110
|
it "can be set from :input_html options" do
|
@@ -113,7 +113,7 @@ describe 'date_picker input' do
|
|
113
113
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
|
114
114
|
end
|
115
115
|
)
|
116
|
-
output_buffer.
|
116
|
+
expect(output_buffer).to have_tag "input[value='1111-11-11']"
|
117
117
|
end
|
118
118
|
|
119
119
|
end
|
@@ -122,7 +122,7 @@ describe 'date_picker input' do
|
|
122
122
|
|
123
123
|
before do
|
124
124
|
@date = Date.new(2000, 11, 11)
|
125
|
-
@new_post.
|
125
|
+
allow(@new_post).to receive(:publish_at).and_return(@date)
|
126
126
|
end
|
127
127
|
|
128
128
|
it "renders the date as YYYY-MM-DD" do
|
@@ -131,7 +131,7 @@ describe 'date_picker input' do
|
|
131
131
|
concat(f.input(:publish_at, :as => :date_picker ))
|
132
132
|
end
|
133
133
|
)
|
134
|
-
output_buffer.
|
134
|
+
expect(output_buffer).to have_tag "input[value='#{@date.to_s}']"
|
135
135
|
end
|
136
136
|
|
137
137
|
it "can be set from :input_html options" do
|
@@ -140,7 +140,7 @@ describe 'date_picker input' do
|
|
140
140
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
|
141
141
|
end
|
142
142
|
)
|
143
|
-
output_buffer.
|
143
|
+
expect(output_buffer).to have_tag "input[value='1111-11-11']"
|
144
144
|
end
|
145
145
|
|
146
146
|
end
|
@@ -149,7 +149,7 @@ describe 'date_picker input' do
|
|
149
149
|
|
150
150
|
before do
|
151
151
|
@time = Time.utc(2000,11,11,11,11,11)
|
152
|
-
@new_post.
|
152
|
+
allow(@new_post).to receive(:publish_at).and_return(@time)
|
153
153
|
end
|
154
154
|
|
155
155
|
it "renders the time as a YYYY-MM-DD" do
|
@@ -158,7 +158,7 @@ describe 'date_picker input' do
|
|
158
158
|
concat(f.input(:publish_at, :as => :date_picker ))
|
159
159
|
end
|
160
160
|
)
|
161
|
-
output_buffer.
|
161
|
+
expect(output_buffer).to have_tag "input[value='2000-11-11']"
|
162
162
|
end
|
163
163
|
|
164
164
|
it "can be set from :input_html options" do
|
@@ -167,7 +167,7 @@ describe 'date_picker input' do
|
|
167
167
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
|
168
168
|
end
|
169
169
|
)
|
170
|
-
output_buffer.
|
170
|
+
expect(output_buffer).to have_tag "input[value='1111-11-11']"
|
171
171
|
end
|
172
172
|
|
173
173
|
end
|
@@ -175,7 +175,7 @@ describe 'date_picker input' do
|
|
175
175
|
context "when method returns an empty String" do
|
176
176
|
|
177
177
|
before do
|
178
|
-
@new_post.
|
178
|
+
allow(@new_post).to receive(:publish_at).and_return("")
|
179
179
|
end
|
180
180
|
|
181
181
|
it "will be empty" do
|
@@ -184,7 +184,7 @@ describe 'date_picker input' do
|
|
184
184
|
concat(f.input(:publish_at, :as => :date_picker ))
|
185
185
|
end
|
186
186
|
)
|
187
|
-
output_buffer.
|
187
|
+
expect(output_buffer).to have_tag "input[value='']"
|
188
188
|
end
|
189
189
|
|
190
190
|
it "can be set from :input_html options" do
|
@@ -193,7 +193,7 @@ describe 'date_picker input' do
|
|
193
193
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
|
194
194
|
end
|
195
195
|
)
|
196
|
-
output_buffer.
|
196
|
+
expect(output_buffer).to have_tag "input[value='1111-11-11']"
|
197
197
|
end
|
198
198
|
|
199
199
|
end
|
@@ -201,7 +201,7 @@ describe 'date_picker input' do
|
|
201
201
|
context "when method returns a String" do
|
202
202
|
|
203
203
|
before do
|
204
|
-
@new_post.
|
204
|
+
allow(@new_post).to receive(:publish_at).and_return("yeah")
|
205
205
|
end
|
206
206
|
|
207
207
|
it "will be the string" do
|
@@ -210,7 +210,7 @@ describe 'date_picker input' do
|
|
210
210
|
concat(f.input(:publish_at, :as => :date_picker ))
|
211
211
|
end
|
212
212
|
)
|
213
|
-
output_buffer.
|
213
|
+
expect(output_buffer).to have_tag "input[value='yeah']"
|
214
214
|
end
|
215
215
|
|
216
216
|
it "can be set from :input_html options" do
|
@@ -219,7 +219,7 @@ describe 'date_picker input' do
|
|
219
219
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :value => "1111-11-11" }))
|
220
220
|
end
|
221
221
|
)
|
222
|
-
output_buffer.
|
222
|
+
expect(output_buffer).to have_tag "input[value='1111-11-11']"
|
223
223
|
end
|
224
224
|
|
225
225
|
end
|
@@ -234,7 +234,7 @@ describe 'date_picker input' do
|
|
234
234
|
concat(f.input(:publish_at, :as => :date_picker))
|
235
235
|
end
|
236
236
|
)
|
237
|
-
output_buffer.
|
237
|
+
expect(output_buffer).not_to have_tag "input[min]"
|
238
238
|
end
|
239
239
|
|
240
240
|
it "can be set from :input_html options" do
|
@@ -243,7 +243,7 @@ describe 'date_picker input' do
|
|
243
243
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :min => "1970-01-01" }))
|
244
244
|
end
|
245
245
|
)
|
246
|
-
output_buffer.
|
246
|
+
expect(output_buffer).to have_tag "input[min='1970-01-01']"
|
247
247
|
end
|
248
248
|
|
249
249
|
end
|
@@ -256,7 +256,7 @@ describe 'date_picker input' do
|
|
256
256
|
concat(f.input(:publish_at, :as => :date_picker))
|
257
257
|
end
|
258
258
|
)
|
259
|
-
output_buffer.
|
259
|
+
expect(output_buffer).not_to have_tag "input[max]"
|
260
260
|
end
|
261
261
|
|
262
262
|
it "can be set from :input_html options" do
|
@@ -265,7 +265,7 @@ describe 'date_picker input' do
|
|
265
265
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :max => "1970-01-01" }))
|
266
266
|
end
|
267
267
|
)
|
268
|
-
output_buffer.
|
268
|
+
expect(output_buffer).to have_tag "input[max='1970-01-01']"
|
269
269
|
end
|
270
270
|
|
271
271
|
end
|
@@ -278,7 +278,7 @@ describe 'date_picker input' do
|
|
278
278
|
concat(f.input(:publish_at, :as => :date_picker))
|
279
279
|
end
|
280
280
|
)
|
281
|
-
output_buffer.
|
281
|
+
expect(output_buffer).to have_tag "input[step='1']"
|
282
282
|
end
|
283
283
|
|
284
284
|
it "can be set from :input_html options" do
|
@@ -287,7 +287,7 @@ describe 'date_picker input' do
|
|
287
287
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :step => "5" }))
|
288
288
|
end
|
289
289
|
)
|
290
|
-
output_buffer.
|
290
|
+
expect(output_buffer).to have_tag "input[step='5']"
|
291
291
|
end
|
292
292
|
|
293
293
|
describe "macros" do
|
@@ -303,49 +303,49 @@ describe 'date_picker input' do
|
|
303
303
|
context ":day" do
|
304
304
|
let(:step) { :day }
|
305
305
|
it "uses 1" do
|
306
|
-
output_buffer.
|
306
|
+
expect(output_buffer).to have_tag "input[step='1']"
|
307
307
|
end
|
308
308
|
end
|
309
309
|
|
310
310
|
context ":seven_days" do
|
311
311
|
let(:step) { :seven_days }
|
312
312
|
it "uses 7" do
|
313
|
-
output_buffer.
|
313
|
+
expect(output_buffer).to have_tag "input[step='7']"
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
317
317
|
context ":week" do
|
318
318
|
let(:step) { :week }
|
319
319
|
it "uses 7" do
|
320
|
-
output_buffer.
|
320
|
+
expect(output_buffer).to have_tag "input[step='7']"
|
321
321
|
end
|
322
322
|
end
|
323
323
|
|
324
324
|
context ":fortnight" do
|
325
325
|
let(:step) { :fortnight }
|
326
326
|
it "uses 14" do
|
327
|
-
output_buffer.
|
327
|
+
expect(output_buffer).to have_tag "input[step='14']"
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
331
331
|
context ":two_weeks" do
|
332
332
|
let(:step) { :two_weeks }
|
333
333
|
it "uses 14" do
|
334
|
-
output_buffer.
|
334
|
+
expect(output_buffer).to have_tag "input[step='14']"
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
338
|
context ":four_weeks" do
|
339
339
|
let(:step) { :four_weeks }
|
340
340
|
it "uses 28" do
|
341
|
-
output_buffer.
|
341
|
+
expect(output_buffer).to have_tag "input[step='28']"
|
342
342
|
end
|
343
343
|
end
|
344
344
|
|
345
345
|
context ":thirty_days" do
|
346
346
|
let(:step) { :thirty_days }
|
347
347
|
it "uses 30" do
|
348
|
-
output_buffer.
|
348
|
+
expect(output_buffer).to have_tag "input[step='30']"
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
@@ -361,7 +361,7 @@ describe 'date_picker input' do
|
|
361
361
|
concat(f.input(:publish_at, :as => :date_picker))
|
362
362
|
end
|
363
363
|
)
|
364
|
-
output_buffer.
|
364
|
+
expect(output_buffer).not_to have_tag "input[placeholder]"
|
365
365
|
end
|
366
366
|
|
367
367
|
it "can be set from :input_html options" do
|
@@ -370,7 +370,7 @@ describe 'date_picker input' do
|
|
370
370
|
concat(f.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "1970-01-01" }))
|
371
371
|
end
|
372
372
|
)
|
373
|
-
output_buffer.
|
373
|
+
expect(output_buffer).to have_tag "input[placeholder='1970-01-01']"
|
374
374
|
end
|
375
375
|
|
376
376
|
context "with i18n set" do
|
@@ -383,7 +383,7 @@ describe 'date_picker input' do
|
|
383
383
|
concat(semantic_form_for(@new_post) do |builder|
|
384
384
|
concat(builder.input(:publish_at, :as => :date_picker))
|
385
385
|
end)
|
386
|
-
output_buffer.
|
386
|
+
expect(output_buffer).to have_tag('input[@placeholder="YYYY-MM-DD"]')
|
387
387
|
end
|
388
388
|
end
|
389
389
|
|
@@ -392,7 +392,7 @@ describe 'date_picker input' do
|
|
392
392
|
concat(semantic_form_for(@new_post) do |builder|
|
393
393
|
concat(builder.input(:publish_at, :as => :date_picker, :input_html => { :placeholder => "Something" }))
|
394
394
|
end)
|
395
|
-
output_buffer.
|
395
|
+
expect(output_buffer).to have_tag('input[@placeholder="Something"]')
|
396
396
|
end
|
397
397
|
end
|
398
398
|
end
|
@@ -423,15 +423,15 @@ describe 'date_picker input' do
|
|
423
423
|
end
|
424
424
|
|
425
425
|
it 'should index the id of the wrapper' do
|
426
|
-
output_buffer.
|
426
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
|
427
427
|
end
|
428
428
|
|
429
429
|
it 'should index the id of the select tag' do
|
430
|
-
output_buffer.
|
430
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
|
431
431
|
end
|
432
432
|
|
433
433
|
it 'should index the name of the select tag' do
|
434
|
-
output_buffer.
|
434
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
|
435
435
|
end
|
436
436
|
end
|
437
437
|
|
@@ -441,7 +441,7 @@ describe 'date_picker input' do
|
|
441
441
|
concat(semantic_form_for(@new_post) do |builder|
|
442
442
|
concat(builder.input(:publish_at, :as => :date_picker, :required => true))
|
443
443
|
end)
|
444
|
-
output_buffer.
|
444
|
+
expect(output_buffer).to have_tag("input[@required]")
|
445
445
|
end
|
446
446
|
end
|
447
447
|
end
|