Skip to content

Instantly share code, notes, and snippets.

@koic
Created January 5, 2016 04:40
Show Gist options
  • Save koic/384b40709cf35e9eceeb to your computer and use it in GitHub Desktop.
Save koic/384b40709cf35e9eceeb to your computer and use it in GitHub Desktop.
Test case of AR 4.2.5 and Oracle (oracle-enhanced/issues/755)
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.2.5'
gem 'activerecord-oracle_enhanced-adapter', '1.6.5'
require 'active_record'
require 'minitest/autorun'
require 'logger'
require 'active_record/connection_adapters/oracle_enhanced_adapter'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# Set Oracle enhanced adapter specific connection parameters
DATABASE_NAME = ENV['DATABASE_NAME'] || 'orcl'
DATABASE_HOST = ENV['DATABASE_HOST']
DATABASE_PORT = ENV['DATABASE_PORT']
DATABASE_USER = ENV['DATABASE_USER'] || 'oracle_enhanced'
DATABASE_PASSWORD = ENV['DATABASE_PASSWORD'] || 'oracle_enhanced'
DATABASE_SYS_PASSWORD = ENV['DATABASE_SYS_PASSWORD'] || 'admin'
CONNECTION_PARAMS = {
:adapter => "oracle_enhanced",
:database => DATABASE_NAME,
:host => DATABASE_HOST,
:port => DATABASE_PORT,
:username => DATABASE_USER,
:password => DATABASE_PASSWORD
}
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, :force => true do |t|
t.timestamps null: false
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_find_by_created_at
post = Post.create!
created_at = post.created_at
assert_equal post, Post.find_by(created_at: created_at)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment