gov_uk_date_fields 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gov_uk_date_fields/form_fields.rb +12 -10
- data/lib/gov_uk_date_fields/version.rb +1 -1
- data/test/dummy/log/test.log +1481 -0
- data/test/form_fields_test.rb +58 -58
- metadata +3 -3
data/test/form_fields_test.rb
CHANGED
@@ -21,37 +21,37 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
24
|
+
test "error raised if invalid options given" do
|
25
|
+
err = assert_raise do
|
26
|
+
GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, rubbish: 'some_value')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
test "basic_output_without_fieldset" do
|
32
|
+
date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob)
|
33
|
+
assert_html_equal(date_fields.raw_output, expected_basic_output_without_fieldset)
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'placeholder_output_without_fieldset' do
|
37
|
+
date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {placeholders: { day: 'DAY', month: 'MTH', year: 'YEAR' } })
|
38
|
+
assert_html_equal(date_fields.raw_output, expected_placeholder_output_without_fieldset)
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'fieldset_output_with_form_hint' do
|
42
|
+
date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :dob, {legend_text: 'Date of birth', legend_class: 'govuk_legend_class', form_hint_text: 'In the form: dd mm yyyy'})
|
43
|
+
assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_form_hint)
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
test 'fieldset output with legend class' do
|
47
|
+
date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', legend_class: 'date-legend-class', form_hint_text: 'For example, 31 3 1980'})
|
48
|
+
assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_legend_class)
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
test 'fieldset with id' do
|
52
|
+
date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined'})
|
53
|
+
assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_id)
|
54
|
+
end
|
55
55
|
|
56
56
|
test 'fieldset with error_class and message' do
|
57
57
|
@employee.errors[:joined] << "Invalid joining date"
|
@@ -60,11 +60,11 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
60
60
|
assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_error_class_and_message)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
test "squash_html" do
|
64
|
+
html = " <html> This is some text \n <tr> \n <td> <%= dfkhdfh %> </td> </tr>\n</html> "
|
65
|
+
expected_result = "<html>This is some text<tr><td><%= dfkhdfh %></td></tr></html>"
|
66
|
+
assert_html_equal(html, expected_result)
|
67
|
+
end
|
68
68
|
|
69
69
|
|
70
70
|
def expected_basic_output_without_fieldset
|
@@ -99,16 +99,16 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
99
99
|
</ul>
|
100
100
|
<p class="form-hint" id="joined-hint">For example, 31 3 1980</p>
|
101
101
|
<div class="form-group form-group-day">
|
102
|
-
<label for="
|
103
|
-
<input class="form-control" id="
|
102
|
+
<label for="employee_joined_dd">Day</label>
|
103
|
+
<input class="form-control" id="employee_joined_dd" name="employee[joined_dd]" type="number" pattern="[0-9]*" min="0" max="31" aria-describedby="joined-hint" value="1">
|
104
104
|
</div>
|
105
105
|
<div class="form-group form-group-month">
|
106
|
-
<label for="
|
107
|
-
<input class="form-control" id="
|
106
|
+
<label for="employee_joined_mm">Month</label>
|
107
|
+
<input class="form-control" id="employee_joined_mm" name="employee[joined_mm]" type="number" pattern="[0-9]*" min="0" max="12" value="4">
|
108
108
|
</div>
|
109
109
|
<div class="form-group form-group-year">
|
110
|
-
<label for="
|
111
|
-
<input class="form-control" id="
|
110
|
+
<label for="employee_joined_yyyy">Year</label>
|
111
|
+
<input class="form-control" id="employee_joined_yyyy" name="employee[joined_yyyy]" type="number" pattern="[0-9]*" min="0" max="2016" value="2015">
|
112
112
|
</div>
|
113
113
|
</div>
|
114
114
|
</fieldset>
|
@@ -122,16 +122,16 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
122
122
|
<div class="form-date">
|
123
123
|
<p class="form-hint" id="joined-hint">For example, 31 3 1980</p>
|
124
124
|
<div class="form-group form-group-day">
|
125
|
-
<label for="
|
126
|
-
<input class="form-control" id="
|
125
|
+
<label for="employee_joined_dd">Day</label>
|
126
|
+
<input class="form-control" id="employee_joined_dd" name="employee[joined_dd]" type="number" pattern="[0-9]*" min="0" max="31" aria-describedby="joined-hint" value="1">
|
127
127
|
</div>
|
128
128
|
<div class="form-group form-group-month">
|
129
|
-
<label for="
|
130
|
-
<input class="form-control" id="
|
129
|
+
<label for="employee_joined_mm">Month</label>
|
130
|
+
<input class="form-control" id="employee_joined_mm" name="employee[joined_mm]" type="number" pattern="[0-9]*" min="0" max="12" value="4">
|
131
131
|
</div>
|
132
132
|
<div class="form-group form-group-year">
|
133
|
-
<label for="
|
134
|
-
<input class="form-control" id="
|
133
|
+
<label for="employee_joined_yyyy">Year</label>
|
134
|
+
<input class="form-control" id="employee_joined_yyyy" name="employee[joined_yyyy]" type="number" pattern="[0-9]*" min="0" max="2016" value="2015">
|
135
135
|
</div>
|
136
136
|
</div>
|
137
137
|
</fieldset>
|
@@ -145,16 +145,16 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
145
145
|
<div class="form-date">
|
146
146
|
<p class="form-hint" id="dob-hint">In the form: dd mm yyyy</p>
|
147
147
|
<div class="form-group form-group-day">
|
148
|
-
<label for="
|
149
|
-
<input class="form-control" id="
|
148
|
+
<label for="employee_dob_dd">Day</label>
|
149
|
+
<input class="form-control" id="employee_dob_dd" name="employee[dob_dd]" type="number" pattern="[0-9]*" min="0" max="31" aria-describedby="dob-hint" value="7">
|
150
150
|
</div>
|
151
151
|
<div class="form-group form-group-month">
|
152
|
-
<label for="
|
153
|
-
<input class="form-control" id="
|
152
|
+
<label for="employee_dob_mm">Month</label>
|
153
|
+
<input class="form-control" id="employee_dob_mm" name="employee[dob_mm]" type="number" pattern="[0-9]*" min="0" max="12" value="12">
|
154
154
|
</div>
|
155
155
|
<div class="form-group form-group-year">
|
156
|
-
<label for="
|
157
|
-
<input class="form-control" id="
|
156
|
+
<label for="employee_dob_yyyy">Year</label>
|
157
|
+
<input class="form-control" id="employee_dob_yyyy" name="employee[dob_yyyy]" type="number" pattern="[0-9]*" min="0" max="2016" value="1963">
|
158
158
|
</div>
|
159
159
|
</div>
|
160
160
|
</fieldset>
|
@@ -168,16 +168,16 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
|
|
168
168
|
<div class="form-date">
|
169
169
|
<p class="form-hint" id="joined-hint">For example, 31 3 1980</p>
|
170
170
|
<div class="form-group form-group-day">
|
171
|
-
<label for="
|
172
|
-
<input class="form-control" id="
|
171
|
+
<label for="employee_joined_dd">Day</label>
|
172
|
+
<input class="form-control" id="employee_joined_dd" name="employee[joined_dd]" type="number" pattern="[0-9]*" min="0" max="31" aria-describedby="joined-hint" value="1">
|
173
173
|
</div>
|
174
174
|
<div class="form-group form-group-month">
|
175
|
-
<label for="
|
176
|
-
<input class="form-control" id="
|
175
|
+
<label for="employee_joined_mm">Month</label>
|
176
|
+
<input class="form-control" id="employee_joined_mm" name="employee[joined_mm]" type="number" pattern="[0-9]*" min="0" max="12" value="4">
|
177
177
|
</div>
|
178
178
|
<div class="form-group form-group-year">
|
179
|
-
<label for="
|
180
|
-
<input class="form-control" id="
|
179
|
+
<label for="employee_joined_yyyy">Year</label>
|
180
|
+
<input class="form-control" id="employee_joined_yyyy" name="employee[joined_yyyy]" type="number" pattern="[0-9]*" min="0" max="#{Date.today.year}" value="2015">
|
181
181
|
</div>
|
182
182
|
</div>
|
183
183
|
</fieldset>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gov_uk_date_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Richards
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-04-
|
12
|
+
date: 2016-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.4.6
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Enable day-month-year text edit fields for form date entry
|