Created
March 12, 2014 07:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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