mobilize-base 1.378 → 1.379

Sign up to get free protection for your applications and to get access to all the features.
@@ -125,22 +125,8 @@ module Mobilize
125
125
  else
126
126
  return false
127
127
  end
128
- elsif unit == "day_of_week"
129
- if curr_time.wday==number and (last_comp_time.nil? or last_comp_time.to_date != curr_time.to_date)
130
- if mark
131
- #check if it already ran today
132
- last_mark_time = Time.at_marks_ago(1,"day",mark)
133
- if last_comp_time < last_mark_time
134
- return true
135
- else
136
- return false
137
- end
138
- else
139
- return true
140
- end
141
- end
142
128
  elsif unit == "day_of_month"
143
- if curr_time.day==number and (last_comp_time.nil? or last_comp_time.to_date != curr_time.to_date)
129
+ if curr_time.day==number.to_i and (last_comp_time.nil? or last_comp_time.to_date != curr_time.to_date)
144
130
  if mark
145
131
  #check if it already ran today
146
132
  last_mark_time = Time.at_marks_ago(1,"day",mark)
@@ -1,5 +1,5 @@
1
1
  module Mobilize
2
2
  module Base
3
- VERSION = "1.378"
3
+ VERSION = "1.379"
4
4
  end
5
5
  end
@@ -31,4 +31,6 @@ Gem::Specification.new do |s|
31
31
  s.add_runtime_dependency 'google_drive','0.3.2'
32
32
  s.add_runtime_dependency 'popen4','0.1.2'
33
33
  s.add_runtime_dependency 'actionmailer','3.1.1'
34
+
35
+ s.add_development_dependency 'mocha'
34
36
  end
@@ -89,3 +89,33 @@
89
89
  parent: {completed_at: Time.now.utc - 1.second}
90
90
  completed_at: Time.now.utc
91
91
  expected: false
92
+ - name: day_of_month
93
+ active: true
94
+ trigger: 'every 1.day_of_month'
95
+ status: ""
96
+ stage1: gsheet.method source:"source", target:"target"
97
+ now: Time.utc(2013,9,1)
98
+ expected: true
99
+ - name: not_day_of_month
100
+ active: true
101
+ trigger: 'every 1.day_of_month'
102
+ status: ""
103
+ stage1: gsheet.method source:"source", target:"target"
104
+ now: Time.utc(2013,9,2)
105
+ expected: false
106
+ - name: day_of_month_aft0100_comp_1monthago
107
+ active: true
108
+ trigger: 'every 1.day_of_month after 01:00'
109
+ status: ""
110
+ stage1: gsheet.method source:"source", target:"target"
111
+ now: Time.utc(2013,9,1,1,30)
112
+ completed_at: Time.utc(2013,8,1,1,15)
113
+ expected: true
114
+ - name: day_of_month_aft0100_comp0115
115
+ active: true
116
+ trigger: 'every 1.day_of_month after 01:00'
117
+ status: ""
118
+ stage1: gsheet.method source:"source", target:"target"
119
+ now: Time.utc(2013,9,1,1,30)
120
+ completed_at: Time.utc(2013,9,1,1,15)
121
+ expected: false
@@ -1,34 +1,46 @@
1
1
  require 'test_helper'
2
+ require 'mocha/setup'
3
+
2
4
  class TestUnit < MiniTest::Unit::TestCase
3
- def setup
5
+ def self.test_order
6
+ :sorted
7
+ end
8
+
9
+ def self.setup_test
4
10
  TestHelper.restart_test_redis
5
11
  TestHelper.drop_test_db
6
12
  end
7
13
 
8
- #this test checks that several job triggers work as expected
9
- def test_is_due
14
+ def self.define_tests(fixture)
10
15
  u = TestHelper.owner_user
11
- job_hashes = TestHelper.load_fixture("is_due")
12
- job_hashes.each do |jh|
13
- job_path = "#{u.runner.path}/#{jh['name']}"
14
- j = Mobilize::Job.find_or_create_by_path(job_path)
15
- #update job params
16
- j.update_from_hash(jh)
17
- #apply the completed_at, failed at, and parent attributes where appropriate
18
- if jh['completed_at']
19
- j.stages.last.update_attributes(:completed_at=>eval(jh['completed_at']))
16
+ TestHelper.load_fixture(fixture).each_with_index do |jh, i|
17
+ name = "%03d_%s" % [i, jh['name']]
18
+ define_method(:"test_#{name}") do
19
+ job_path = "#{u.runner.path}/#{jh['name']}"
20
+ j = Mobilize::Job.find_or_create_by_path(job_path)
21
+ #update job params
22
+ j.update_from_hash(jh)
23
+ #apply the completed_at, failed at, and parent attributes where appropriate
24
+ if jh['completed_at']
25
+ j.stages.last.update_attributes(:completed_at=>eval(jh['completed_at']))
26
+ end
27
+ if jh['failed_at']
28
+ j.stages.last.update_attributes(:failed_at=>eval(jh['failed_at']))
29
+ end
30
+ if jh['parent']
31
+ j.parent.stages.last.update_attributes(:completed_at=>eval(jh['parent']['completed_at'])) if jh['parent']['completed_at']
32
+ j.parent.stages.last.update_attributes(:failed_at=>eval(jh['parent']['failed_at'])) if jh['parent']['failed_at']
33
+ end
34
+ if jh['now']
35
+ Time.stubs(:now).returns(eval(jh['now']))
36
+ end
37
+ expected = jh['expected']
38
+ #check if is_due
39
+ assert expected == j.is_due?
20
40
  end
21
- if jh['failed_at']
22
- j.stages.last.update_attributes(:failed_at=>eval(jh['failed_at']))
23
- end
24
- if jh['parent']
25
- j.parent.stages.last.update_attributes(:completed_at=>eval(jh['parent']['completed_at'])) if jh['parent']['completed_at']
26
- j.parent.stages.last.update_attributes(:failed_at=>eval(jh['parent']['failed_at'])) if jh['parent']['failed_at']
27
- end
28
- expected = jh['expected']
29
- #check if is_due
30
- puts "checking #{j.name}"
31
- assert expected == j.is_due?
32
41
  end
33
42
  end
43
+
44
+ setup_test
45
+ define_tests("is_due")
34
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobilize-base
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.378'
4
+ version: '1.379'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-12 00:00:00.000000000 Z
13
+ date: 2013-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -156,6 +156,22 @@ dependencies:
156
156
  - - '='
157
157
  - !ruby/object:Gem::Version
158
158
  version: 3.1.1
159
+ - !ruby/object:Gem::Dependency
160
+ name: mocha
161
+ requirement: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
159
175
  description: ! "Manage your organization's workflows entirely through Google Docs
160
176
  and irb.\n Mobilize schedules jobs, queues workers, sends failure
161
177
  notifications, and\n integrates mobilize-hadoop, -http, -mysql,
@@ -237,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
253
  version: '0'
238
254
  segments:
239
255
  - 0
240
- hash: -2038085441569804169
256
+ hash: -754745545664310301
241
257
  required_rubygems_version: !ruby/object:Gem::Requirement
242
258
  none: false
243
259
  requirements:
@@ -246,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
262
  version: '0'
247
263
  segments:
248
264
  - 0
249
- hash: -2038085441569804169
265
+ hash: -754745545664310301
250
266
  requirements: []
251
267
  rubyforge_project: mobilize-base
252
268
  rubygems_version: 1.8.23