Skip to content

Instantly share code, notes, and snippets.

@senny
Created December 30, 2013 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senny/8181015 to your computer and use it in GitHub Desktop.
Save senny/8181015 to your computer and use it in GitHub Desktop.
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
index 6df5d8f..8d1e7bc 100644
--- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb
@@ -70,6 +70,23 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase
Hstore.reset_column_information
end
+ def test_adding_hstore_column_is_revertable
+ hstore_migration = Class.new(ActiveRecord::Migration) do
+ def write(text = '')
+ end
+
+ def change
+ add_column 'hstores', 'groups', :hstore
+ end
+ end
+
+ migration = hstore_migration.new
+ migration.migrate(:up)
+ assert_equal ["id", "tags", "settings", "groups"], @connection.columns("hstores").map(&:name)
+ migration.migrate(:down)
+ assert_equal ["id", "tags", "settings"], @connection.columns("hstores").map(&:name)
+ end
+
def test_cast_value_on_write
x = Hstore.new tags: {"bool" => true, "number" => 5}
assert_equal({"bool" => "true", "number" => "5"}, x.tags)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment