aboutsummaryrefslogblamecommitdiffstats
path: root/activemodel/test/cases/type/immutable_string_test.rb
blob: b3140c26829b2ecad6c22a08b3340d03eecf36f5 (plain) (tree)
1
2
3
4
5
6
7

                             
                      


                  
                                                       














                                                          
# frozen_string_literal: true

require "cases/helper"

module ActiveModel
  module Type
    class ImmutableStringTest < ActiveSupport::TestCase
      test "cast strings are frozen" do
        s = "foo"
        type = Type::ImmutableString.new
        assert_equal true, type.cast(s).frozen?
      end

      test "immutable strings are not duped coming out" do
        s = "foo"
        type = Type::ImmutableString.new
        assert_same s, type.cast(s)
        assert_same s, type.deserialize(s)
      end
    end
  end
end