Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… a given queue
  • Loading branch information...
commit 97917711cebb1269e7bc7299797e87daadbfa496 1 parent 27b27f6
@flippingbits authored
View
4 lib/travis/notifications/worker/queue.rb
@@ -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)
View
11 spec_fast/travis/notifications/worker/queue_spec.rb
@@ -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
View
1  spec_fast/travis/notifications/worker_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.