dump IO encoding value along with schema.rb so the file can be reloaded. fixes #1592

This commit is contained in:
Aaron Patterson
2011-07-29 12:23:37 -07:00
parent f2ade6f4b0
commit 4e1f6ab6f6
2 changed files with 16 additions and 3 deletions

View File

@@ -40,6 +40,10 @@ module ActiveRecord
def header(stream)
define_params = @version ? ":version => #{@version}" : ""
if stream.respond_to?(:external_encoding)
stream.puts "# encoding: #{stream.external_encoding.name}"
end
stream.puts <<HEADER
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to

View File

@@ -3,11 +3,20 @@ require 'stringio'
class SchemaDumperTest < ActiveRecord::TestCase
def setup
@stream = StringIO.new
end
def standard_dump
stream = StringIO.new
@stream = StringIO.new
ActiveRecord::SchemaDumper.ignore_tables = []
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
stream.string
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, @stream)
@stream.string
end
def test_magic_comment
skip "only test magic comments on 1.9" if RUBY_VERSION < '1.9'
assert_match "# encoding: #{@stream.external_encoding.name}", standard_dump
end
def test_schema_dump