Skip to content

Instantly share code, notes, and snippets.

@juno
Created March 12, 2014 07:12
Show Gist options
  • Select an option

  • Save juno/9502223 to your computer and use it in GitHub Desktop.

Select an option

Save juno/9502223 to your computer and use it in GitHub Desktop.

Revisions

  1. juno created this gist Mar 12, 2014.
    6 changes: 6 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    source 'https://rubygems.org'

    ruby '2.1.1'

    gem 'activerecord', '4.0.4.rc1'
    gem 'pg', '0.17.1'
    33 changes: 33 additions & 0 deletions active_record_gem.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # 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