aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/json_attribute_test.rb
blob: afc39d0420e2ecce0b3f76c2b2c7b5a52da5da43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require "cases/helper"
require "cases/json_shared_test_cases"

class JsonAttributeTest < ActiveRecord::TestCase
  include JSONSharedTestCases
  self.use_transactional_tests = false

  class JsonDataTypeOnText < ActiveRecord::Base
    self.table_name = "json_data_type"

    attribute :payload,  :json
    attribute :settings, :json

    store_accessor :settings, :resolution
  end

  def setup
    super
    @connection.create_table("json_data_type") do |t|
      t.string "payload"
      t.string "settings"
    end
  end

  private
    def column_type
      :string
    end

    def klass
      JsonDataTypeOnText
    end
end