Sha256: 274341404eef8f106c942ae14818d7315cb5b2e99d96a9f510295ac92c59d891

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'cases/sqlserver_helper'

class SchemaDumperTestSqlserver < ActiveRecord::TestCase
  
  context 'In schema dump' do
    
    should 'include limit constraint for integer columns' do
      output = standard_dump(/^(?!integer_limits)/)
      assert_match %r{c_int_1.*:limit => 2}, output
      assert_match %r{c_int_2.*:limit => 2}, output
      assert_match %r{c_int_3.*}, output
      assert_match %r{c_int_4.*}, output
      assert_no_match %r{c_int_3.*:limit}, output
      assert_no_match %r{c_int_4.*:limit}, output
      assert_match %r{c_int_5.*:limit => 8}, output
      assert_match %r{c_int_6.*:limit => 8}, output
      assert_match %r{c_int_7.*:limit => 8}, output
      assert_match %r{c_int_8.*:limit => 8}, output
    end
    
    should 'honor nonstandard primary keys' do
      output = standard_dump
      match = output.match(%r{create_table "movies"(.*)do})
      assert_not_nil(match, "nonstandardpk table not found")
      assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved"
    end
    
  end
  
  
  private
  
  def standard_dump(ignore_tables = [])
    stream = StringIO.new
    ActiveRecord::SchemaDumper.ignore_tables = [*ignore_tables]
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
    stream.string
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-sqlserver-2000-2005-adapter-1.0.0 test/cases/schema_dumper_test_sqlserver.rb
rails-sqlserver-2000-2005-adapter-1.0.1 test/cases/schema_dumper_test_sqlserver.rb