Skip to content

Instantly share code, notes, and snippets.

@arthurnn
Created January 12, 2015 19:59
Show Gist options
  • Save arthurnn/57e789ae1ac8297f47bd to your computer and use it in GitHub Desktop.
Save arthurnn/57e789ae1ac8297f47bd to your computer and use it in GitHub Desktop.
require 'active_record'
require 'minitest/autorun'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
#ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'test', username: 'root')
#ActiveRecord::Base.establish_connection(adapter: "postgresql", host: "localhost", user: "postgres", database: "test")
p ActiveRecord.version
ActiveRecord::Base.logger = Logger.new(STDOUT)
class Post < ActiveRecord::Base
connection.create_table table_name, force: true do
end
end
class BugTest < MiniTest::Unit::TestCase
def test_bug
Post.create!
assert_not_nil Post.find :first
end
end
@arthurnn
Copy link
Author

result:

  1) Error:
BugTest#test_bug:
ActiveRecord::RecordNotFound: Couldn't find Post with 'id'=first
    /Users/arthurnn/dev/rails/activerecord/lib/active_record/relation/finder_methods.rb:320:in `raise_record_not_found_exception!'
    /Users/arthurnn/dev/rails/activerecord/lib/active_record/relation/finder_methods.rb:429:in `find_one'
    /Users/arthurnn/dev/rails/activerecord/lib/active_record/relation/finder_methods.rb:413:in `find_with_ids'
    /Users/arthurnn/dev/rails/activerecord/lib/active_record/relation/finder_methods.rb:68:in `find'
    /Users/arthurnn/dev/rails/activerecord/lib/active_record/querying.rb:3:in `find'
    gistfile_2.rb:19:in `test_bug'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment