hiccup 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiccup/validatable.rb +5 -5
- data/lib/hiccup/version.rb +1 -1
- data/test/validatable_test.rb +37 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f89546345663c8eebbbef1213af5d5936758ae
|
4
|
+
data.tar.gz: 8c399d781f9d76e59661c23be50226a9c333f704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47e2c586234b76c82b49e0af90a9b9538d4db20b13d2ee9256b50add794ee398e1a56d8cf9f46409561fe776ae162d15c9af039e4389fff1e51c95d82cd1e7c6
|
7
|
+
data.tar.gz: 4d4843ce6c366ce85b871f3af7be0652869a008883702756b1f07320d67fd6427abc844d92d90c929ee8a665adb14d3e40975f35e1a6eb0cb57b42ba6b2b1c67
|
data/lib/hiccup/validatable.rb
CHANGED
@@ -10,6 +10,7 @@ module Hiccup
|
|
10
10
|
|
11
11
|
# !todo: use ActiveModel:Validation rather than a custom method
|
12
12
|
included do
|
13
|
+
validates :skip, numericality: {greater_than: 0}
|
13
14
|
validate :validate_recurrence
|
14
15
|
end
|
15
16
|
|
@@ -27,13 +28,12 @@ module Hiccup
|
|
27
28
|
else; invalid_kind!
|
28
29
|
end
|
29
30
|
|
30
|
-
errors.add
|
31
|
-
errors.add(:skip, "is not a positive integer") unless (skip.is_a? Fixnum) and (skip > 0)
|
31
|
+
errors.add :start_date, "is a #{start_date.class} not a Date" unless start_date.is_a?(Date)
|
32
32
|
if ends?
|
33
|
-
if
|
34
|
-
errors.add
|
33
|
+
if end_date.is_a?(Date)
|
34
|
+
errors.add :end_date, "cannot be before start" if start_date.is_a?(Date) && end_date < start_date
|
35
35
|
else
|
36
|
-
errors.add
|
36
|
+
errors.add :end_date, "is a #{end_date.class} not a Date"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/hiccup/version.rb
CHANGED
data/test/validatable_test.rb
CHANGED
@@ -68,6 +68,43 @@ class ValidatableTest < ActiveSupport::TestCase
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
+
context "skip" do
|
72
|
+
should "be positive" do
|
73
|
+
schedule = Schedule.new
|
74
|
+
schedule.skip = -5
|
75
|
+
schedule.valid?
|
76
|
+
assert schedule.errors[:skip].any?, "Expected skip to be invalid"
|
77
|
+
end
|
78
|
+
|
79
|
+
should "be present" do
|
80
|
+
schedule = Schedule.new
|
81
|
+
schedule.skip = nil
|
82
|
+
schedule.valid?
|
83
|
+
assert schedule.errors[:skip].any?, "Expected skip to be invalid"
|
84
|
+
end
|
85
|
+
|
86
|
+
should "be nonzero" do
|
87
|
+
schedule = Schedule.new
|
88
|
+
schedule.skip = 0
|
89
|
+
schedule.valid?
|
90
|
+
assert schedule.errors[:skip].any?, "Expected skip to be invalid"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
context "When an end_date is supplied but not a start_date, it" do
|
97
|
+
should "record an error for the start_date but not for end_date" do
|
98
|
+
schedule = Schedule.new(kind: :weekly, ends: true, end_date: Date.today)
|
99
|
+
schedule.start_date = nil
|
100
|
+
refute schedule.valid?
|
101
|
+
assert schedule.errors[:start_date].any?
|
102
|
+
refute schedule.errors[:end_date].any?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
|
71
108
|
private
|
72
109
|
|
73
110
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiccup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Lail
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|