formtastic 3.1.5 → 4.0.0.rc1
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 +5 -5
- data/.gitattributes +1 -0
- data/.gitignore +3 -2
- data/.travis.yml +28 -40
- data/CHANGELOG.md +49 -0
- data/DEPRECATIONS +1 -1
- data/Gemfile.lock +104 -0
- data/README.md +628 -629
- data/Rakefile +20 -1
- data/app/assets/stylesheets/formtastic.css +1 -1
- data/bin/appraisal +8 -0
- data/formtastic.gemspec +8 -14
- 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 +5 -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 +8 -24
- data/lib/formtastic/helpers/action_helper.rb +1 -48
- data/lib/formtastic/helpers/errors_helper.rb +2 -2
- data/lib/formtastic/helpers/fieldset_wrapper.rb +7 -3
- data/lib/formtastic/helpers/input_helper.rb +18 -76
- data/lib/formtastic/helpers/inputs_helper.rb +12 -3
- data/lib/formtastic/i18n.rb +1 -1
- data/lib/formtastic/inputs.rb +32 -29
- data/lib/formtastic/inputs/base/collections.rb +1 -5
- data/lib/formtastic/inputs/base/errors.rb +4 -4
- data/lib/formtastic/inputs/base/hints.rb +1 -1
- data/lib/formtastic/inputs/base/timeish.rb +5 -1
- data/lib/formtastic/inputs/base/validations.rb +19 -9
- data/lib/formtastic/inputs/check_boxes_input.rb +3 -3
- data/lib/formtastic/inputs/color_input.rb +0 -1
- data/lib/formtastic/inputs/select_input.rb +1 -1
- data/lib/formtastic/localizer.rb +5 -7
- data/lib/formtastic/version.rb +1 -1
- data/lib/generators/templates/formtastic.rb +4 -6
- 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/generators/formtastic/form/form_generator_spec.rb +25 -25
- data/spec/generators/formtastic/input/input_generator_spec.rb +31 -31
- 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 +33 -33
- 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 +6 -6
- data/spec/inputs/base/validations_spec.rb +157 -19
- data/spec/inputs/boolean_input_spec.rb +55 -55
- data/spec/inputs/check_boxes_input_spec.rb +96 -95
- 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 +63 -65
- data/spec/inputs/range_input_spec.rb +66 -66
- data/spec/inputs/readonly_spec.rb +4 -4
- data/spec/inputs/search_input_spec.rb +5 -5
- data/spec/inputs/select_input_spec.rb +92 -96
- 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 +19 -19
- 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 +163 -223
- data/spec/support/custom_macros.rb +72 -75
- data/spec/support/shared_examples.rb +0 -1301
- data/spec/support/test_environment.rb +23 -9
- metadata +33 -123
- data/Appraisals +0 -43
- data/CHANGELOG +0 -54
- data/gemfiles/rails_3.2.gemfile +0 -9
- data/gemfiles/rails_4.0.4.gemfile +0 -8
- data/gemfiles/rails_4.1.gemfile +0 -8
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_4.gemfile +0 -8
- data/gemfiles/rails_5.0.gemfile +0 -8
- data/gemfiles/rails_edge.gemfile +0 -15
- data/lib/formtastic/util.rb +0 -57
- data/spec/helpers/namespaced_action_helper_spec.rb +0 -43
- data/spec/helpers/namespaced_input_helper_spec.rb +0 -36
- 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 'string input' do
|
4
|
+
RSpec.describe 'string input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -37,23 +37,23 @@ describe 'string input' do
|
|
37
37
|
concat(semantic_form_for(@new_post) do |builder|
|
38
38
|
concat(builder.input(method))
|
39
39
|
end)
|
40
|
-
output_buffer.
|
40
|
+
expect(output_buffer).to have_tag("form li input[@maxlength='#{maxlength}']")
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'and its a ActiveModel' do
|
44
44
|
let(:default_maxlength) { 50 }
|
45
45
|
|
46
46
|
before do
|
47
|
-
@new_post.
|
47
|
+
allow(@new_post).to receive(:class).and_return(::PostModel)
|
48
48
|
end
|
49
49
|
|
50
50
|
after do
|
51
|
-
@new_post.
|
51
|
+
allow(@new_post).to receive(:class).and_return(::Post)
|
52
52
|
end
|
53
53
|
|
54
54
|
describe 'and validates_length_of was called for the method' do
|
55
55
|
def should_have_maxlength(maxlength, options)
|
56
|
-
@new_post.class.
|
56
|
+
expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
|
57
57
|
active_model_length_validator([:title], options[:options])
|
58
58
|
])
|
59
59
|
|
@@ -61,7 +61,7 @@ describe 'string input' do
|
|
61
61
|
concat(builder.input(:title))
|
62
62
|
end)
|
63
63
|
|
64
|
-
output_buffer.
|
64
|
+
expect(output_buffer).to have_tag("form li input##{@new_post.class.name.underscore}_title[@maxlength='#{maxlength}']")
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'should have maxlength if the optional :if or :unless options are not supplied' do
|
@@ -81,12 +81,12 @@ describe 'string input' do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should have default maxlength if the optional :if with a method name evaluates to false' do
|
84
|
-
@new_post.
|
84
|
+
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(false)
|
85
85
|
should_have_maxlength(default_maxlength, :options => { :maximum => 42, :if => :specify_maxlength })
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should have maxlength if the optional :if with a method name evaluates to true' do
|
89
|
-
@new_post.
|
89
|
+
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(true)
|
90
90
|
should_have_maxlength(42, :options => { :maximum => 42, :if => :specify_maxlength })
|
91
91
|
end
|
92
92
|
|
@@ -99,12 +99,12 @@ describe 'string input' do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should have default maxlength if the optional :unless with a method name evaluates to true' do
|
102
|
-
@new_post.
|
102
|
+
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(true)
|
103
103
|
should_have_maxlength(default_maxlength, :options => { :maximum => 42, :unless => :specify_maxlength })
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should have maxlength if the optional :unless with a method name evaluates to false' do
|
107
|
-
@new_post.
|
107
|
+
expect(@new_post).to receive(:specify_maxlength).at_least(1).and_return(false)
|
108
108
|
should_have_maxlength(42, :options => { :maximum => 42, :unless => :specify_maxlength })
|
109
109
|
end
|
110
110
|
end
|
@@ -112,8 +112,8 @@ describe 'string input' do
|
|
112
112
|
describe 'any conditional validation' do
|
113
113
|
describe 'proc that calls an instance method' do
|
114
114
|
it 'calls the method on the object' do
|
115
|
-
@new_post.
|
116
|
-
@new_post.class.
|
115
|
+
expect(@new_post).to receive(:something?)
|
116
|
+
expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
|
117
117
|
active_model_presence_validator([:title], { :unless => -> { something? } })
|
118
118
|
])
|
119
119
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -124,8 +124,8 @@ describe 'string input' do
|
|
124
124
|
|
125
125
|
describe 'proc with arity that calls an instance method' do
|
126
126
|
it 'calls the method on the object' do
|
127
|
-
@new_post.
|
128
|
-
@new_post.class.
|
127
|
+
expect(@new_post).to receive(:something?)
|
128
|
+
expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
|
129
129
|
active_model_presence_validator([:title], { :unless => ->(user) { user.something? } })
|
130
130
|
])
|
131
131
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -136,8 +136,8 @@ describe 'string input' do
|
|
136
136
|
|
137
137
|
describe 'symbol method name' do
|
138
138
|
it 'calls the method on the object if the method exists' do
|
139
|
-
@new_post.
|
140
|
-
@new_post.class.
|
139
|
+
expect(@new_post).to receive(:something?)
|
140
|
+
expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
|
141
141
|
active_model_presence_validator([:title], { :unless => :something? })
|
142
142
|
])
|
143
143
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -149,7 +149,7 @@ describe 'string input' do
|
|
149
149
|
describe 'any other conditional' do
|
150
150
|
it 'does not raise an error' do
|
151
151
|
@conditional = double()
|
152
|
-
@new_post.class.
|
152
|
+
expect(@new_post.class).to receive(:validators_on).with(:title).at_least(1).and_return([
|
153
153
|
active_model_presence_validator([:title], { :unless => @conditional })
|
154
154
|
])
|
155
155
|
concat(semantic_form_for(@new_post) do |builder|
|
@@ -190,15 +190,15 @@ describe 'string input' do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it 'should index the id of the wrapper' do
|
193
|
-
output_buffer.
|
193
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
194
194
|
end
|
195
195
|
|
196
196
|
it 'should index the id of the select tag' do
|
197
|
-
output_buffer.
|
197
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'should index the name of the select tag' do
|
201
|
-
output_buffer.
|
201
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
202
202
|
end
|
203
203
|
|
204
204
|
end
|
@@ -226,7 +226,7 @@ describe 'string input' do
|
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should have no size attribute" do
|
229
|
-
output_buffer.
|
229
|
+
expect(output_buffer).not_to have_tag("input[@size]")
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
@@ -238,7 +238,7 @@ describe 'string input' do
|
|
238
238
|
concat(semantic_form_for(@new_post) do |builder|
|
239
239
|
concat(builder.input(:title, :as => :string, :required => true))
|
240
240
|
end)
|
241
|
-
output_buffer.
|
241
|
+
expect(output_buffer).to have_tag("input[@required]")
|
242
242
|
end
|
243
243
|
end
|
244
244
|
end
|
@@ -249,7 +249,7 @@ describe 'string input' do
|
|
249
249
|
concat(semantic_form_for(@new_post) do |builder|
|
250
250
|
concat(builder.input(:title, :as => :string, :required => true))
|
251
251
|
end)
|
252
|
-
output_buffer.
|
252
|
+
expect(output_buffer).not_to have_tag("input[@required]")
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'text input' do
|
4
|
+
RSpec.describe 'text input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -28,7 +28,7 @@ describe 'text input' do
|
|
28
28
|
concat(semantic_form_for(@new_post) do |builder|
|
29
29
|
concat(builder.input(:title, :as => :text, :input_html => { :class => 'myclass' }))
|
30
30
|
end)
|
31
|
-
output_buffer.
|
31
|
+
expect(output_buffer).to have_tag("form li textarea.myclass")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should have a cols attribute when :cols is a number in :input_html" do
|
@@ -36,7 +36,7 @@ describe 'text input' do
|
|
36
36
|
concat(semantic_form_for(@new_post) do |builder|
|
37
37
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => 42 }))
|
38
38
|
end)
|
39
|
-
output_buffer.
|
39
|
+
expect(output_buffer).to have_tag("form li textarea[@cols='42']")
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should not have a cols attribute when :cols is nil in :input_html" do
|
@@ -44,7 +44,7 @@ describe 'text input' do
|
|
44
44
|
concat(semantic_form_for(@new_post) do |builder|
|
45
45
|
concat(builder.input(:title, :as => :text, :input_html => { :cols => nil }))
|
46
46
|
end)
|
47
|
-
output_buffer.
|
47
|
+
expect(output_buffer).not_to have_tag("form li textarea[@cols]")
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should have a rows attribute when :rows is a number in :input_html" do
|
@@ -52,7 +52,7 @@ describe 'text input' do
|
|
52
52
|
concat(semantic_form_for(@new_post) do |builder|
|
53
53
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => 42 }))
|
54
54
|
end)
|
55
|
-
output_buffer.
|
55
|
+
expect(output_buffer).to have_tag("form li textarea[@rows='42']")
|
56
56
|
|
57
57
|
end
|
58
58
|
|
@@ -61,7 +61,7 @@ describe 'text input' do
|
|
61
61
|
concat(semantic_form_for(@new_post) do |builder|
|
62
62
|
concat(builder.input(:title, :as => :text, :input_html => { :rows => nil }))
|
63
63
|
end)
|
64
|
-
output_buffer.
|
64
|
+
expect(output_buffer).not_to have_tag("form li textarea[@rows]")
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "when namespace is provided" do
|
@@ -95,15 +95,15 @@ describe 'text input' do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'should index the id of the wrapper' do
|
98
|
-
output_buffer.
|
98
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should index the id of the select tag' do
|
102
|
-
output_buffer.
|
102
|
+
expect(output_buffer).to have_tag("textarea#post_author_attributes_3_name")
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'should index the name of the select tag' do
|
106
|
-
output_buffer.
|
106
|
+
expect(output_buffer).to have_tag("textarea[@name='post[author_attributes][3][name]']")
|
107
107
|
end
|
108
108
|
|
109
109
|
end
|
@@ -114,13 +114,13 @@ describe 'text input' do
|
|
114
114
|
concat(semantic_form_for(@new_post) do |builder|
|
115
115
|
concat(builder.input(:title, :as => :text, :required => true))
|
116
116
|
end)
|
117
|
-
output_buffer.
|
117
|
+
expect(output_buffer).to have_tag("textarea[@required]")
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
context "when :autofocus is provided in :input_html" do
|
123
|
-
before(:
|
123
|
+
before(:example) do
|
124
124
|
concat(semantic_form_for(@new_post) do |builder|
|
125
125
|
concat(builder.input(:title, :input_html => {:autofocus => true}))
|
126
126
|
end)
|
@@ -129,7 +129,7 @@ describe 'text input' do
|
|
129
129
|
it_should_have_input_wrapper_with_class("autofocus")
|
130
130
|
|
131
131
|
it "should add the autofocus attribute to the input's html options" do
|
132
|
-
output_buffer.
|
132
|
+
expect(output_buffer).to have_tag("input[@autofocus]")
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -143,7 +143,7 @@ describe 'text input' do
|
|
143
143
|
concat(semantic_form_for(@new_post) do |builder|
|
144
144
|
concat(builder.input(:title, :as => :text))
|
145
145
|
end)
|
146
|
-
output_buffer.
|
146
|
+
expect(output_buffer).to have_tag("form li textarea[@rows='12']")
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -152,7 +152,7 @@ describe 'text input' do
|
|
152
152
|
concat(semantic_form_for(@new_post) do |builder|
|
153
153
|
concat(builder.input(:title, :as => :text))
|
154
154
|
end)
|
155
|
-
output_buffer.
|
155
|
+
expect(output_buffer).not_to have_tag("form li textarea[@rows]")
|
156
156
|
end
|
157
157
|
|
158
158
|
end
|
@@ -168,7 +168,7 @@ describe 'text input' do
|
|
168
168
|
concat(semantic_form_for(@new_post) do |builder|
|
169
169
|
concat(builder.input(:title, :as => :text))
|
170
170
|
end)
|
171
|
-
output_buffer.
|
171
|
+
expect(output_buffer).to have_tag("form li textarea[@cols='10']")
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -177,7 +177,7 @@ describe 'text input' do
|
|
177
177
|
concat(semantic_form_for(@new_post) do |builder|
|
178
178
|
concat(builder.input(:title, :as => :text))
|
179
179
|
end)
|
180
|
-
output_buffer.
|
180
|
+
expect(output_buffer).not_to have_tag("form li textarea[@cols]")
|
181
181
|
end
|
182
182
|
|
183
183
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'time_picker input' do
|
4
|
+
RSpec.describe 'time_picker input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -40,7 +40,7 @@ describe 'time_picker input' do
|
|
40
40
|
concat(f.input(:publish_at, :as => :time_picker))
|
41
41
|
end
|
42
42
|
)
|
43
|
-
output_buffer.
|
43
|
+
expect(output_buffer).to have_tag "input[size='5']"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "can be set from :input_html options" do
|
@@ -49,7 +49,7 @@ describe 'time_picker input' do
|
|
49
49
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
58
58
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
71
71
|
concat(f.input(:publish_at, :as => :time_picker))
|
72
72
|
end
|
73
73
|
)
|
74
|
-
output_buffer.
|
74
|
+
expect(output_buffer).to have_tag "input[maxlength='5']"
|
75
75
|
end
|
76
76
|
|
77
77
|
it "can be set from :input_html options" do
|
@@ -80,7 +80,7 @@ describe 'time_picker input' do
|
|
80
80
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
89
89
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
104
104
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
113
113
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:00" }))
|
114
114
|
end
|
115
115
|
)
|
116
|
-
output_buffer.
|
116
|
+
expect(output_buffer).to have_tag "input[value='12:00']"
|
117
117
|
end
|
118
118
|
|
119
119
|
end
|
@@ -122,7 +122,7 @@ describe 'time_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 00:00" do
|
@@ -131,7 +131,7 @@ describe 'time_picker input' do
|
|
131
131
|
concat(f.input(:publish_at, :as => :time_picker ))
|
132
132
|
end
|
133
133
|
)
|
134
|
-
output_buffer.
|
134
|
+
expect(output_buffer).to have_tag "input[value='00:00']"
|
135
135
|
end
|
136
136
|
|
137
137
|
it "can be set from :input_html options" do
|
@@ -140,7 +140,7 @@ describe 'time_picker input' do
|
|
140
140
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "23:59" }))
|
141
141
|
end
|
142
142
|
)
|
143
|
-
output_buffer.
|
143
|
+
expect(output_buffer).to have_tag "input[value='23:59']"
|
144
144
|
end
|
145
145
|
|
146
146
|
end
|
@@ -149,7 +149,7 @@ describe 'time_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 HH:MM" do
|
@@ -158,7 +158,7 @@ describe 'time_picker input' do
|
|
158
158
|
concat(f.input(:publish_at, :as => :time_picker ))
|
159
159
|
end
|
160
160
|
)
|
161
|
-
output_buffer.
|
161
|
+
expect(output_buffer).to have_tag "input[value='11:11']"
|
162
162
|
end
|
163
163
|
|
164
164
|
it "can be set from :input_html options" do
|
@@ -167,7 +167,7 @@ describe 'time_picker input' do
|
|
167
167
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12" }))
|
168
168
|
end
|
169
169
|
)
|
170
|
-
output_buffer.
|
170
|
+
expect(output_buffer).to have_tag "input[value='12:12']"
|
171
171
|
end
|
172
172
|
|
173
173
|
end
|
@@ -175,7 +175,7 @@ describe 'time_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 'time_picker input' do
|
|
184
184
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
193
193
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12:12" }))
|
194
194
|
end
|
195
195
|
)
|
196
|
-
output_buffer.
|
196
|
+
expect(output_buffer).to have_tag "input[value='12:12:12']"
|
197
197
|
end
|
198
198
|
|
199
199
|
end
|
@@ -201,7 +201,7 @@ describe 'time_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 'time_picker input' do
|
|
210
210
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
219
219
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :value => "12:12:12" }))
|
220
220
|
end
|
221
221
|
)
|
222
|
-
output_buffer.
|
222
|
+
expect(output_buffer).to have_tag "input[value='12:12:12']"
|
223
223
|
end
|
224
224
|
|
225
225
|
end
|
@@ -234,7 +234,7 @@ describe 'time_picker input' do
|
|
234
234
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
243
243
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :min => "13:00" }))
|
244
244
|
end
|
245
245
|
)
|
246
|
-
output_buffer.
|
246
|
+
expect(output_buffer).to have_tag "input[min='13:00']"
|
247
247
|
end
|
248
248
|
|
249
249
|
end
|
@@ -256,7 +256,7 @@ describe 'time_picker input' do
|
|
256
256
|
concat(f.input(:publish_at, :as => :time_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 'time_picker input' do
|
|
265
265
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :max => "13:00" }))
|
266
266
|
end
|
267
267
|
)
|
268
|
-
output_buffer.
|
268
|
+
expect(output_buffer).to have_tag "input[max='13:00']"
|
269
269
|
end
|
270
270
|
|
271
271
|
end
|
@@ -278,7 +278,7 @@ describe 'time_picker input' do
|
|
278
278
|
concat(f.input(:publish_at, :as => :time_picker))
|
279
279
|
end
|
280
280
|
)
|
281
|
-
output_buffer.
|
281
|
+
expect(output_buffer).to have_tag "input[step='60']"
|
282
282
|
end
|
283
283
|
|
284
284
|
it "can be set from :input_html options" do
|
@@ -287,7 +287,7 @@ describe 'time_picker input' do
|
|
287
287
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :step => "3600" }))
|
288
288
|
end
|
289
289
|
)
|
290
|
-
output_buffer.
|
290
|
+
expect(output_buffer).to have_tag "input[step='3600']"
|
291
291
|
end
|
292
292
|
|
293
293
|
describe "macros" do
|
@@ -302,56 +302,56 @@ describe 'time_picker input' do
|
|
302
302
|
context ":second" do
|
303
303
|
let(:step) { :second }
|
304
304
|
it "uses 1" do
|
305
|
-
output_buffer.
|
305
|
+
expect(output_buffer).to have_tag "input[step='1']"
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
309
309
|
context ":minute" do
|
310
310
|
let(:step) { :minute }
|
311
311
|
it "uses 60" do
|
312
|
-
output_buffer.
|
312
|
+
expect(output_buffer).to have_tag "input[step='60']"
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
316
316
|
context ":fifteen_minutes" do
|
317
317
|
let(:step) { :fifteen_minutes }
|
318
318
|
it "uses 900" do
|
319
|
-
output_buffer.
|
319
|
+
expect(output_buffer).to have_tag "input[step='900']"
|
320
320
|
end
|
321
321
|
end
|
322
322
|
|
323
323
|
context ":quarter_hour" do
|
324
324
|
let(:step) { :quarter_hour }
|
325
325
|
it "uses 900" do
|
326
|
-
output_buffer.
|
326
|
+
expect(output_buffer).to have_tag "input[step='900']"
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
330
330
|
context ":thirty_minutes" do
|
331
331
|
let(:step) { :thirty_minutes }
|
332
332
|
it "uses 1800" do
|
333
|
-
output_buffer.
|
333
|
+
expect(output_buffer).to have_tag "input[step='1800']"
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
337
337
|
context ":half_hour" do
|
338
338
|
let(:step) { :half_hour }
|
339
339
|
it "uses 1800" do
|
340
|
-
output_buffer.
|
340
|
+
expect(output_buffer).to have_tag "input[step='1800']"
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
344
|
context ":hour" do
|
345
345
|
let(:step) { :hour }
|
346
346
|
it "uses 3600" do
|
347
|
-
output_buffer.
|
347
|
+
expect(output_buffer).to have_tag "input[step='3600']"
|
348
348
|
end
|
349
349
|
end
|
350
350
|
|
351
351
|
context ":sixty_minutes" do
|
352
352
|
let(:step) { :sixty_minutes }
|
353
353
|
it "uses 3600" do
|
354
|
-
output_buffer.
|
354
|
+
expect(output_buffer).to have_tag "input[step='3600']"
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
@@ -367,7 +367,7 @@ describe 'time_picker input' do
|
|
367
367
|
concat(f.input(:publish_at, :as => :time_picker))
|
368
368
|
end
|
369
369
|
)
|
370
|
-
output_buffer.
|
370
|
+
expect(output_buffer).not_to have_tag "input[placeholder]"
|
371
371
|
end
|
372
372
|
|
373
373
|
it "can be set from :input_html options" do
|
@@ -376,7 +376,7 @@ describe 'time_picker input' do
|
|
376
376
|
concat(f.input(:publish_at, :as => :time_picker, :input_html => { :placeholder => "HH:MM" }))
|
377
377
|
end
|
378
378
|
)
|
379
|
-
output_buffer.
|
379
|
+
expect(output_buffer).to have_tag "input[placeholder='HH:MM']"
|
380
380
|
end
|
381
381
|
|
382
382
|
context "with i18n set" do
|
@@ -389,7 +389,7 @@ describe 'time_picker input' do
|
|
389
389
|
concat(semantic_form_for(@new_post) do |builder|
|
390
390
|
concat(builder.input(:publish_at, :as => :time_picker))
|
391
391
|
end)
|
392
|
-
output_buffer.
|
392
|
+
expect(output_buffer).to have_tag('input[@placeholder="HH:MM"]')
|
393
393
|
end
|
394
394
|
end
|
395
395
|
|
@@ -398,7 +398,7 @@ describe 'time_picker input' do
|
|
398
398
|
concat(semantic_form_for(@new_post) do |builder|
|
399
399
|
concat(builder.input(:publish_at, :as => :time_picker, :input_html => { :placeholder => "Something" }))
|
400
400
|
end)
|
401
|
-
output_buffer.
|
401
|
+
expect(output_buffer).to have_tag('input[@placeholder="Something"]')
|
402
402
|
end
|
403
403
|
end
|
404
404
|
end
|
@@ -429,15 +429,15 @@ describe 'time_picker input' do
|
|
429
429
|
end
|
430
430
|
|
431
431
|
it 'should index the id of the wrapper' do
|
432
|
-
output_buffer.
|
432
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_created_at_input")
|
433
433
|
end
|
434
434
|
|
435
435
|
it 'should index the id of the select tag' do
|
436
|
-
output_buffer.
|
436
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_created_at")
|
437
437
|
end
|
438
438
|
|
439
439
|
it 'should index the name of the select tag' do
|
440
|
-
output_buffer.
|
440
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][created_at]']")
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
@@ -447,7 +447,7 @@ describe 'time_picker input' do
|
|
447
447
|
concat(semantic_form_for(@new_post) do |builder|
|
448
448
|
concat(builder.input(:publish_at, :as => :time_picker, :required => true))
|
449
449
|
end)
|
450
|
-
output_buffer.
|
450
|
+
expect(output_buffer).to have_tag("input[@required]")
|
451
451
|
end
|
452
452
|
end
|
453
453
|
end
|