Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #26 from BDQ/mysql2

Fix issues with mysql2 support
  • Loading branch information...
commit 0b678f5f4fdad768b9c7ef0d489750a8ac0627b2 2 parents 34fa856 + 2412614
@bradrobertson bradrobertson authored
View
14 lib/apartment/adapters/mysql_adapter.rb → lib/apartment/adapters/mysql2_adapter.rb
@@ -1,16 +1,16 @@
module Apartment
module Database
-
+
def self.mysql2_adapter(config)
- Adapters::MysqlAdapter.new config
+ Adapters::Mysql2Adapter.new config
end
end
-
+
module Adapters
-
- class MysqlAdapter < AbstractAdapter
-
+
+ class Mysql2Adapter < AbstractAdapter
+
protected
# Connect to new database
@@ -26,4 +26,4 @@ def connect_to_new(database)
end
end
end
-end
+end
View
14 spec/adapters/mysql_adapter_spec.rb → spec/adapters/mysql2_adapter_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
-require 'apartment/adapters/mysql_adapter'
+require 'apartment/adapters/mysql2_adapter'
+
+describe Apartment::Adapters::Mysql2Adapter do
-describe Apartment::Adapters::MysqlAdapter do
-
let(:config){ Apartment::Test.config['connections']['mysql'] }
subject{ Apartment::Database.mysql2_adapter config.symbolize_keys }
-
+
def database_names
ActiveRecord::Base.connection.execute("SELECT schema_name FROM information_schema.schemata").collect{|row| row[0]}
end
-
+
let(:default_database){ subject.process{ ActiveRecord::Base.connection.current_database } }
-
+
it_should_behave_like "a generic apartment adapter"
it_should_behave_like "a db based apartment adapter"
-end
+end
View
27 spec/database_spec.rb
@@ -1,7 +1,30 @@
require 'spec_helper'
describe Apartment::Database do
-
+ context "using mysql" do
+ # See apartment.yml file in dummy app config
+
+ let(:config){ Apartment::Test.config['connections']['mysql'].symbolize_keys }
+
+ before do
+ ActiveRecord::Base.establish_connection config
+ Apartment::Test.load_schema # load the Rails schema in the public db schema
+ subject.stub(:config).and_return config # Use postgresql database config for this test
+ end
+
+ describe "#adapter" do
+ before do
+ subject.reload!
+ end
+
+ it "should load mysql adapter" do
+ subject.adapter
+ Apartment::Adapters::Mysql2Adapter.should be_a(Class)
+ end
+
+ end
+ end
+
context "using postgresql" do
# See apartment.yml file in dummy app config
@@ -107,4 +130,4 @@
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.