diff --git a/spec/resources/sqlite_patch.rb b/spec/resources/sqlite_patch.rb new file mode 100644 index 0000000..df353b9 --- /dev/null +++ b/spec/resources/sqlite_patch.rb @@ -0,0 +1,19 @@ +# patches adapter in rails 2.0 which mistakenly made time attributes map to datetime column type +ActiveRecord::ConnectionAdapters::SQLiteAdapter.class_eval do + def native_database_types #:nodoc: + { + :primary_key => default_primary_key_type, + :string => { :name => "varchar", :limit => 255 }, + :text => { :name => "text" }, + :integer => { :name => "integer" }, + :float => { :name => "float" }, + :decimal => { :name => "decimal" }, + :datetime => { :name => "datetime" }, + :timestamp => { :name => "datetime" }, + :time => { :name => "time" }, + :date => { :name => "date" }, + :binary => { :name => "blob" }, + :boolean => { :name => "boolean" } + } + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 57297aa..4425bea 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,31 +45,10 @@ if RAILS_VER >= '2.1' ActiveRecord::Base.time_zone_aware_attributes = true end - ActiveRecord::Migration.verbose = false ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'}) -# patches adapter in rails 2.0 which mistakenly made time attributes map to datetime column typs -if RAILS_VER < '2.1' - ActiveRecord::ConnectionAdapters::SQLiteAdapter.class_eval do - def native_database_types #:nodoc: - { - :primary_key => default_primary_key_type, - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "integer" }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "boolean" } - } - end - end -end +require 'sqlite_patch' if RAILS_VER < '2.1' require 'schema' require 'person'