spec/spec_helper.rb in resque-restriction-0.1.0 vs spec/spec_helper.rb in resque-restriction-0.2.0
- old
+ new
@@ -26,11 +26,11 @@
next if $!
exit_code = Spec::Runner.run
pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
- puts "Killing test redis server..."
+ puts "Killing test redis server [#{pid}]..."
`rm -f #{dir}/dump.rdb`
Process.kill("KILL", pid.to_i)
exit exit_code
end
@@ -61,9 +61,32 @@
restrict :per_hour => 10
@queue = 'normal'
def self.perform(args)
+ end
+end
+
+class IdentifiedRestrictionJob < Resque::Plugins::RestrictionJob
+ restrict :per_hour => 10
+
+ @queue = 'normal'
+
+ def self.identifier(*args)
+ [self.to_s, args.first].join(":")
+ end
+
+ def self.perform(*args)
+ end
+end
+
+class ConcurrentRestrictionJob < Resque::Plugins::RestrictionJob
+ restrict :concurrent => 1
+
+ @queue = 'normal'
+
+ def self.perform(*args)
+ sleep 0.2
end
end
class MultipleRestrictionJob < Resque::Plugins::RestrictionJob
restrict :per_hour => 10, :per_300 => 2