Sha256: bcd3f2f3533250d7e2c9bd7a0427a9504ede9acc30e1758e858e35eb52d8d1e8

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "cases/helper"
require "models/topic"
require "models/reply"

class MarshalSerializationTest < ActiveRecord::TestCase
  fixtures :topics

  def test_deserializing_rails_6_0_marshal_basic
    topic = Marshal.load(marshal_fixture("rails_6_0_topic"))

    assert_not_predicate topic, :new_record?
    assert_equal 1, topic.id
    assert_equal "The First Topic", topic.title
    assert_equal "Have a nice day", topic.content
  end

  def test_deserializing_rails_6_0_marshal_with_loaded_association_cache
    topic = Marshal.load(marshal_fixture("rails_6_0_topic_associations"))

    assert_not_predicate topic, :new_record?
    assert_equal 1, topic.id
    assert_equal "The First Topic", topic.title
    assert_equal "Have a nice day", topic.content
  end

  private
    def marshal_fixture(file_name)
      File.binread(marshal_fixture_path(file_name))
    end

    def marshal_fixture_path(file_name)
      File.expand_path(
        "support/marshal_compatibility_fixtures/#{ActiveRecord::Base.connection.adapter_name}/#{file_name}.dump",
        TEST_ROOT
      )
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ibm_db-5.5.0-x86-mingw32 test/cases/marshal_serialization_test.rb
ibm_db-5.4.1-x86-mingw32 test/cases/marshal_serialization_test.rb
ibm_db-5.4.0-x86-mingw32 test/cases/marshal_serialization_test.rb
ibm_db-5.3.2-x86-mingw32 test/cases/marshal_serialization_test.rb