govuk_content_models 14.0.0 → 14.0.1
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -32,6 +32,7 @@ class BusinessSupportEdition < Edition
|
|
32
32
|
|
33
33
|
GOVSPEAK_FIELDS = Edition::GOVSPEAK_FIELDS + [:body, :eligibility, :evaluation, :additional_information]
|
34
34
|
|
35
|
+
validate :scheme_dates
|
35
36
|
validate :min_must_be_less_than_max
|
36
37
|
validates_format_of :continuation_link, :with => URI::regexp(%w(http https)), :allow_blank => true
|
37
38
|
|
@@ -70,4 +71,13 @@ class BusinessSupportEdition < Edition
|
|
70
71
|
end
|
71
72
|
criteria
|
72
73
|
end
|
74
|
+
|
75
|
+
def scheme_dates
|
76
|
+
errors.add(:start_date, "year must be 4 digits") if start_date.present? && start_date.year.to_s.length != 4
|
77
|
+
errors.add(:end_date, "year must be 4 digits") if end_date.present? && end_date.year.to_s.length != 4
|
78
|
+
|
79
|
+
if start_date.present? && end_date.present? && start_date > end_date
|
80
|
+
errors.add(:start_date, "can't be later than end date")
|
81
|
+
end
|
82
|
+
end
|
73
83
|
end
|
data/app/models/edition.rb
CHANGED
@@ -217,4 +217,23 @@ class BusinessSupportEditionTest < ActiveSupport::TestCase
|
|
217
217
|
assert_empty editions
|
218
218
|
end
|
219
219
|
end
|
220
|
+
|
221
|
+
context "scheme dates" do
|
222
|
+
should "should have year with 4 digits length" do
|
223
|
+
invalid_edition = FactoryGirl.build(:business_support_edition, start_date: Date.new(99, 12, 31), end_date: Date.new(99, 12, 31))
|
224
|
+
|
225
|
+
refute invalid_edition.valid?
|
226
|
+
|
227
|
+
edition_errors = invalid_edition.errors.full_messages
|
228
|
+
assert_includes edition_errors, "Start date year must be 4 digits"
|
229
|
+
assert_includes edition_errors, "End date year must be 4 digits"
|
230
|
+
end
|
231
|
+
|
232
|
+
should "have start date earlier than end date" do
|
233
|
+
invalid_edition = FactoryGirl.build(:business_support_edition, start_date: 1.week.ago, end_date: 2.weeks.ago)
|
234
|
+
|
235
|
+
refute invalid_edition.valid?
|
236
|
+
assert_includes invalid_edition.errors.full_messages, "Start date can't be later than end date"
|
237
|
+
end
|
238
|
+
end
|
220
239
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_content_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.0.
|
4
|
+
version: 14.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson_ext
|
@@ -466,7 +466,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
466
466
|
version: '0'
|
467
467
|
segments:
|
468
468
|
- 0
|
469
|
-
hash:
|
469
|
+
hash: 2796015811550823768
|
470
470
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
471
471
|
none: false
|
472
472
|
requirements:
|
@@ -475,7 +475,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
475
475
|
version: '0'
|
476
476
|
segments:
|
477
477
|
- 0
|
478
|
-
hash:
|
478
|
+
hash: 2796015811550823768
|
479
479
|
requirements: []
|
480
480
|
rubyforge_project:
|
481
481
|
rubygems_version: 1.8.23
|