Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test to verify the `ActiveRecord::Store` behavior with PG's json type

  • Loading branch information...
commit 557b8b69477ff6b7ac2bc6d2e76dc6a3e04fd9c3 1 parent 7160ffb
@senny senny authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/test/cases/adapters/postgresql/json_test.rb
View
18 activerecord/test/cases/adapters/postgresql/json_test.rb
@@ -7,6 +7,8 @@
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 @@ def setup
@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 @@ def test_rewrite_array_json_value
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
Please sign in to comment.
Something went wrong with that request. Please try again.