generate migrations with new .change method for rails >= 3.1. closes #1345

This commit is contained in:
Vasiliy Ermolovich
2011-11-06 15:47:34 +03:00
parent 95be78ac5e
commit f00d9c5eff
4 changed files with 42 additions and 10 deletions

View File

@@ -57,4 +57,20 @@ class ActiveSupport::TestCase
object.send :"#{key}=", value
end
end
def with_rails_version(constants, &block)
saved_constants = {}
constants.each do |constant, val|
saved_constants[constant] = ::Rails::VERSION.const_get constant
Kernel::silence_warnings { ::Rails::VERSION.const_set(constant, val) }
end
begin
block.call
ensure
constants.each do |constant, val|
Kernel::silence_warnings { ::Rails::VERSION.const_set(constant, saved_constants[constant]) }
end
end
end
end