Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test connection to mysql properly

  • Loading branch information...
commit 735bc6d3d892f618f988faf17f99df921c45f02c 1 parent ddf62e0
@qrush qrush authored
View
2  Gemfile.lock
@@ -36,6 +36,7 @@ GEM
hike (1.2.1)
i18n (0.6.0)
multi_json (1.1.0)
+ mysql (2.8.1)
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
@@ -55,5 +56,6 @@ PLATFORMS
ruby
DEPENDENCIES
+ mysql
query_comments!
rake
View
1  query_comments.gemspec
@@ -13,6 +13,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency "actionpack", ">= 2.3", "<= 3.2"
gem.add_runtime_dependency "activerecord", ">= 2.3", "<= 3.2"
gem.add_development_dependency "rake"
+ gem.add_development_dependency "mysql"
gem.summary = description = %q{Attach comments to your ActiveRecord queries.}
end
View
27 test/query_comments_test.rb
@@ -11,16 +11,19 @@
:database => "query_comments_test"
})
-#ActiveSupport::LogSubscriber.colorize_logging = false
-#ActiveRecord::Base.logger = Logger.new(STDOUT)
-
class Post < ActiveRecord::Base
end
+class PostsController < ActionController::Base
+ def driver_only
+ ActiveRecord::Base.connection.execute "select id from posts"
+ render :nothing => true
+ end
+end
+
unless Post.table_exists?
ActiveRecord::Schema.define do
create_table "posts", :force => true do |t|
- t.string "body"
end
end
end
@@ -33,10 +36,20 @@ def setup
ActiveSupport::Notifications.subscribe "sql.active_record" do |*args|
@queries << args.last[:sql]
end
+ @env = Rack::MockRequest.env_for('/')
+ end
+
+ def test_query_commenting_on_mysql_driver_with_no_action
+ ActiveRecord::Base.connection.execute "select id from posts"
+ assert_match %r{select id from posts /\*\*/$}, @queries.first
+ end
+
+ def test_query_commenting_on_mysql_driver_with_action
+ PostsController.action(:driver_only).call(@env)
+ assert_match %r{select id from posts /\*application:BCX,controller:posts,action:driver_only\*/$}, @queries.first
end
- def test_blank_query
- Post.count
- assert_match %r{/\*\*/}, @queries.first
+ def teardown
+ ActiveSupport::Notifications.unsubscribe "sql.active_record"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.