Created
June 10, 2012 14:47
-
-
Save waseem/2906016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From aed288e38ddda5e68a7de1a12d57ef161ac222bd Mon Sep 17 00:00:00 2001 | |
From: Waseem Ahmad <talk.to.waseem@gmail.com> | |
Date: Sun, 10 Jun 2012 20:15:20 +0530 | |
Subject: [PATCH] Passing test case for #6679 | |
--- | |
.../test/cases/migration/change_schema_test.rb | 24 ++++++++++++++++++++ | |
1 file changed, 24 insertions(+) | |
diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb | |
index ab61a4d..0d90472 100644 | |
--- a/activerecord/test/cases/migration/change_schema_test.rb | |
+++ b/activerecord/test/cases/migration/change_schema_test.rb | |
@@ -215,6 +215,30 @@ module ActiveRecord | |
end | |
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 | |
+ if current_adapter?(:OracleAdapter) | |
+ person_klass.connection.execute("INSERT INTO testings (id, title) VALUES (testings_seq.nextval, 'tester')") | |
+ else | |
+ person_klass.connection.execute("INSERT INTO testings (title) VALUES ('tester')") | |
+ end | |
+ end | |
+ person_klass.connection.add_column 'testings', 'body', :text | |
+ person_klass.all do |person| | |
+ person.body = 'Ba Ba Black Sheep' | |
+ person.save | |
+ end | |
+ | |
+ person_klass.all do |person| | |
+ assert_equal 'Ba Ba Black Sheep', person.body | |
+ end | |
+ end | |
+ | |
def test_keeping_default_and_notnull_constaint_on_change | |
connection.create_table :testings do |t| | |
t.column :title, :string | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment