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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb92bb351bb70b127d803017a755fbb60486e493
4
- data.tar.gz: b16ac99ffe79acf0874df41d347b23820fbf395c
3
+ metadata.gz: 31f89546345663c8eebbbef1213af5d5936758ae
4
+ data.tar.gz: 8c399d781f9d76e59661c23be50226a9c333f704
5
5
  SHA512:
6
- metadata.gz: 4dfff15d9adb485161d7bc857e25a8836ad255d4bd9a49aaa8c1bd6a52eac5d25ace2ebca34ae5c2306bf7aad74477242b2c221eab4bbc9f47568bd838753dde
7
- data.tar.gz: b972f70010604a6d1e7463351b6f60bf58ab1d8167101e0bed45ba9d033cb0cb4167fe7e8495be49fc0ca76d29a1d1808eac6452950e4d1bb00b722aadf7abb2
6
+ metadata.gz: 47e2c586234b76c82b49e0af90a9b9538d4db20b13d2ee9256b50add794ee398e1a56d8cf9f46409561fe776ae162d15c9af039e4389fff1e51c95d82cd1e7c6
7
+ data.tar.gz: 4d4843ce6c366ce85b871f3af7be0652869a008883702756b1f07320d67fd6427abc844d92d90c929ee8a665adb14d3e40975f35e1a6eb0cb57b42ba6b2b1c67
@@ -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(:start_date, "is a #{self.start_date.class} not a Date") unless self.start_date.is_a?(Date)
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 self.end_date.is_a? Date
34
- errors.add(:end_date, "cannot be before start") if (self.end_date < self.start_date)
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(:end_date, "is a #{self.end_date.class} not a Date")
36
+ errors.add :end_date, "is a #{end_date.class} not a Date"
37
37
  end
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module Hiccup
2
- VERSION = "0.5.9"
2
+ VERSION = "0.5.10"
3
3
  end
@@ -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.9
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-18 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport