Skip to content

Commit

Permalink
specs to ensure before_fork and after_fork are working
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Apr 4, 2010
1 parent b3df972 commit 764cba7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spec/backend/active_record_job_spec.rb
Expand Up @@ -35,5 +35,12 @@
ActiveRecord::Base.default_timezone = :local
%w(CST CDT).should include(Delayed::Backend::ActiveRecord::Job.db_time_now.zone)
end
end
end

describe "after_fork" do
it "should call reconnect on the connection" do
ActiveRecord::Base.connection.should_receive(:reconnect!)
Delayed::Backend::ActiveRecord::Job.after_fork
end
end
end
25 changes: 25 additions & 0 deletions spec/backend/mongo_mapper_job_spec.rb
Expand Up @@ -66,4 +66,29 @@ def tell
job.payload_object.perform.should == 'Epilog: Once upon a time...'
end
end

describe "before_fork" do
after do
MongoMapper.connection.connect_to_master
end

it "should disconnect" do
lambda do
Delayed::Backend::MongoMapper::Job.before_fork
end.should change { !!MongoMapper.connection.connected? }.from(true).to(false)
end
end

describe "after_fork" do
before do
MongoMapper.connection.close
end

it "should call reconnect" do
lambda do
Delayed::Backend::MongoMapper::Job.after_fork
end.should change { !!MongoMapper.connection.connected? }.from(false).to(true)
end
end

end

0 comments on commit 764cba7

Please sign in to comment.