Skip to content

Instantly share code, notes, and snippets.

@juno
Created March 12, 2014 07:12
Show Gist options
  • Save juno/9502223 to your computer and use it in GitHub Desktop.
Save juno/9502223 to your computer and use it in GitHub Desktop.
Regression test template for activerecord.gem with PostgreSQL. Borrowed from https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.4.rc1'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection('postgres://username:password@hostname/dbname')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.string :tags, array: true, default: '{}'
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_empty_array_member
post = Post.create!
post.tags = ['foo', 'bar', 'baz', '']
post.save!
post.reload
assert_equal 4, post.tags.count
end
end
source 'https://rubygems.org'
ruby '2.1.1'
gem 'activerecord', '4.0.4.rc1'
gem 'pg', '0.17.1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment