diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-10-10 10:31:02 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-10-25 08:34:59 +0200 |
commit | 557b8b69477ff6b7ac2bc6d2e76dc6a3e04fd9c3 (patch) | |
tree | f35d7cecaa01ceb0ff4aa4eedb451b8e53cce100 /activerecord/test/cases/adapters | |
parent | 7160ffbe59ef99f01f530ad6e8377f8a91218396 (diff) | |
download | rails-557b8b69477ff6b7ac2bc6d2e76dc6a3e04fd9c3.tar.gz rails-557b8b69477ff6b7ac2bc6d2e76dc6a3e04fd9c3.tar.bz2 rails-557b8b69477ff6b7ac2bc6d2e76dc6a3e04fd9c3.zip |
test to verify the `ActiveRecord::Store` behavior with PG's json type
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index adac1d3c13..f7609404ce 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -7,6 +7,8 @@ require 'active_record/connection_adapters/postgresql_adapter' class PostgresqlJSONTest < ActiveRecord::TestCase class JsonDataType < ActiveRecord::Base self.table_name = 'json_data_type' + + store_accessor :settings, :resolution end def setup @@ -15,6 +17,7 @@ class PostgresqlJSONTest < ActiveRecord::TestCase @connection.transaction do @connection.create_table('json_data_type') do |t| t.json 'payload', :default => {} + t.json 'settings' end end rescue ActiveRecord::StatementInvalid @@ -96,4 +99,19 @@ class PostgresqlJSONTest < ActiveRecord::TestCase x.payload = ['v1', {'k2' => 'v2'}, 'v3'] assert x.save! end + + def test_with_store_accessors + x = JsonDataType.new(resolution: "320×480") + assert_equal "320×480", x.resolution + + x.save! + x = JsonDataType.first + assert_equal "320×480", x.resolution + + x.resolution = "640×1136" + x.save! + + x = JsonDataType.first + assert_equal "640×1136", x.resolution + end end |