formtastic 3.1.5 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- 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 'ButtonAction', 'when submitting' do
|
4
|
+
RSpec.describe 'ButtonAction', 'when submitting' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -15,12 +15,12 @@ describe 'ButtonAction', 'when submitting' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should render a submit type of button' do
|
18
|
-
output_buffer.
|
18
|
+
expect(output_buffer).to have_tag('li.action.button_action button[@type="submit"]')
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
22
22
|
|
23
|
-
describe 'ButtonAction', 'when resetting' do
|
23
|
+
RSpec.describe 'ButtonAction', 'when resetting' do
|
24
24
|
|
25
25
|
include FormtasticSpecHelper
|
26
26
|
|
@@ -34,16 +34,16 @@ describe 'ButtonAction', 'when resetting' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should render a reset type of button' do
|
37
|
-
output_buffer.
|
37
|
+
expect(output_buffer).to have_tag('li.action.button_action button[@type="reset"]', :text => "Reset Post")
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should not render a value attribute' do
|
41
|
-
output_buffer.
|
41
|
+
expect(output_buffer).not_to have_tag('li.action.button_action button[@value]')
|
42
42
|
end
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
describe 'InputAction', 'when cancelling' do
|
46
|
+
RSpec.describe 'InputAction', 'when cancelling' do
|
47
47
|
|
48
48
|
include FormtasticSpecHelper
|
49
49
|
|
@@ -53,11 +53,11 @@ describe 'InputAction', 'when cancelling' do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should raise an error' do
|
56
|
-
|
56
|
+
expect {
|
57
57
|
concat(semantic_form_for(@new_post) do |builder|
|
58
58
|
concat(builder.action(:cancel, :as => :button))
|
59
59
|
end)
|
60
|
-
}.
|
60
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'InputAction::Base' do
|
4
|
+
RSpec.describe 'InputAction::Base' do
|
5
5
|
|
6
6
|
# Most basic Action class to test Base
|
7
7
|
class ::GenericAction
|
@@ -36,15 +36,15 @@ describe 'InputAction::Base' do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should add the #foo id to the li' do
|
39
|
-
output_buffer.
|
39
|
+
expect(output_buffer).to have_tag('li#post_submit_action')
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should add the .action and .generic_action classes to the li' do
|
43
|
-
output_buffer.
|
43
|
+
expect(output_buffer).to have_tag('li.action.generic_action')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'should pass :wrapper_html HTML attributes to the wrapper' do
|
47
|
-
output_buffer.
|
47
|
+
expect(output_buffer).to have_tag('li.action.generic_action[@foo="bah"]')
|
48
48
|
end
|
49
49
|
|
50
50
|
context "when a custom :id is provided" do
|
@@ -58,7 +58,7 @@ describe 'InputAction::Base' do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should use the custom id" do
|
61
|
-
output_buffer.
|
61
|
+
expect(output_buffer).to have_tag('li#foo_bah_bing')
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -74,7 +74,7 @@ describe 'InputAction::Base' do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should add the custom class strng to the existing classes" do
|
77
|
-
output_buffer.
|
77
|
+
expect(output_buffer).to have_tag('li.action.generic_action.foo_bah_bing')
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -90,7 +90,7 @@ describe 'InputAction::Base' do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should add the custom class strng to the existing classes" do
|
93
|
-
output_buffer.
|
93
|
+
expect(output_buffer).to have_tag('li.action.generic_action.foo_bah_bing.zing_boo')
|
94
94
|
end
|
95
95
|
|
96
96
|
end
|
@@ -108,7 +108,7 @@ describe 'InputAction::Base' do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'should pass :button_html HTML attributes to the button' do
|
111
|
-
output_buffer.
|
111
|
+
expect(output_buffer).to have_tag('li.action.generic_action input[@foo="bah"]')
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'should respect a default_commit_button_accesskey configuration with nil' do
|
@@ -116,7 +116,7 @@ describe 'InputAction::Base' do
|
|
116
116
|
concat(semantic_form_for(@new_post) do |builder|
|
117
117
|
concat(builder.action(:submit, :as => :generic))
|
118
118
|
end)
|
119
|
-
output_buffer.
|
119
|
+
expect(output_buffer).not_to have_tag('li.action input[@accesskey]')
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -125,7 +125,7 @@ describe 'InputAction::Base' do
|
|
125
125
|
concat(semantic_form_for(@new_post) do |builder|
|
126
126
|
concat(builder.action(:submit, :as => :generic))
|
127
127
|
end)
|
128
|
-
output_buffer.
|
128
|
+
expect(output_buffer).to have_tag('li.action input[@accesskey="s"]')
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -134,8 +134,8 @@ describe 'InputAction::Base' do
|
|
134
134
|
concat(semantic_form_for(@new_post) do |builder|
|
135
135
|
concat(builder.action(:submit, :as => :generic, :accesskey => 'o'))
|
136
136
|
end)
|
137
|
-
output_buffer.
|
138
|
-
output_buffer.
|
137
|
+
expect(output_buffer).not_to have_tag('li.action input[@accesskey="s"]')
|
138
|
+
expect(output_buffer).to have_tag('li.action input[@accesskey="o"]')
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -152,9 +152,9 @@ describe 'InputAction::Base' do
|
|
152
152
|
concat(builder.action(:reset, :as => :generic, :label => "Reset!"))
|
153
153
|
concat(builder.action(:cancel, :as => :generic, :label => "Cancel!"))
|
154
154
|
end)
|
155
|
-
output_buffer.
|
156
|
-
output_buffer.
|
157
|
-
output_buffer.
|
155
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Click!"]')
|
156
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset!"]')
|
157
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel!"]')
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
@@ -185,9 +185,9 @@ describe 'InputAction::Base' do
|
|
185
185
|
concat(builder.action(:reset, :as => :generic))
|
186
186
|
concat(builder.action(:cancel, :as => :generic))
|
187
187
|
end)
|
188
|
-
output_buffer.
|
189
|
-
output_buffer.
|
190
|
-
output_buffer.
|
188
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Submit Post"]')
|
189
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel Post"]')
|
190
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset Post"]')
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'should render an input with custom resource name localized label' do
|
@@ -196,9 +196,9 @@ describe 'InputAction::Base' do
|
|
196
196
|
concat(builder.action(:reset, :as => :generic))
|
197
197
|
concat(builder.action(:cancel, :as => :generic))
|
198
198
|
end)
|
199
|
-
output_buffer.
|
200
|
-
output_buffer.
|
201
|
-
output_buffer.
|
199
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Submit message"]')
|
200
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel message"]')
|
201
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset message"]')
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -237,9 +237,9 @@ describe 'InputAction::Base' do
|
|
237
237
|
concat(builder.action(:reset, :as => :generic))
|
238
238
|
concat(builder.action(:cancel, :as => :generic))
|
239
239
|
end)
|
240
|
-
output_buffer.
|
241
|
-
output_buffer.
|
242
|
-
output_buffer.
|
240
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Submit Post"]})
|
241
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset Post"]})
|
242
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel Post"]})
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -250,9 +250,9 @@ describe 'InputAction::Base' do
|
|
250
250
|
concat(builder.action(:reset, :as => :generic))
|
251
251
|
concat(builder.action(:cancel, :as => :generic))
|
252
252
|
end)
|
253
|
-
output_buffer.
|
254
|
-
output_buffer.
|
255
|
-
output_buffer.
|
253
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Submit"]})
|
254
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset"]})
|
255
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel"]})
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
@@ -262,7 +262,7 @@ describe 'InputAction::Base' do
|
|
262
262
|
|
263
263
|
describe 'when used on a new record' do
|
264
264
|
before do
|
265
|
-
@new_post.
|
265
|
+
allow(@new_post).to receive(:new_record?).and_return(true)
|
266
266
|
end
|
267
267
|
|
268
268
|
describe 'when explicit label is provided' do
|
@@ -272,9 +272,9 @@ describe 'InputAction::Base' do
|
|
272
272
|
concat(builder.action(:reset, :as => :generic, :label => "Reset!"))
|
273
273
|
concat(builder.action(:cancel, :as => :generic, :label => "Cancel!"))
|
274
274
|
end)
|
275
|
-
output_buffer.
|
276
|
-
output_buffer.
|
277
|
-
output_buffer.
|
275
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Click!"]')
|
276
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset!"]')
|
277
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel!"]')
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
@@ -298,9 +298,9 @@ describe 'InputAction::Base' do
|
|
298
298
|
concat(builder.action(:reset, :as => :generic))
|
299
299
|
concat(builder.action(:cancel, :as => :generic))
|
300
300
|
end)
|
301
|
-
output_buffer.
|
302
|
-
output_buffer.
|
303
|
-
output_buffer.
|
301
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Create Post"]')
|
302
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset Post"]')
|
303
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel Post"]')
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
@@ -337,9 +337,9 @@ describe 'InputAction::Base' do
|
|
337
337
|
concat(builder.action(:reset, :as => :generic))
|
338
338
|
concat(builder.action(:cancel, :as => :generic))
|
339
339
|
end)
|
340
|
-
output_buffer.
|
341
|
-
output_buffer.
|
342
|
-
output_buffer.
|
340
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Create Post"]})
|
341
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset Post"]})
|
342
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel Post"]})
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
@@ -350,9 +350,9 @@ describe 'InputAction::Base' do
|
|
350
350
|
concat(builder.action(:reset, :as => :generic))
|
351
351
|
concat(builder.action(:cancel, :as => :generic))
|
352
352
|
end)
|
353
|
-
output_buffer.
|
354
|
-
output_buffer.
|
355
|
-
output_buffer.
|
353
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Create"]})
|
354
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset"]})
|
355
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel"]})
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
@@ -362,7 +362,7 @@ describe 'InputAction::Base' do
|
|
362
362
|
|
363
363
|
describe 'when used on an existing record' do
|
364
364
|
before do
|
365
|
-
@new_post.
|
365
|
+
allow(@new_post).to receive(:persisted?).and_return(true)
|
366
366
|
end
|
367
367
|
|
368
368
|
describe 'when explicit label is provided' do
|
@@ -372,9 +372,9 @@ describe 'InputAction::Base' do
|
|
372
372
|
concat(builder.action(:reset, :as => :generic, :label => "Reset!"))
|
373
373
|
concat(builder.action(:cancel, :as => :generic, :label => "Cancel!"))
|
374
374
|
end)
|
375
|
-
output_buffer.
|
376
|
-
output_buffer.
|
377
|
-
output_buffer.
|
375
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Click!"]')
|
376
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset!"]')
|
377
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel!"]')
|
378
378
|
end
|
379
379
|
end
|
380
380
|
|
@@ -405,9 +405,9 @@ describe 'InputAction::Base' do
|
|
405
405
|
concat(builder.action(:reset, :as => :generic))
|
406
406
|
concat(builder.action(:cancel, :as => :generic))
|
407
407
|
end)
|
408
|
-
output_buffer.
|
409
|
-
output_buffer.
|
410
|
-
output_buffer.
|
408
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Save Post"]')
|
409
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset Post"]')
|
410
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel Post"]')
|
411
411
|
end
|
412
412
|
|
413
413
|
it 'should render an input with custom resource name localized label' do
|
@@ -416,9 +416,9 @@ describe 'InputAction::Base' do
|
|
416
416
|
concat(builder.action(:reset, :as => :generic))
|
417
417
|
concat(builder.action(:cancel, :as => :generic))
|
418
418
|
end)
|
419
|
-
output_buffer.
|
420
|
-
output_buffer.
|
421
|
-
output_buffer.
|
419
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Submit message"]')
|
420
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Cancel message"]')
|
421
|
+
expect(output_buffer).to have_tag('li.generic_action input[@value="Reset message"]')
|
422
422
|
end
|
423
423
|
end
|
424
424
|
|
@@ -456,9 +456,9 @@ describe 'InputAction::Base' do
|
|
456
456
|
concat(builder.action(:reset, :as => :generic))
|
457
457
|
concat(builder.action(:cancel, :as => :generic))
|
458
458
|
end)
|
459
|
-
output_buffer.
|
460
|
-
output_buffer.
|
461
|
-
output_buffer.
|
459
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Save Post"]})
|
460
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset Post"]})
|
461
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel Post"]})
|
462
462
|
end
|
463
463
|
end
|
464
464
|
|
@@ -469,9 +469,9 @@ describe 'InputAction::Base' do
|
|
469
469
|
concat(builder.action(:reset, :as => :generic))
|
470
470
|
concat(builder.action(:cancel, :as => :generic))
|
471
471
|
end)
|
472
|
-
output_buffer.
|
473
|
-
output_buffer.
|
474
|
-
output_buffer.
|
472
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Save"]})
|
473
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Reset"]})
|
474
|
+
expect(output_buffer).to have_tag(%Q{li.generic_action input[@value="Custom Cancel"]})
|
475
475
|
::I18n.backend.store_translations :en, :formtastic => {}
|
476
476
|
end
|
477
477
|
end
|
@@ -502,7 +502,7 @@ describe 'InputAction::Base' do
|
|
502
502
|
end
|
503
503
|
@new_user_post = ::UserPost.new
|
504
504
|
|
505
|
-
@new_user_post.
|
505
|
+
allow(@new_user_post).to receive(:new_record?).and_return(true)
|
506
506
|
concat(semantic_form_for(@new_user_post, :url => '') do |builder|
|
507
507
|
concat(builder.action(:submit, :as => :generic))
|
508
508
|
concat(builder.action(:reset, :as => :generic))
|
@@ -511,9 +511,9 @@ describe 'InputAction::Base' do
|
|
511
511
|
end
|
512
512
|
|
513
513
|
it "should render the string as the value of the button" do
|
514
|
-
output_buffer.
|
515
|
-
output_buffer.
|
516
|
-
output_buffer.
|
514
|
+
expect(output_buffer).to have_tag('li input[@value="Create User post"]')
|
515
|
+
expect(output_buffer).to have_tag('li input[@value="Reset User post"]')
|
516
|
+
expect(output_buffer).to have_tag('li input[@value="Cancel User post"]')
|
517
517
|
end
|
518
518
|
|
519
519
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'InputAction', 'when submitting' do
|
4
|
+
RSpec.describe 'InputAction', 'when submitting' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -15,12 +15,12 @@ describe 'InputAction', 'when submitting' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should render a submit type of input' do
|
18
|
-
output_buffer.
|
18
|
+
expect(output_buffer).to have_tag('li.action.input_action input[@type="submit"]')
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
22
22
|
|
23
|
-
describe 'InputAction', 'when resetting' do
|
23
|
+
RSpec.describe 'InputAction', 'when resetting' do
|
24
24
|
|
25
25
|
include FormtasticSpecHelper
|
26
26
|
|
@@ -34,12 +34,12 @@ describe 'InputAction', 'when resetting' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should render a reset type of input' do
|
37
|
-
output_buffer.
|
37
|
+
expect(output_buffer).to have_tag('li.action.input_action input[@type="reset"]')
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
41
41
|
|
42
|
-
describe 'InputAction', 'when cancelling' do
|
42
|
+
RSpec.describe 'InputAction', 'when cancelling' do
|
43
43
|
|
44
44
|
include FormtasticSpecHelper
|
45
45
|
|
@@ -49,11 +49,11 @@ describe 'InputAction', 'when cancelling' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should raise an error' do
|
52
|
-
|
52
|
+
expect {
|
53
53
|
concat(semantic_form_for(@new_post) do |builder|
|
54
54
|
concat(builder.action(:cancel, :as => :input))
|
55
55
|
end)
|
56
|
-
}.
|
56
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'LinkAction', 'when cancelling' do
|
4
|
+
RSpec.describe 'LinkAction', 'when cancelling' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -18,7 +18,7 @@ describe 'LinkAction', 'when cancelling' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should render a submit type of input' do
|
21
|
-
output_buffer.
|
21
|
+
expect(output_buffer).to have_tag('li.action.link_action a[@href="javascript:history.back()"]')
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -32,7 +32,7 @@ describe 'LinkAction', 'when cancelling' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should render a submit type of input' do
|
35
|
-
output_buffer.
|
35
|
+
expect(output_buffer).to have_tag('li.action.link_action a[@href="http://foo.bah/baz"]')
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -46,14 +46,14 @@ describe 'LinkAction', 'when cancelling' do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should render a submit type of input' do
|
49
|
-
output_buffer.
|
49
|
+
expect(output_buffer).to have_tag('li.action.link_action a[@href="/mock/path"]')
|
50
50
|
end
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
54
|
end
|
55
55
|
|
56
|
-
describe 'LinkAction', 'when submitting' do
|
56
|
+
RSpec.describe 'LinkAction', 'when submitting' do
|
57
57
|
|
58
58
|
include FormtasticSpecHelper
|
59
59
|
|
@@ -63,16 +63,16 @@ describe 'LinkAction', 'when submitting' do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should raise an error' do
|
66
|
-
|
66
|
+
expect {
|
67
67
|
concat(semantic_form_for(@new_post) do |builder|
|
68
68
|
concat(builder.action(:submit, :as => :link))
|
69
69
|
end)
|
70
|
-
}.
|
70
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
71
71
|
end
|
72
72
|
|
73
73
|
end
|
74
74
|
|
75
|
-
describe 'LinkAction', 'when submitting' do
|
75
|
+
RSpec.describe 'LinkAction', 'when submitting' do
|
76
76
|
|
77
77
|
include FormtasticSpecHelper
|
78
78
|
|
@@ -82,11 +82,11 @@ describe 'LinkAction', 'when submitting' do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'should raise an error' do
|
85
|
-
|
85
|
+
expect {
|
86
86
|
concat(semantic_form_for(@new_post) do |builder|
|
87
87
|
concat(builder.action(:reset, :as => :link))
|
88
88
|
end)
|
89
|
-
}.
|
89
|
+
}.to raise_error(Formtastic::UnsupportedMethodForAction)
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|