Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created June 11, 2012 08:11
Show Gist options
  • Select an option

  • Save jdelStrother/2909023 to your computer and use it in GitHub Desktop.

Select an option

Save jdelStrother/2909023 to your computer and use it in GitHub Desktop.
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb
index ab61a4d..3fbd110 100644
--- a/activerecord/test/cases/migration/change_schema_test.rb
+++ b/activerecord/test/cases/migration/change_schema_test.rb
@@ -17,6 +18,27 @@ module ActiveRecord
ActiveRecord::Base.primary_key_prefix_type = nil
end
+ def test_add_column_persists_values
+ connection.create_table :testings do |t|
+ t.column :title, :string
+ end
+ person_klass = Class.new(ActiveRecord::Base)
+ person_klass.table_name = 'testings'
+ 2.times do
+ person_klass.create!(title:'foo')
+ end
+
+ person_klass.connection.add_column 'testings', 'body', :text
+ person_klass.find_each do |person|
+ person.body = 'Ba Ba Black Sheep'
+ person.save!
+ end
+
+ person_klass.find_each do |person|
+ assert_equal 'Ba Ba Black Sheep', person.body
+ end
+ end
+
def test_create_table_without_id
testing_table_with_only_foo_attribute do
assert_equal connection.columns(:testings).size, 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment