formtastic 3.1.6 → 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 +4 -4
- 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 +9 -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/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/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/inputs.rb +32 -29
- data/lib/formtastic/localizer.rb +4 -3
- data/lib/formtastic/version.rb +1 -1
- data/lib/formtastic.rb +5 -11
- 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 +36 -122
- 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 'password input' do
|
4
|
+
RSpec.describe 'password input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -71,15 +71,15 @@ describe 'password input' do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should index the id of the wrapper' do
|
74
|
-
output_buffer.
|
74
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should index the id of the select tag' do
|
78
|
-
output_buffer.
|
78
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should index the name of the select tag' do
|
82
|
-
output_buffer.
|
82
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
@@ -91,7 +91,7 @@ describe 'password input' do
|
|
91
91
|
concat(semantic_form_for(@new_post) do |builder|
|
92
92
|
concat(builder.input(:title, :as => :password, :required => true))
|
93
93
|
end)
|
94
|
-
output_buffer.
|
94
|
+
expect(output_buffer).to have_tag("input[@required]")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'phone input' do
|
4
|
+
RSpec.describe 'phone input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -56,15 +56,15 @@ describe 'phone input' do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should index the id of the wrapper' do
|
59
|
-
output_buffer.
|
59
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should index the id of the select tag' do
|
63
|
-
output_buffer.
|
63
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name")
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'should index the name of the select tag' do
|
67
|
-
output_buffer.
|
67
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
68
68
|
end
|
69
69
|
|
70
70
|
end
|
@@ -76,7 +76,7 @@ describe 'phone input' do
|
|
76
76
|
concat(semantic_form_for(@new_post) do |builder|
|
77
77
|
concat(builder.input(:title, :as => :phone, :required => true))
|
78
78
|
end)
|
79
|
-
output_buffer.
|
79
|
+
expect(output_buffer).to have_tag("input[@required]")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -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
|
|
@@ -27,7 +27,7 @@ describe 'string input' do
|
|
27
27
|
concat(semantic_form_for(@new_post) do |builder|
|
28
28
|
concat(builder.input(:title, :as => type))
|
29
29
|
end)
|
30
|
-
output_buffer.
|
30
|
+
expect(output_buffer).to have_tag((type == :text ? 'textarea' : 'input') + '[@placeholder="War and Peace"]')
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -37,7 +37,7 @@ describe 'string input' do
|
|
37
37
|
concat(semantic_form_for(@new_post) do |builder|
|
38
38
|
concat(builder.input(:title, :as => type))
|
39
39
|
end)
|
40
|
-
output_buffer.
|
40
|
+
expect(output_buffer).not_to have_tag((type == :text ? 'textarea' : 'input') + '[@placeholder]')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -48,7 +48,7 @@ describe 'string input' do
|
|
48
48
|
concat(semantic_form_for(@new_post) do |builder|
|
49
49
|
concat(builder.input(:title, :as => type, :input_html => { :placeholder => "Foo" }))
|
50
50
|
end)
|
51
|
-
output_buffer.
|
51
|
+
expect(output_buffer).to have_tag((type == :text ? 'textarea' : 'input') + '[@placeholder="Foo"]')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -58,7 +58,7 @@ describe 'string input' do
|
|
58
58
|
concat(semantic_form_for(@new_post) do |builder|
|
59
59
|
concat(builder.input(:title, :as => type, :input_html => { :placeholder => "Untitled" }))
|
60
60
|
end)
|
61
|
-
output_buffer.
|
61
|
+
expect(output_buffer).to have_tag((type == :text ? 'textarea' : 'input') + '[@placeholder="Untitled"]')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe 'radio input' do
|
4
|
+
RSpec.describe 'radio input' do
|
5
5
|
|
6
6
|
include FormtasticSpecHelper
|
7
7
|
|
@@ -27,66 +27,66 @@ describe 'radio input' do
|
|
27
27
|
it_should_use_the_collection_when_provided(:radio, 'input')
|
28
28
|
|
29
29
|
it 'should generate a legend containing a label with text for the input' do
|
30
|
-
output_buffer.
|
31
|
-
output_buffer.
|
30
|
+
expect(output_buffer).to have_tag('form li fieldset legend.label label')
|
31
|
+
expect(output_buffer).to have_tag('form li fieldset legend.label label', :text => /Author/)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should not link the label within the legend to any input' do
|
35
|
-
output_buffer.
|
35
|
+
expect(output_buffer).not_to have_tag('form li fieldset legend label[@for]')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should generate an ordered list with a list item for each choice' do
|
39
|
-
output_buffer.
|
40
|
-
output_buffer.
|
39
|
+
expect(output_buffer).to have_tag('form li fieldset ol')
|
40
|
+
expect(output_buffer).to have_tag('form li fieldset ol li.choice', :count => ::Author.all.size)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should have one option with a "checked" attribute' do
|
44
|
-
output_buffer.
|
44
|
+
expect(output_buffer).to have_tag('form li input[@checked]', :count => 1)
|
45
45
|
end
|
46
46
|
|
47
47
|
describe "each choice" do
|
48
48
|
|
49
49
|
it 'should not give the choice label the .label class' do
|
50
|
-
output_buffer.
|
50
|
+
expect(output_buffer).not_to have_tag('li.choice label.label')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should not add the required attribute to each input' do
|
54
|
-
output_buffer.
|
54
|
+
expect(output_buffer).not_to have_tag('li.choice input[@required]')
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
58
|
it 'should contain a label for the radio input with a nested input and label text' do
|
59
59
|
::Author.all.each do |author|
|
60
|
-
output_buffer.
|
61
|
-
output_buffer.
|
60
|
+
expect(output_buffer).to have_tag('form li fieldset ol li label', /#{author.to_label}/)
|
61
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label[@for='post_author_id_#{author.id}']")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should use values as li.class when value_as_class is true' do
|
66
66
|
::Author.all.each do |author|
|
67
|
-
output_buffer.
|
67
|
+
expect(output_buffer).to have_tag("form li fieldset ol li.author_#{author.id} label")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should have a radio input" do
|
72
72
|
::Author.all.each do |author|
|
73
|
-
output_buffer.
|
74
|
-
output_buffer.
|
75
|
-
output_buffer.
|
76
|
-
output_buffer.
|
73
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input#post_author_id_#{author.id}")
|
74
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@type='radio']")
|
75
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@value='#{author.id}']")
|
76
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@name='post[author_id]']")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should mark input as checked if it's the the existing choice" do
|
81
|
-
@new_post.author_id.
|
82
|
-
@new_post.author.id.
|
83
|
-
@new_post.author.
|
81
|
+
expect(@new_post.author_id).to eq(@bob.id)
|
82
|
+
expect(@new_post.author.id).to eq(@bob.id)
|
83
|
+
expect(@new_post.author).to eq(@bob)
|
84
84
|
|
85
85
|
concat(semantic_form_for(@new_post) do |builder|
|
86
86
|
concat(builder.input(:author, :as => :radio))
|
87
87
|
end)
|
88
88
|
|
89
|
-
output_buffer.
|
89
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@checked='checked']")
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should mark the input as disabled if options attached for disabling" do
|
@@ -94,8 +94,8 @@ describe 'radio input' do
|
|
94
94
|
concat(builder.input(:author, :as => :radio, :collection => [["Test", 'test'], ["Try", "try", {:disabled => true}]]))
|
95
95
|
end)
|
96
96
|
|
97
|
-
output_buffer.
|
98
|
-
output_buffer.
|
97
|
+
expect(output_buffer).not_to have_tag("form li fieldset ol li label input[@value='test'][@disabled='disabled']")
|
98
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@value='try'][@disabled='disabled']")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should not contain invalid HTML attributes" do
|
@@ -104,13 +104,13 @@ describe 'radio input' do
|
|
104
104
|
concat(builder.input(:author, :as => :radio))
|
105
105
|
end)
|
106
106
|
|
107
|
-
output_buffer.
|
107
|
+
expect(output_buffer).not_to have_tag("form li fieldset ol li input[@find_options]")
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
111
111
|
|
112
112
|
describe 'and no object is given' do
|
113
|
-
before(:
|
113
|
+
before(:example) do
|
114
114
|
output_buffer.replace ''
|
115
115
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
116
116
|
concat(builder.input(:author_id, :as => :radio, :collection => ::Author.all))
|
@@ -118,17 +118,17 @@ describe 'radio input' do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should generate a fieldset with legend' do
|
121
|
-
output_buffer.
|
121
|
+
expect(output_buffer).to have_tag('form li fieldset legend', :text => /Author/)
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'should generate an li tag for each item in the collection' do
|
125
|
-
output_buffer.
|
125
|
+
expect(output_buffer).to have_tag('form li fieldset ol li', :count => ::Author.all.size)
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'should generate labels for each item' do
|
129
129
|
::Author.all.each do |author|
|
130
|
-
output_buffer.
|
131
|
-
output_buffer.
|
130
|
+
expect(output_buffer).to have_tag('form li fieldset ol li label', :text => /#{author.to_label}/)
|
131
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label[@for='project_author_id_#{author.id}']")
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -136,17 +136,15 @@ describe 'radio input' do
|
|
136
136
|
concat(semantic_form_for(:project, :url => 'http://test.host') do |builder|
|
137
137
|
concat(builder.input(:author_id, :as => :radio, :collection => [["<b>Item 1</b>", 1], ["<b>Item 2</b>", 2]]))
|
138
138
|
end)
|
139
|
-
output_buffer.
|
140
|
-
label.body.should match /<b>Item [12]<\/b>$/
|
141
|
-
end
|
139
|
+
expect(output_buffer).to have_tag('form li fieldset ol li label', text: %r{<b>Item [12]</b>}, count: 2)
|
142
140
|
end
|
143
141
|
|
144
142
|
it 'should generate inputs for each item' do
|
145
143
|
::Author.all.each do |author|
|
146
|
-
output_buffer.
|
147
|
-
output_buffer.
|
148
|
-
output_buffer.
|
149
|
-
output_buffer.
|
144
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input#project_author_id_#{author.id}")
|
145
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@type='radio']")
|
146
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@value='#{author.id}']")
|
147
|
+
expect(output_buffer).to have_tag("form li fieldset ol li label input[@name='project[author_id]']")
|
150
148
|
end
|
151
149
|
end
|
152
150
|
end
|
@@ -154,10 +152,10 @@ describe 'radio input' do
|
|
154
152
|
|
155
153
|
describe 'for a enum column' do
|
156
154
|
before do
|
157
|
-
@new_post.
|
155
|
+
allow(@new_post).to receive(:status) { 'inactive' }
|
158
156
|
statuses = ActiveSupport::HashWithIndifferentAccess.new("active"=>0, "inactive"=>1)
|
159
|
-
@new_post.class.
|
160
|
-
@new_post.
|
157
|
+
allow(@new_post.class).to receive(:statuses) { statuses }
|
158
|
+
allow(@new_post).to receive(:defined_enums) { { "status" => statuses } }
|
161
159
|
end
|
162
160
|
|
163
161
|
before do
|
@@ -167,15 +165,15 @@ describe 'radio input' do
|
|
167
165
|
end
|
168
166
|
|
169
167
|
it 'should have a radio input for each defined enum status' do
|
170
|
-
output_buffer.
|
168
|
+
expect(output_buffer).to have_tag("form li input[@name='post[status]'][@type='radio']", :count => @new_post.class.statuses.count)
|
171
169
|
@new_post.class.statuses.each do |label, value|
|
172
|
-
output_buffer.
|
173
|
-
output_buffer.
|
170
|
+
expect(output_buffer).to have_tag("form li input[@value='#{label}']")
|
171
|
+
expect(output_buffer).to have_tag("form li label", :text => /#{label.humanize}/)
|
174
172
|
end
|
175
173
|
end
|
176
174
|
|
177
175
|
it 'should have one radio input with a "checked" attribute' do
|
178
|
-
output_buffer.
|
176
|
+
expect(output_buffer).to have_tag("form li input[@name='post[status]'][@checked]", :count => 1)
|
179
177
|
end
|
180
178
|
end
|
181
179
|
|
@@ -186,7 +184,7 @@ describe 'radio input' do
|
|
186
184
|
::I18n.backend.store_translations :en, :formtastic => { :labels => { :post => { :authors => "Translated!" }}}
|
187
185
|
|
188
186
|
with_config :i18n_lookups_by_default, true do
|
189
|
-
@new_post.
|
187
|
+
allow(@new_post).to receive(:author_ids).and_return(nil)
|
190
188
|
concat(semantic_form_for(@new_post) do |builder|
|
191
189
|
concat(builder.input(:authors, :as => :radio))
|
192
190
|
end)
|
@@ -198,66 +196,66 @@ describe 'radio input' do
|
|
198
196
|
end
|
199
197
|
|
200
198
|
it "should do foo" do
|
201
|
-
output_buffer.
|
199
|
+
expect(output_buffer).to have_tag("legend.label label", :text => /Translated/)
|
202
200
|
end
|
203
201
|
|
204
202
|
end
|
205
203
|
|
206
204
|
describe "when :label option is set" do
|
207
205
|
before do
|
208
|
-
@new_post.
|
206
|
+
allow(@new_post).to receive(:author_ids).and_return(nil)
|
209
207
|
concat(semantic_form_for(@new_post) do |builder|
|
210
208
|
concat(builder.input(:authors, :as => :radio, :label => 'The authors'))
|
211
209
|
end)
|
212
210
|
end
|
213
211
|
|
214
212
|
it "should output the correct label title" do
|
215
|
-
output_buffer.
|
213
|
+
expect(output_buffer).to have_tag("legend.label label", :text => /The authors/)
|
216
214
|
end
|
217
215
|
end
|
218
216
|
|
219
217
|
describe "when :label option is false" do
|
220
218
|
before do
|
221
219
|
@output_buffer = ''
|
222
|
-
@new_post.
|
220
|
+
allow(@new_post).to receive(:author_ids).and_return(nil)
|
223
221
|
concat(semantic_form_for(@new_post) do |builder|
|
224
222
|
concat(builder.input(:authors, :as => :radio, :label => false))
|
225
223
|
end)
|
226
224
|
end
|
227
225
|
|
228
226
|
it "should not output the legend" do
|
229
|
-
output_buffer.
|
230
|
-
output_buffer.
|
227
|
+
expect(output_buffer).not_to have_tag("legend.label")
|
228
|
+
expect(output_buffer).not_to include(">")
|
231
229
|
end
|
232
230
|
|
233
231
|
it "should not cause escaped HTML" do
|
234
|
-
output_buffer.
|
232
|
+
expect(output_buffer).not_to include(">")
|
235
233
|
end
|
236
234
|
end
|
237
235
|
|
238
236
|
describe "when :required option is true" do
|
239
237
|
before do
|
240
|
-
@new_post.
|
238
|
+
allow(@new_post).to receive(:author_ids).and_return(nil)
|
241
239
|
concat(semantic_form_for(@new_post) do |builder|
|
242
240
|
concat(builder.input(:authors, :as => :radio, :required => true))
|
243
241
|
end)
|
244
242
|
end
|
245
243
|
|
246
244
|
it "should output the correct label title" do
|
247
|
-
output_buffer.
|
245
|
+
expect(output_buffer).to have_tag("legend.label label abbr")
|
248
246
|
end
|
249
247
|
end
|
250
248
|
|
251
249
|
describe "when :namespace is given on form" do
|
252
250
|
before do
|
253
251
|
@output_buffer = ''
|
254
|
-
@new_post.
|
252
|
+
allow(@new_post).to receive(:author_ids).and_return(nil)
|
255
253
|
concat(semantic_form_for(@new_post, :namespace => "custom_prefix") do |builder|
|
256
254
|
concat(builder.input(:authors, :as => :radio, :label => ''))
|
257
255
|
end)
|
258
256
|
|
259
|
-
output_buffer.
|
260
|
-
output_buffer.
|
257
|
+
expect(output_buffer).to match(/for="custom_prefix_post_author_ids_(\d+)"/)
|
258
|
+
expect(output_buffer).to match(/id="custom_prefix_post_author_ids_(\d+)"/)
|
261
259
|
end
|
262
260
|
it_should_have_input_wrapper_with_id("custom_prefix_post_authors_input")
|
263
261
|
end
|
@@ -276,16 +274,16 @@ describe 'radio input' do
|
|
276
274
|
end
|
277
275
|
|
278
276
|
it 'should index the id of the wrapper' do
|
279
|
-
output_buffer.
|
277
|
+
expect(output_buffer).to have_tag("li#post_author_attributes_3_name_input")
|
280
278
|
end
|
281
279
|
|
282
280
|
it 'should index the id of the select tag' do
|
283
|
-
output_buffer.
|
284
|
-
output_buffer.
|
281
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name_true")
|
282
|
+
expect(output_buffer).to have_tag("input#post_author_attributes_3_name_false")
|
285
283
|
end
|
286
284
|
|
287
285
|
it 'should index the name of the select tag' do
|
288
|
-
output_buffer.
|
286
|
+
expect(output_buffer).to have_tag("input[@name='post[author_attributes][3][name]']")
|
289
287
|
end
|
290
288
|
|
291
289
|
end
|
@@ -301,9 +299,9 @@ describe 'radio input' do
|
|
301
299
|
end
|
302
300
|
|
303
301
|
it 'should output the correct labels' do
|
304
|
-
output_buffer.
|
305
|
-
output_buffer.
|
306
|
-
output_buffer.
|
302
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /1/)
|
303
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /2/)
|
304
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /3/)
|
307
305
|
end
|
308
306
|
end
|
309
307
|
|
@@ -318,9 +316,9 @@ describe 'radio input' do
|
|
318
316
|
end
|
319
317
|
|
320
318
|
it 'should output the correct labels' do
|
321
|
-
output_buffer.
|
322
|
-
output_buffer.
|
323
|
-
output_buffer.
|
319
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /A/)
|
320
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /B/)
|
321
|
+
expect(output_buffer).to have_tag("li.choice label", :text => /C/)
|
324
322
|
end
|
325
323
|
end
|
326
324
|
|