spec/support/model_helpers.rb in warp-1.3.0 vs spec/support/model_helpers.rb in warp-1.3.1

- old
+ new

@@ -23,11 +23,16 @@ def self.attribute_method?(method) method = method.to_s.sub("=", "") columns.any? {|c| c.name == method } end - def self.column(name, sql_type = nil, default = nil, null = true) - columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) + def self.column(name, sql_type = "varchar(255)", default = nil, null = true) + if ActiveRecord::ConnectionAdapters::AbstractAdapter.method_defined?(:lookup_cast_type) + cast_type = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(nil, nil, nil).lookup_cast_type(sql_type) + columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, cast_type, sql_type.to_s, null) + else + columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null) + end end instance_eval(&blk) if blk end end \ No newline at end of file