2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-07 02:42:14 -05:00
|
|
|
require "cases/helper"
|
|
|
|
require "cases/json_shared_test_cases"
|
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
class JsonAttributeTest < ActiveRecord::TestCase
|
|
|
|
include JSONSharedTestCases
|
|
|
|
self.use_transactional_tests = false
|
2017-03-07 02:42:14 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
class JsonDataTypeOnText < ActiveRecord::Base
|
|
|
|
self.table_name = "json_data_type"
|
2017-03-07 02:42:14 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
attribute :payload, :json
|
|
|
|
attribute :settings, :json
|
2017-03-07 02:42:14 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
store_accessor :settings, :resolution
|
|
|
|
end
|
2017-03-07 02:42:14 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
@connection.create_table("json_data_type") do |t|
|
2017-12-05 18:33:16 -05:00
|
|
|
t.string "payload"
|
|
|
|
t.string "settings"
|
2017-03-07 02:42:14 -05:00
|
|
|
end
|
2017-12-05 18:30:27 -05:00
|
|
|
end
|
2017-03-07 02:42:14 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
private
|
|
|
|
def column_type
|
2017-12-05 18:33:16 -05:00
|
|
|
:string
|
2017-12-05 18:30:27 -05:00
|
|
|
end
|
2017-12-05 14:16:11 -05:00
|
|
|
|
2017-12-05 18:30:27 -05:00
|
|
|
def klass
|
|
|
|
JsonDataTypeOnText
|
|
|
|
end
|
2017-03-07 02:42:14 -05:00
|
|
|
end
|