-
Notifications
You must be signed in to change notification settings - Fork 152
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
detect Rails DB connection and use it #232
Merged
jipiboily
merged 9 commits into
QueueClassic:master
from
jipiboily:detect-rails-db-connection
Oct 10, 2014
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
04391ab
add detection of ActiveRecord connection and use it
jipiboily 620d47d
add WIP test for ActiveRecord connection detection
jipiboily db4b5ce
add spec for ActiveRecord connection detection
jipiboily 8988b20
make ActiveRecord detection work on Ruby 2.0.x
jipiboily d709479
update README with Rails DB connection detection
jipiboily 7af4496
remove useless ensure
jipiboily e2408d3
add QC_RAILS_DATABASE to disable conn detection
jipiboily 8e3c69f
add note in README regarding Active Job
jipiboily be9c54a
Merge branch 'master' into detect-rails-db-connection
jipiboily File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require File.expand_path("../../helper.rb", __FILE__) | ||
|
||
class QueueClassicRailsConnectionTest < QCTest | ||
def before_setup | ||
Object.send :const_set, :ActiveRecord, Module.new | ||
ActiveRecord.const_set :Base, Module.new | ||
|
||
QC.default_conn_adapter = nil | ||
end | ||
|
||
def after_teardown | ||
ensure | ||
ActiveRecord.send :remove_const, :Base | ||
Object.send :remove_const, :ActiveRecord | ||
end | ||
|
||
def test_uses_active_record_connection_if_exists | ||
connection = Minitest::Mock.new | ||
connection.expect(:raw_connection, QC::ConnAdapter.new.connection) | ||
|
||
ActiveRecord::Base.define_singleton_method(:connection) do | ||
connection | ||
end | ||
|
||
QC.default_conn_adapter | ||
assert connection.verify | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need the unsure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! I don't remember...I'll test and if it's required, I'll document the reason.