Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Get rake test:oracle_enhanced running (but not passing :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Halasz committed May 27, 2011
1 parent aa7dc7b commit a05e49b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Expand Up @@ -3,14 +3,17 @@ source :gemcutter
gem "activerecord", "~> 3.0.0"

group :development do
gem "rake"
# http://stackoverflow.com/questions/6085610/rails-rake-problems-uninitialized-constant-rakedsl
gem "rake", "0.8.7"
gem "jeweler", ">= 1.4.0"
end

group :test do
# Database Adapters
gem "mysql", "~> 2.8.1"
gem "mysql2", "~> 0.2.4"
gem 'activerecord-oracle_enhanced-adapter', '>=1.3.1'
gem 'ruby-oci8'
gem "pg", "~> 0.9.0"
gem "sqlite3-ruby", "~> 1.3.1"

Expand Down
6 changes: 5 additions & 1 deletion Gemfile.lock
Expand Up @@ -10,6 +10,7 @@ GEM
activesupport (= 3.0.1)
arel (~> 1.0.0)
tzinfo (~> 0.3.23)
activerecord-oracle_enhanced-adapter (1.3.2)
activesupport (3.0.1)
archive-tar-minitar (0.5.2)
arel (1.0.1)
Expand Down Expand Up @@ -45,6 +46,7 @@ GEM
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby-oci8 (2.0.4)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
rubyforge (2.0.4)
Expand All @@ -57,13 +59,15 @@ PLATFORMS

DEPENDENCIES
activerecord (~> 3.0.0)
activerecord-oracle_enhanced-adapter (>= 1.3.1)
delorean (~> 0.2.0)
factory_girl (~> 1.3.3)
jeweler (>= 1.4.0)
mysql (~> 2.8.1)
mysql2 (~> 0.2.4)
pg (~> 0.9.0)
rake
rake (= 0.8.7)
ruby-debug (~> 0.9.3)
ruby-debug19
ruby-oci8
sqlite3-ruby (~> 1.3.1)
3 changes: 2 additions & 1 deletion Rakefile
@@ -1,3 +1,4 @@
require "rubygems"
require "bundler"
Bundler.setup

Expand Down Expand Up @@ -36,7 +37,7 @@ namespace :display do
end
task :default => ["display:notice"]

ADAPTERS = %w(mysql mysql2 postgresql sqlite3)
ADAPTERS = %w(mysql mysql2 oracle_enhanced postgresql sqlite3)
ADAPTERS.each do |adapter|
namespace :test do
desc "Runs #{adapter} database tests."
Expand Down
@@ -1,4 +1,4 @@
module ActiveRecord::Import::PostgreSQLAdapter
module ActiveRecord::Import::OracleEnhancedAdapter
module InstanceMethods
def self.included(klass)
klass.instance_eval do
Expand Down
5 changes: 2 additions & 3 deletions lib/activerecord-import/base.rb
Expand Up @@ -15,8 +15,7 @@ def self.require_adapter(adapter)
def self.load_from_connection(connection)
import_adapter = "ActiveRecord::Import::#{connection.class.name.demodulize}::InstanceMethods"
unless connection.class.ancestors.map(&:name).include?(import_adapter)
config = connection.instance_variable_get :@config
require_adapter config[:adapter]
require_adapter connection.adapter_name.underscore
end
end
end
Expand All @@ -25,4 +24,4 @@ def self.load_from_connection(connection)
this_dir = Pathname.new File.dirname(__FILE__)
require this_dir.join("import")
require this_dir.join("active_record/adapters/abstract_adapter")
require this_dir.join("synchronize")
require this_dir.join("synchronize")
1 change: 1 addition & 0 deletions test/adapters/oracle_enhanced.rb
@@ -0,0 +1 @@
ENV["ARE_DB"] = "oracle_enhanced"
7 changes: 4 additions & 3 deletions test/database.yml.sample
Expand Up @@ -19,9 +19,10 @@ postgresql:
adapter: postgresql
min_messages: warning

oracle:
<<: *common
adapter: oracle
oracle_enhanced:
adapter: oracle_enhanced
username: arimport
database: <tnsname>
min_messages: debug

sqlite:
Expand Down
20 changes: 20 additions & 0 deletions test/oracle_enhanced/import_test.rb
@@ -0,0 +1,20 @@
require File.expand_path('../../test_helper', __FILE__)

describe "#supports_imports?" do
it "should support import" do
assert ActiveRecord::Base.supports_import?
end
end

describe "#import" do
it "should import with a single insert" do
# see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics
assert_difference "Topic.count", +10 do
result = Topic.import Build(3, :topics)
assert_equal 1, result.num_inserts

result = Topic.import Build(7, :topics)
assert_equal 1, result.num_inserts
end
end
end

0 comments on commit a05e49b

Please sign in to comment.