Skip to content

Instantly share code, notes, and snippets.

@yahonda
Created February 12, 2016 15:32
Show Gist options
  • Save yahonda/f4d5d2102c3e9e3cf22e to your computer and use it in GitHub Desktop.
Save yahonda/f4d5d2102c3e9e3cf22e to your computer and use it in GitHub Desktop.
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '4.2.5'
gem 'activerecord-oracle_enhanced-adapter', '1.6.5'
gem 'ruby-oci8'
gem 'minitest'
gem 'byebug'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
require 'active_record/connection_adapters/oracle_enhanced_adapter'
require 'byebug'
# 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.default_timezone = :local
ActiveRecord::Base.default_timezone = :utc
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :events, :force => true do |t|
t.string :title, :limit => 5
end
end
class Event < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_validate_uniqueness_with_limit
e1 = Event.create(:title => "abcde")
assert e1.valid?
assert_raises(ActiveRecord::StatementInvalid) do
e2 = Event.create!(:title => "abcdefgh")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment