Permalink
Browse files

Add Travis::Notifications::Worker.Queue#jobs that returns the jobs of…

… a given queue
  • Loading branch information...
1 parent 27b27f6 commit 97917711cebb1269e7bc7299797e87daadbfa496 @flippingbits committed Nov 6, 2011
@@ -16,6 +16,10 @@ def queue
name
end
+ def jobs
+ Job.queued.select { |job| Worker.queue_for(job).try(:name) == name }
+ end
+
protected
def matches_slug?(slug)
@@ -8,6 +8,7 @@ def queue(*args)
Travis::Notifications::Worker::Queue.new(*args)
end
+ let(:ruby) { queue('ruby', nil, nil, nil) }
let(:rails) { queue('rails', 'rails/rails', nil) }
let(:erlang) { queue('erlang', nil, 'erlang', nil) }
let(:clojure) { queue('builds', nil, nil, 'clojure') }
@@ -33,6 +34,16 @@ def queue(*args)
erlang.matches?('foo/bar', 'worker-on-mars', 'COBOL').should be_false
end
end
+
+ describe "#jobs" do
+ let(:test) { Factory.create(:test) }
+
+ it "returns jobs that are matching the queue" do
+ test.start!
+ ruby.jobs.should have(1).item
+ ruby.jobs.should include(test)
+ end
+ end
end
@@ -11,6 +11,7 @@
{ :queue => 'builds', :language => 'clojure' },
{ :queue => 'erlang', :target => 'erlang', :language => 'erlang' },
]
+ Travis::Notifications::Worker.instance_variable_set("@queues", nil)
end
after do

0 comments on commit 9791771

Please sign in to comment.