Sha256: b215d2c3640911fbfd5399e44b4394d574c8ac2e97d022d387ffa7e958ecea04

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'helper'

class AxleAttributes::VersionedTest < ActiveSupport::TestCase
  class Joke < Superstore::Base
    include AxleAttributes::SerializedChild

    has_attribute :text, type: :text, version: true
    has_attribute :lol_factor, type: :integer, version: false
  end

  class ParentRecord < Superstore::Base
    include AxleAttributes::Model
  end

  class TestRecord < ParentRecord
    has_attribute :name,    type: :string,  version: true
    has_attribute :price,   type: :integer, version: true
    has_attribute :weight,  type: :float,   version: true
    has_attribute :is_cool, type: :boolean, version: true
    has_attribute :color,   type: :string

    serialize_many :jokes, class_name: 'AxleAttributes::VersionedTest::Joke'

    self.add_versioned_attribute :name, :price, :weight
  end

  def test_class_versioned_attributes
    assert_equal Set.new(['name', 'price', 'weight', 'is_cool', 'jokes']), TestRecord.versioned_attributes
  end

  def test_versioned_attributes
    assert ParentRecord.versioned_attributes.exclude?('weight')
    assert TestRecord.versioned_attributes.include?('weight')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axle_attributes-1.13.2 test/lib/versioned_test.rb