gov_uk_date_fields 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ require 'mocha/test_unit'
2
+
1
3
  require File.dirname(File.expand_path(__FILE__)) + '/test_helper'
2
4
 
3
5
  class MockTemplate
@@ -51,6 +53,12 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
51
53
  assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_id)
52
54
  end
53
55
 
56
+ test 'fieldset with error_class' do
57
+ @employee.stubs(:errors).returns( {joined: 'wrong'} )
58
+ date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined'})
59
+ assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_error_class)
60
+ end
61
+
54
62
  test "squash_html" do
55
63
  html = " <html> This is some text \n <tr> \n <td> <%= dfkhdfh %> </td> </tr>\n</html> "
56
64
  expected_result = "<html>This is some text<tr><td><%= dfkhdfh %></td></tr></html>"
@@ -75,6 +83,29 @@ class GovUkDateFieldsTest < ActiveSupport::TestCase
75
83
  }
76
84
  end
77
85
 
86
+ def expected_fieldset_output_with_error_class
87
+ %Q{
88
+ <fieldset id="employee_date_joined" class="error">
89
+ <legend>Joining date</legend>
90
+ <div class="form-date">
91
+ <p class="form-hint" id="joined-hint">For example, 31 3 1980</p>
92
+ <div class="form-group form-group-day">
93
+ <label for="joined-day">Day</label>
94
+ <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">
95
+ </div>
96
+ <div class="form-group form-group-month">
97
+ <label for="joined-month">Month</label>
98
+ <input class="form-control" id="employee[joined_mm]" name="employee[joined_mm]" type="number" pattern="[0-9]*" min="0" max="12" value="4">
99
+ </div>
100
+ <div class="form-group form-group-year">
101
+ <label for="joined-year">Year</label>
102
+ <input class="form-control" id="employee[joined_yyyy]" name="employee[joined_yyyy]" type="number" pattern="[0-9]*" min="0" max="2016" value="2015">
103
+ </div>
104
+ </div>
105
+ </fieldset>
106
+ }
107
+ end
108
+
78
109
  def expected_fieldset_output_with_id
79
110
  %Q{
80
111
  <fieldset id="employee_date_joined">
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.2
4
+ version: 1.0.3
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-01 00:00:00.000000000 Z
12
+ date: 2016-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: mocha
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.1'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.1'
56
70
  description: Provides acts_as_gov_uk_date to mark Rails model attributes as dates
57
71
  that will be entered as three separate text edit boxes, and a form_builder method
58
72
  gov_uk_date_field to display those fields.
@@ -182,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
196
  version: '0'
183
197
  requirements: []
184
198
  rubyforge_project:
185
- rubygems_version: 2.4.6
199
+ rubygems_version: 2.5.1
186
200
  signing_key:
187
201
  specification_version: 4
188
202
  summary: Enable day-month-year text edit fields for form date entry