Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for resque-heroku disconnecting DB #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/resque_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
module ResqueSpec
extend self

attr_accessor :inline
attr_reader :inline
attr_accessor :disable_ext

def inline=(value)
Resque.inline = value
@inline = value
end

def dequeue(queue_name, klass, *args)
queue_by_name(queue_name).delete_if do |job|
job[:class] == klass.to_s && args.empty? || job[:args] == args
Expand Down Expand Up @@ -80,7 +85,10 @@ def new_job(queue_name, payload)
end

def perform(queue_name, payload)
original = Resque.inline
Resque.inline = true
new_job(queue_name, payload).perform
Resque.inline = original
end

def perform_or_store(queue_name, payload)
Expand Down
8 changes: 8 additions & 0 deletions spec/resque_spec/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
end
ResqueSpec.inline.should eq status
end

it "sets Resque.inline as #{status} when inside the block" do
ResqueSpec.inline = status
with_resque do
Resque.inline.should eq true
end
Resque.inline.should eq status
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/resque_spec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
}.not_to change(NameFromClassMethod, :invocations)
end

it "sets Resque.inline to false" do
expect(Resque.inline).to be_false
end

it "does not change the behavior of enqueue" do
ResqueSpec.enqueue(:queue_name, NameFromClassMethod, 1)
ResqueSpec.queue_by_name(:queue_name).should include({ class: NameFromClassMethod.to_s, args: [1] })
Expand All @@ -92,6 +96,10 @@
}.to change(NameFromClassMethod, :invocations).by(1)
end

it "sets Resque.inline to true" do
expect(Resque.inline).to be_true
end

it "does not enqueue" do
ResqueSpec.enqueue(:queue_name, NameFromClassMethod, 1)
ResqueSpec.queue_by_name(:queue_name).should be_empty
Expand Down Expand Up @@ -279,6 +287,7 @@
ResqueSpec.inline = true
ResqueSpec.reset!
ResqueSpec.inline.should be_false
Resque.inline.should be_false
end
end
end