gov_uk_date_fields 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ec9ca6a651be83cc6a6cf10b8e0262729f9ff72
4
- data.tar.gz: 89390a34df913cb4b83e56145df959b65c6a4de6
3
+ metadata.gz: 97d3f862b011c12c8cfb47b97019f694a75d20b7
4
+ data.tar.gz: a58ba69eadf26038875b86eb673f4200b68ada9f
5
5
  SHA512:
6
- metadata.gz: 879582b734ad6e4f6f202a4950654c5c39d45798d68aa44ccb1ac6c6b54b95f29e9358a5b4d5c581d79c57f8e6155736bceb5ec4a0f82309da9dac3a01f94f97
7
- data.tar.gz: 24e6f09eff12fbafaf828a8cbe094b7e00e4aa1f7599c78580efe6f0b9be87c5198695f00827f7da1a3b4932430b3d20732037c3aa4fc5a01bb437c6b856ee7c
6
+ metadata.gz: 198a6db12b94e8aa753f6bfc8be5c043b4b6403a4d227ef4e378a71081ac4dc50a824ac7163179bfdc9f266fd1200110db6ff880973bbb77cc72bbc1aad9d92e
7
+ data.tar.gz: 60a2391c1e2b3df687dec851ead4135547fc564c18794080e4d12e8681b5c0224ad00274b8d7066fe2c575a04478d1e922274e97ca2c5efb26b32df0c8250e7c
@@ -1,7 +1,7 @@
1
1
  module GovUkDateFields
2
2
 
3
3
  class FormFields
4
- VALID_OPTIONS = [:legend_text, :legend_class, :form_hint_text, :id, :placeholders]
4
+ VALID_OPTIONS = [:legend_text, :legend_class, :form_hint_text, :id, :placeholders, :error_messages]
5
5
 
6
6
  DATE_SEGMENTS = {
7
7
  day: '_dd',
@@ -27,6 +27,7 @@ module GovUkDateFields
27
27
  @form_hint_text = @options[:form_hint_text] || "For example, 31 3 1980"
28
28
  @fieldset_required = false
29
29
  @fieldset_id = @options[:id]
30
+ @error_messages = @options[:error_messages]
30
31
  parse_options
31
32
  end
32
33
 
@@ -94,7 +95,10 @@ module GovUkDateFields
94
95
  result = ''
95
96
  if error_for_attr?
96
97
  result = "<ul>"
97
- @object.errors[@attribute].each do |message|
98
+ if @error_messages.nil?
99
+ @error_messages = @object.errors[@attribute]
100
+ end
101
+ @error_messages.each do |message|
98
102
  result += %Q|<li><span class="error-message">#{message}</span></li>|
99
103
  end
100
104
  result += "</ul>"
@@ -1,3 +1,3 @@
1
1
  module GovUkDateFields
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -11935,3 +11935,358 @@ EmployeeTest: test_that_form_population_values_can_be_extracted_from_the_date_fi
11935
11935
  EmployeeTest: test_that_the_calling_the_field_name_on_employee_will_return_the_date_part_of_the_form_date_object
11936
11936
  ----------------------------------------------------------------------------------------------------------------
11937
11937
   (0.1ms) ROLLBACK
11938
+ ActiveRecord::SchemaMigration Load (2.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
11939
+  (0.1ms) BEGIN
11940
+ -------------------------------------------------------------------------------
11941
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_supplied_error_messages
11942
+ -------------------------------------------------------------------------------
11943
+  (0.2ms) ROLLBACK
11944
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
11945
+  (0.2ms) BEGIN
11946
+ -------------------------------------------------------------------------------
11947
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_supplied_error_messages
11948
+ -------------------------------------------------------------------------------
11949
+  (0.2ms) ROLLBACK
11950
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
11951
+  (0.1ms) BEGIN
11952
+ ---------------------------------------------------------------
11953
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_message
11954
+ ---------------------------------------------------------------
11955
+  (0.2ms) ROLLBACK
11956
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
11957
+  (0.2ms) BEGIN
11958
+ ---------------------------------------------------------------
11959
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_message
11960
+ ---------------------------------------------------------------
11961
+  (0.1ms) ROLLBACK
11962
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
11963
+  (0.1ms) BEGIN
11964
+ -------------------------------------------------------------------------------
11965
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_supplied_error_messages
11966
+ -------------------------------------------------------------------------------
11967
+  (0.1ms) ROLLBACK
11968
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
11969
+  (0.2ms) BEGIN
11970
+ ---------------------------------------------------------------------------------
11971
+ GovUkDateFields::FormDateTest: test_new_raises_error_if_called_from_outside_class
11972
+ ---------------------------------------------------------------------------------
11973
+  (0.1ms) ROLLBACK
11974
+  (0.1ms) BEGIN
11975
+ -------------------------------------------------------------------------------
11976
+ GovUkDateFields::FormDateTest: test_set_one_date_part_leaves_the_rest_unchanged
11977
+ -------------------------------------------------------------------------------
11978
+  (0.1ms) ROLLBACK
11979
+  (0.1ms) BEGIN
11980
+ ----------------------------------------------------------------------------------------------------------------------------------
11981
+ GovUkDateFields::FormDateTest: test_setting_date_parts_with_invalid_values_marks_date_as_invalid_and_leaves_date_variable_the_same
11982
+ ----------------------------------------------------------------------------------------------------------------------------------
11983
+  (0.1ms) ROLLBACK
11984
+  (0.1ms) BEGIN
11985
+ ------------------------------------------------------------------------------------------
11986
+ GovUkDateFields::FormDateTest: test_set_from_date_instantiates_a_nil_object_if_date_is_nil
11987
+ ------------------------------------------------------------------------------------------
11988
+  (0.1ms) ROLLBACK
11989
+  (0.0ms) BEGIN
11990
+ -----------------------------------------------------------------------------------------
11991
+ GovUkDateFields::FormDateTest: test_set_from_date_instantiates_the_attribute_and_is_valid
11992
+ -----------------------------------------------------------------------------------------
11993
+  (0.1ms) ROLLBACK
11994
+  (0.1ms) BEGIN
11995
+ ---------------------------------------------------------------------------------
11996
+ GovUkDateFields::FormDateTest: test_setting_all_three_date_parts_changes_the_date
11997
+ ---------------------------------------------------------------------------------
11998
+  (0.1ms) ROLLBACK
11999
+  (0.1ms) BEGIN
12000
+ -----------------------------------------------------------------------------------------------
12001
+ GovUkDateFields::FormDateTest: test_setting_all_date_parts_to_nil_sets_date_to_nil_and_is_valid
12002
+ -----------------------------------------------------------------------------------------------
12003
+  (0.1ms) ROLLBACK
12004
+  (0.1ms) BEGIN
12005
+ -----------------------------------------------------------
12006
+ EmployeeTest: test_new_dates_can_be_populated_from_the_form
12007
+ -----------------------------------------------------------
12008
+  (0.1ms) ROLLBACK
12009
+  (0.1ms) BEGIN
12010
+ -----------------------------------------------------------
12011
+ EmployeeTest: test_that_nil_can_be_assigned_to_a_date_field
12012
+ -----------------------------------------------------------
12013
+  (0.1ms) ROLLBACK
12014
+  (0.1ms) BEGIN
12015
+ ---------------------------------------------------------------------
12016
+ EmployeeTest: test_updating_existing_record_with_valid_dates_is_valid
12017
+ ---------------------------------------------------------------------
12018
+  (0.1ms) SAVEPOINT active_record_1
12019
+ SQL (2.3ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "John"], ["dob", "1963-08-13"], ["joined", "2014-04-21"], ["created_at", "2016-04-29 08:57:00.194956"], ["updated_at", "2016-04-29 08:57:00.194956"]]
12020
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12021
+  (0.1ms) SAVEPOINT active_record_1
12022
+ SQL (0.3ms) UPDATE "employees" SET "dob" = $1, "updated_at" = $2 WHERE "employees"."id" = $3 [["dob", "1965-05-17"], ["updated_at", "2016-04-29 08:57:00.209064"], ["id", 628]]
12023
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12024
+  (0.1ms) ROLLBACK
12025
+  (0.1ms) BEGIN
12026
+ -------------------------------------------
12027
+ EmployeeTest: test_invalid_day_raises_error
12028
+ -------------------------------------------
12029
+  (0.1ms) ROLLBACK
12030
+  (0.1ms) BEGIN
12031
+ ---------------------------------------------------------------------
12032
+ EmployeeTest: test_createing_a_new_employee_with_valid_dates_is_valid
12033
+ ---------------------------------------------------------------------
12034
+  (0.1ms) ROLLBACK
12035
+  (0.1ms) BEGIN
12036
+ --------------------------------------------
12037
+ EmployeeTest: test_nil_dates_raise_no_errors
12038
+ --------------------------------------------
12039
+  (0.1ms) ROLLBACK
12040
+  (0.1ms) BEGIN
12041
+ -------------------------------------------------------------------------------------------------------------------
12042
+ EmployeeTest: test_argument_error_is_raised_if_an_object_that_doesnt_respond_to_to_date_is_assigned_to_a_date_field
12043
+ -------------------------------------------------------------------------------------------------------------------
12044
+  (0.1ms) ROLLBACK
12045
+  (0.1ms) BEGIN
12046
+ --------------------------------------------------------------------------
12047
+ EmployeeTest: test_employee_has_class_variable_describing_all_gov_uk_dates
12048
+ --------------------------------------------------------------------------
12049
+  (0.1ms) ROLLBACK
12050
+  (0.1ms) BEGIN
12051
+ -------------------------------------------------------------------------
12052
+ EmployeeTest: test_updating_existing_record_with_invalid_dates_is_invalid
12053
+ -------------------------------------------------------------------------
12054
+  (0.1ms) SAVEPOINT active_record_1
12055
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "John"], ["dob", "1963-08-13"], ["joined", "2014-04-21"], ["created_at", "2016-04-29 08:57:00.218586"], ["updated_at", "2016-04-29 08:57:00.218586"]]
12056
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12057
+  (0.1ms) SAVEPOINT active_record_1
12058
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
12059
+  (0.1ms) ROLLBACK
12060
+  (0.1ms) BEGIN
12061
+ ------------------------------------------------------------------------------------------
12062
+ EmployeeTest: test_employee_instance_has_form_date_instance_variables_for_each_gov_uk_date
12063
+ ------------------------------------------------------------------------------------------
12064
+  (0.1ms) ROLLBACK
12065
+  (0.1ms) BEGIN
12066
+ ----------------------------------------------
12067
+ EmployeeTest: test_valid_dates_raise_no_errors
12068
+ ----------------------------------------------
12069
+  (0.1ms) ROLLBACK
12070
+  (0.1ms) BEGIN
12071
+ -----------------------------------------------------------------------
12072
+ EmployeeTest: test_that_we_can_assign_new_dates_to_the_form_date_object
12073
+ -----------------------------------------------------------------------
12074
+  (0.1ms) ROLLBACK
12075
+  (0.1ms) BEGIN
12076
+ -----------------------------------------------------------------------------------
12077
+ EmployeeTest: test_that_form_population_values_can_be_extracted_from_the_date_field
12078
+ -----------------------------------------------------------------------------------
12079
+  (0.1ms) ROLLBACK
12080
+  (0.1ms) BEGIN
12081
+ ------------------------------------------------------------------------
12082
+ EmployeeTest: test_creating_a_new_employee_with_invalid_dates_is_invalid
12083
+ ------------------------------------------------------------------------
12084
+  (0.1ms) ROLLBACK
12085
+  (0.1ms) BEGIN
12086
+ ----------------------------------------------------------------------------------------------
12087
+ EmployeeTest: test_no_argument_error_is_raised_if_parseable_string_is_assigned_to_a_date_field
12088
+ ----------------------------------------------------------------------------------------------
12089
+  (0.1ms) ROLLBACK
12090
+  (0.1ms) BEGIN
12091
+ ----------------------------------------------------------------------------------------------------------------
12092
+ EmployeeTest: test_that_the_calling_the_field_name_on_employee_will_return_the_date_part_of_the_form_date_object
12093
+ ----------------------------------------------------------------------------------------------------------------
12094
+  (0.1ms) ROLLBACK
12095
+  (0.1ms) BEGIN
12096
+ ---------------------------------------------------------------------------------------------------------
12097
+ EmployeeTest: test_that_argument_error_is_raised_if_unparseable_string_object_is_assigned_to_a_date_field
12098
+ ---------------------------------------------------------------------------------------------------------
12099
+  (0.1ms) ROLLBACK
12100
+  (0.1ms) BEGIN
12101
+ -----------------------------------------------------------------
12102
+ EmployeeTest: test_employee_class_responds_to_acts_as_gov_uk_date
12103
+ -----------------------------------------------------------------
12104
+  (0.1ms) ROLLBACK
12105
+  (0.1ms) BEGIN
12106
+ -------------------------------------------------------
12107
+ GovUkDateFieldsTest: test_basic_output_without_fieldset
12108
+ -------------------------------------------------------
12109
+  (0.1ms) ROLLBACK
12110
+  (0.1ms) BEGIN
12111
+ -------------------------------------
12112
+ GovUkDateFieldsTest: test_squash_html
12113
+ -------------------------------------
12114
+  (0.1ms) ROLLBACK
12115
+  (0.1ms) BEGIN
12116
+ --------------------------------------------------------
12117
+ GovUkDateFieldsTest: test_fieldset_output_with_form_hint
12118
+ --------------------------------------------------------
12119
+  (0.1ms) ROLLBACK
12120
+  (0.1ms) BEGIN
12121
+ -----------------------------------------------------------
12122
+ GovUkDateFieldsTest: test_fieldset_output_with_legend_class
12123
+ -----------------------------------------------------------
12124
+  (0.1ms) ROLLBACK
12125
+  (0.1ms) BEGIN
12126
+ ---------------------------------------------------------------
12127
+ GovUkDateFieldsTest: test_error_raised_if_invalid_options_given
12128
+ ---------------------------------------------------------------
12129
+  (0.1ms) ROLLBACK
12130
+  (0.1ms) BEGIN
12131
+ -------------------------------------------------------------
12132
+ GovUkDateFieldsTest: test_placeholder_output_without_fieldset
12133
+ -------------------------------------------------------------
12134
+  (0.1ms) ROLLBACK
12135
+  (0.1ms) BEGIN
12136
+ -------------------------------------------------------------------------------
12137
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_supplied_error_messages
12138
+ -------------------------------------------------------------------------------
12139
+  (0.1ms) ROLLBACK
12140
+  (0.1ms) BEGIN
12141
+ ------------------------------------------
12142
+ GovUkDateFieldsTest: test_fieldset_with_id
12143
+ ------------------------------------------
12144
+  (0.1ms) ROLLBACK
12145
+  (0.1ms) BEGIN
12146
+ ---------------------------------------------------------------
12147
+ GovUkDateFieldsTest: test_fieldset_with_error_class_and_message
12148
+ ---------------------------------------------------------------
12149
+  (0.1ms) ROLLBACK
12150
+  (0.1ms) BEGIN
12151
+ --------------------------------------------------
12152
+ EmployeesControllerTest: test_should_show_employee
12153
+ --------------------------------------------------
12154
+  (0.1ms) SAVEPOINT active_record_1
12155
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.279199"], ["updated_at", "2016-04-29 08:57:00.279199"]]
12156
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12157
+  (0.1ms) SAVEPOINT active_record_1
12158
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.280771"], ["updated_at", "2016-04-29 08:57:00.280771"]]
12159
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12160
+ Processing by EmployeesController#show as HTML
12161
+ Parameters: {"id"=>"630"}
12162
+ Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 630]]
12163
+ Rendered employees/show.html.erb within layouts/application (1.6ms)
12164
+ Completed 200 OK in 117ms (Views: 113.7ms | ActiveRecord: 0.2ms)
12165
+  (0.2ms) ROLLBACK
12166
+  (0.1ms) BEGIN
12167
+ ----------------------------------------------
12168
+ EmployeesControllerTest: test_should_get_index
12169
+ ----------------------------------------------
12170
+  (0.1ms) SAVEPOINT active_record_1
12171
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.402428"], ["updated_at", "2016-04-29 08:57:00.402428"]]
12172
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12173
+  (0.1ms) SAVEPOINT active_record_1
12174
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.403674"], ["updated_at", "2016-04-29 08:57:00.403674"]]
12175
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12176
+ Processing by EmployeesController#index as HTML
12177
+ Employee Load (0.9ms) SELECT "employees".* FROM "employees"
12178
+ Rendered employees/index.html.erb within layouts/application (3.2ms)
12179
+ Completed 200 OK in 6ms (Views: 4.9ms | ActiveRecord: 0.9ms)
12180
+  (0.2ms) ROLLBACK
12181
+  (0.1ms) BEGIN
12182
+ ----------------------------------------------------
12183
+ EmployeesControllerTest: test_should_create_employee
12184
+ ----------------------------------------------------
12185
+  (0.1ms) SAVEPOINT active_record_1
12186
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.412398"], ["updated_at", "2016-04-29 08:57:00.412398"]]
12187
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12188
+  (0.1ms) SAVEPOINT active_record_1
12189
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.413542"], ["updated_at", "2016-04-29 08:57:00.413542"]]
12190
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12191
+  (0.2ms) SELECT COUNT(*) FROM "employees"
12192
+ Processing by EmployeesController#create as HTML
12193
+ Parameters: {"employee"=>{"dob_dd"=>"31", "dob_mm"=>"12", "dob_yyyy"=>"1965", "joined_dd"=>"4", "joined_mm"=>"mar", "joined_yyyy"=>"2015", "name"=>"Joe Blow"}}
12194
+  (0.1ms) SAVEPOINT active_record_1
12195
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Joe Blow"], ["dob", "1965-12-31"], ["joined", "2015-03-04"], ["created_at", "2016-04-29 08:57:00.416530"], ["updated_at", "2016-04-29 08:57:00.416530"]]
12196
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12197
+ Redirected to http://test.host/employees/636
12198
+ Completed 302 Found in 2ms (ActiveRecord: 0.3ms)
12199
+  (0.1ms) SELECT COUNT(*) FROM "employees"
12200
+  (0.1ms) SELECT COUNT(*) FROM "employees"
12201
+ Employee Load (0.8ms) SELECT "employees".* FROM "employees" ORDER BY "employees"."id" DESC LIMIT 1
12202
+  (0.1ms) ROLLBACK
12203
+  (0.1ms) BEGIN
12204
+ ----------------------------------------------------
12205
+ EmployeesControllerTest: test_should_update_employee
12206
+ ----------------------------------------------------
12207
+  (0.1ms) SAVEPOINT active_record_1
12208
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.420961"], ["updated_at", "2016-04-29 08:57:00.420961"]]
12209
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12210
+  (0.1ms) SAVEPOINT active_record_1
12211
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.422130"], ["updated_at", "2016-04-29 08:57:00.422130"]]
12212
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12213
+ Processing by EmployeesController#update as HTML
12214
+ Parameters: {"employee"=>{"dob_dd"=>"1", "dob_mm"=>"11", "dob_yyyy"=>"1981", "joined_dd"=>"3", "joined_mm"=>"oct", "joined_yyyy"=>"2015", "name"=>"Ioannis Kole"}, "id"=>"637"}
12215
+ Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 637]]
12216
+  (0.1ms) SAVEPOINT active_record_1
12217
+ SQL (0.2ms) UPDATE "employees" SET "name" = $1, "dob" = $2, "joined" = $3, "updated_at" = $4 WHERE "employees"."id" = $5 [["name", "Ioannis Kole"], ["dob", "1981-11-01"], ["joined", "2015-10-03"], ["updated_at", "2016-04-29 08:57:00.425159"], ["id", 637]]
12218
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12219
+ Redirected to http://test.host/employees/637
12220
+ Completed 302 Found in 3ms (ActiveRecord: 0.6ms)
12221
+ Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 637]]
12222
+  (0.1ms) ROLLBACK
12223
+  (0.1ms) BEGIN
12224
+ --------------------------------------------
12225
+ EmployeesControllerTest: test_should_get_new
12226
+ --------------------------------------------
12227
+  (0.1ms) SAVEPOINT active_record_1
12228
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.428691"], ["updated_at", "2016-04-29 08:57:00.428691"]]
12229
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12230
+  (0.1ms) SAVEPOINT active_record_1
12231
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.429771"], ["updated_at", "2016-04-29 08:57:00.429771"]]
12232
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12233
+ Processing by EmployeesController#new as HTML
12234
+ Rendered employees/_form.html.erb (8.3ms)
12235
+ Rendered employees/new.html.erb within layouts/application (11.8ms)
12236
+ Completed 200 OK in 14ms (Views: 13.9ms | ActiveRecord: 0.0ms)
12237
+  (0.2ms) ROLLBACK
12238
+  (0.1ms) BEGIN
12239
+ --------------------------------------------------------------
12240
+ EmployeesControllerTest: test_should_render_gov_uk_date_fields
12241
+ --------------------------------------------------------------
12242
+  (0.1ms) SAVEPOINT active_record_1
12243
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.446611"], ["updated_at", "2016-04-29 08:57:00.446611"]]
12244
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12245
+  (0.1ms) SAVEPOINT active_record_1
12246
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.447916"], ["updated_at", "2016-04-29 08:57:00.447916"]]
12247
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12248
+ Processing by EmployeesController#edit as HTML
12249
+ Parameters: {"id"=>"641"}
12250
+ Employee Load (0.2ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 641]]
12251
+ Rendered employees/_form.html.erb (1.6ms)
12252
+ Rendered employees/edit.html.erb within layouts/application (2.1ms)
12253
+ Completed 200 OK in 5ms (Views: 4.1ms | ActiveRecord: 0.2ms)
12254
+  (0.1ms) ROLLBACK
12255
+  (0.1ms) BEGIN
12256
+ -----------------------------------------------------
12257
+ EmployeesControllerTest: test_should_destroy_employee
12258
+ -----------------------------------------------------
12259
+  (0.1ms) SAVEPOINT active_record_1
12260
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.465018"], ["updated_at", "2016-04-29 08:57:00.465018"]]
12261
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12262
+  (0.1ms) SAVEPOINT active_record_1
12263
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.466228"], ["updated_at", "2016-04-29 08:57:00.466228"]]
12264
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12265
+  (0.2ms) SELECT COUNT(*) FROM "employees"
12266
+ Processing by EmployeesController#destroy as HTML
12267
+ Parameters: {"id"=>"643"}
12268
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 643]]
12269
+  (0.1ms) SAVEPOINT active_record_1
12270
+ SQL (0.1ms) DELETE FROM "employees" WHERE "employees"."id" = $1 [["id", 643]]
12271
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12272
+ Redirected to http://test.host/employees
12273
+ Completed 302 Found in 2ms (ActiveRecord: 0.4ms)
12274
+  (0.1ms) SELECT COUNT(*) FROM "employees"
12275
+  (0.1ms) ROLLBACK
12276
+  (0.1ms) BEGIN
12277
+ ---------------------------------------------
12278
+ EmployeesControllerTest: test_should_get_edit
12279
+ ---------------------------------------------
12280
+  (0.1ms) SAVEPOINT active_record_1
12281
+ SQL (0.2ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Stephen"], ["dob", "1963-08-13"], ["joined", "2014-04-01"], ["created_at", "2016-04-29 08:57:00.471347"], ["updated_at", "2016-04-29 08:57:00.471347"]]
12282
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12283
+  (0.1ms) SAVEPOINT active_record_1
12284
+ SQL (0.1ms) INSERT INTO "employees" ("name", "dob", "joined", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "Tony"], ["dob", "1965-05-17"], ["joined", "2014-05-21"], ["created_at", "2016-04-29 08:57:00.472497"], ["updated_at", "2016-04-29 08:57:00.472497"]]
12285
+  (0.1ms) RELEASE SAVEPOINT active_record_1
12286
+ Processing by EmployeesController#edit as HTML
12287
+ Parameters: {"id"=>"645"}
12288
+ Employee Load (0.1ms) SELECT "employees".* FROM "employees" WHERE "employees"."id" = $1 LIMIT 1 [["id", 645]]
12289
+ Rendered employees/_form.html.erb (1.4ms)
12290
+ Rendered employees/edit.html.erb within layouts/application (1.6ms)
12291
+ Completed 200 OK in 3ms (Views: 2.5ms | ActiveRecord: 0.1ms)
12292
+  (0.1ms) ROLLBACK
@@ -60,6 +60,13 @@ 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
+ test 'fieldset with error_class and supplied error messages' do
64
+ @employee.errors[:joined] << "invalid"
65
+ @employee.errors[:joined] << "must_be_in_past"
66
+ date_fields = GovUkDateFields::FormFields.new(@form_builder, :employee, :joined, {legend_text: 'Joining date', id: 'employee_date_joined', error_messages: ['Invalid joining date', 'Joining date must be in the past']})
67
+ assert_html_equal(date_fields.raw_output, expected_fieldset_output_with_error_class_and_message)
68
+ end
69
+
63
70
  test "squash_html" do
64
71
  html = " <html> This is some text \n <tr> \n <td> <%= dfkhdfh %> </td> </tr>\n</html> "
65
72
  expected_result = "<html>This is some text<tr><td><%= dfkhdfh %></td></tr></html>"
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.6
4
+ version: 1.0.7
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 00:00:00.000000000 Z
12
+ date: 2016-04-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails