schedular 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/schedular/event.rb +9 -5
- data/test/test_event.rb +4 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/schedular/event.rb
CHANGED
@@ -16,11 +16,15 @@ module Schedular
|
|
16
16
|
def dates= dates
|
17
17
|
parsed = Eventual.parse dates, :lang => I18n.locale
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if parsed
|
20
|
+
self.times = parsed.map do |time|
|
21
|
+
# TODO: This method is soooo uneficient
|
22
|
+
all_day = !(DateTime === time)
|
23
|
+
Schedular::Time.all_day(all_day).by_time_or_period(time).first || Schedular::Time.new(:value => time, :all_day => all_day)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
self.times = []
|
27
|
+
end
|
24
28
|
|
25
29
|
self['dates'] = dates
|
26
30
|
end
|
data/test/test_event.rb
CHANGED
@@ -13,9 +13,10 @@ class Schedular::EventTest < Test::Unit::TestCase
|
|
13
13
|
# should_validate_presence_of :dates
|
14
14
|
|
15
15
|
should 'not accept bad date' do
|
16
|
-
event
|
17
|
-
assert_equal false, event.valid?
|
18
|
-
assert_equal I18n.t('activerecord.errors.messages.invalid'), event.errors[:dates]
|
16
|
+
@event.dates = 'bad dates'
|
17
|
+
assert_equal false, @event.valid?
|
18
|
+
assert_equal I18n.t('activerecord.errors.messages.invalid'), @event.errors[:dates]
|
19
|
+
assert_equal true, @event.times.blank?
|
19
20
|
end
|
20
21
|
|
21
22
|
context 'times without time' do
|