Skip to content

Commit b2d2998

Browse files
vangbergdefunkt
authored andcommitted
define test jobs in the scope of Object, for 1.9-compat
in 1.8 constants defined in an anonymous class leaks through to the Object scope. in 1.9 they are (properly) defined on the anonymous class [see 1]. this commit defines all test jobs unambiguously on Object, otherwise tests fails with errors like "wrong constant name #<Class:0x000001010b61d0>" 1) http://gist.github.com/441924
1 parent 98e33e8 commit b2d2998

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

test/job_hooks_test.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
context "Resque::Job before_perform" do
44
include PerformJob
55

6-
class BeforePerformJob
6+
class ::BeforePerformJob
77
def self.before_perform_record_history(history)
88
history << :before_perform
99
end
@@ -19,7 +19,7 @@ def self.perform(history)
1919
assert_equal history, [:before_perform, :perform]
2020
end
2121

22-
class BeforePerformJobFails
22+
class ::BeforePerformJobFails
2323
def self.before_perform_fail_job(history)
2424
history << :before_perform
2525
raise StandardError
@@ -37,7 +37,7 @@ def self.perform(history)
3737
assert_equal history, [:before_perform], "Only before_perform was run"
3838
end
3939

40-
class BeforePerformJobAborts
40+
class ::BeforePerformJobAborts
4141
def self.before_perform_abort(history)
4242
history << :before_perform
4343
raise Resque::Job::DontPerform
@@ -57,7 +57,7 @@ def self.perform(history)
5757
context "Resque::Job after_perform" do
5858
include PerformJob
5959

60-
class AfterPerformJob
60+
class ::AfterPerformJob
6161
def self.perform(history)
6262
history << :perform
6363
end
@@ -72,7 +72,7 @@ def self.after_perform_record_history(history)
7272
assert_equal history, [:perform, :after_perform]
7373
end
7474

75-
class AfterPerformJobFails
75+
class ::AfterPerformJobFails
7676
def self.perform(history)
7777
history << :perform
7878
end
@@ -94,7 +94,7 @@ def self.after_perform_fail_job(history)
9494
context "Resque::Job around_perform" do
9595
include PerformJob
9696

97-
class AroundPerformJob
97+
class ::AroundPerformJob
9898
def self.perform(history)
9999
history << :perform
100100
end
@@ -111,7 +111,7 @@ def self.around_perform_record_history(history)
111111
assert_equal history, [:start_around_perform, :perform, :finish_around_perform]
112112
end
113113

114-
class AroundPerformJobFailsBeforePerforming
114+
class ::AroundPerformJobFailsBeforePerforming
115115
def self.perform(history)
116116
history << :perform
117117
end
@@ -131,7 +131,7 @@ def self.around_perform_fail(history)
131131
assert_equal history, [:start_around_perform], "Only part of around_perform was run"
132132
end
133133

134-
class AroundPerformJobFailsWhilePerforming
134+
class ::AroundPerformJobFailsWhilePerforming
135135
def self.perform(history)
136136
history << :perform
137137
raise StandardError
@@ -155,7 +155,7 @@ def self.around_perform_fail_in_yield(history)
155155
assert_equal history, [:start_around_perform, :perform, :ensure_around_perform], "Only part of around_perform was run"
156156
end
157157

158-
class AroundPerformJobDoesNotHaveToYield
158+
class ::AroundPerformJobDoesNotHaveToYield
159159
def self.perform(history)
160160
history << :perform
161161
end
@@ -176,7 +176,7 @@ def self.around_perform_dont_yield(history)
176176
context "Resque::Job on_failure" do
177177
include PerformJob
178178

179-
class FailureJobThatDoesNotFail
179+
class ::FailureJobThatDoesNotFail
180180
def self.perform(history)
181181
history << :perform
182182
end
@@ -191,7 +191,7 @@ def self.on_failure_record_failure(exception, history)
191191
assert_equal history, [:perform]
192192
end
193193

194-
class FailureJobThatFails
194+
class ::FailureJobThatFails
195195
def self.perform(history)
196196
history << :perform
197197
raise StandardError, "oh no"
@@ -209,7 +209,7 @@ def self.on_failure_record_failure(exception, history)
209209
assert_equal history, [:perform, "oh no"]
210210
end
211211

212-
class FailureJobThatFailsBadly
212+
class ::FailureJobThatFailsBadly
213213
def self.perform(history)
214214
history << :perform
215215
raise SyntaxError, "oh no"
@@ -231,7 +231,7 @@ def self.on_failure_record_failure(exception, history)
231231
context "Resque::Job all hooks" do
232232
include PerformJob
233233

234-
class VeryHookyJob
234+
class ::VeryHookyJob
235235
def self.before_perform_record_history(history)
236236
history << :before_perform
237237
end
@@ -263,7 +263,7 @@ def self.on_failure_record_history(exception, history)
263263
]
264264
end
265265

266-
class VeryHookyJobThatFails
266+
class ::VeryHookyJobThatFails
267267
def self.before_perform_record_history(history)
268268
history << :before_perform
269269
end

test/job_plugins_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def after_perform_record_history2(history)
2121
end
2222
end
2323

24-
class ManyBeforesJob
24+
class ::ManyBeforesJob
2525
extend Plugin1
2626
extend Plugin2
2727
def self.perform(history)
@@ -45,7 +45,7 @@ def before_perform1(history)
4545
end
4646
end
4747

48-
class BeforePerformJob
48+
class ::BeforePerformJob
4949
extend BeforePerformPlugin
5050
def self.perform(history)
5151
history << :perform
@@ -71,7 +71,7 @@ def after_perform_record_history(history)
7171
end
7272
end
7373

74-
class AfterPerformJob
74+
class ::AfterPerformJob
7575
extend AfterPerformPlugin
7676
def self.perform(history)
7777
history << :perform
@@ -98,7 +98,7 @@ def around_perform1(history)
9898
end
9999
end
100100

101-
class AroundPerformJustPerformsJob
101+
class ::AroundPerformJustPerformsJob
102102
extend AroundPerformPlugin1
103103
def self.perform(history)
104104
history << :perform
@@ -111,7 +111,7 @@ def self.perform(history)
111111
assert_equal [:around_perform_plugin1, :perform], history
112112
end
113113

114-
class AroundPerformJob
114+
class ::AroundPerformJob
115115
extend AroundPerformPlugin1
116116
def self.perform(history)
117117
history << :perform
@@ -135,7 +135,7 @@ def around_perform2(history)
135135
end
136136
end
137137

138-
class AroundPerformJob2
138+
class ::AroundPerformJob2
139139
extend AroundPerformPlugin1
140140
extend AroundPerformPlugin2
141141
def self.perform(history)
@@ -159,7 +159,7 @@ def around_perform0(history)
159159
end
160160
end
161161

162-
class AroundPerformJob3
162+
class ::AroundPerformJob3
163163
extend AroundPerformPlugin1
164164
extend AroundPerformPlugin2
165165
extend AroundPerformDoesNotYield
@@ -189,7 +189,7 @@ def around_perform_gets_job_result(*args)
189189
end
190190
end
191191

192-
class AroundPerformJobWithReturnValue < GoodJob
192+
class ::AroundPerformJobWithReturnValue < GoodJob
193193
extend AroundPerformGetsJobResult
194194
end
195195

@@ -209,7 +209,7 @@ def on_failure1(exception, history)
209209
end
210210
end
211211

212-
class FailureJob
212+
class ::FailureJob
213213
extend OnFailurePlugin
214214
def self.perform(history)
215215
history << :perform

test/plugin_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ def on_failure2; end
3636
end
3737

3838
context "Resque::Plugin linting" do
39-
module BadBefore
39+
module ::BadBefore
4040
def self.before_perform; end
4141
end
42-
module BadAfter
42+
module ::BadAfter
4343
def self.after_perform; end
4444
end
45-
module BadAround
45+
module ::BadAround
4646
def self.around_perform; end
4747
end
48-
module BadFailure
48+
module ::BadFailure
4949
def self.on_failure; end
5050
end
5151

0 commit comments

Comments
 (0)