aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/test/cases/type/string_test.rb
blob: 9e7810a6a522a7d2b053aa92cd1f79d6b6c2f955 (plain) (tree)
1
2
3
4
5
6
7
8
9

                             
                      


                                               

                                           
                                  
 
                                          
                                            
 
                               
                                             



                   
                                              
                                            


       
# frozen_string_literal: true

require "cases/helper"

module ActiveRecord
  class StringTypeTest < ActiveRecord::TestCase
    test "string mutations are detected" do
      klass = Class.new(Base)
      klass.table_name = "authors"

      author = klass.create!(name: "Sean")
      assert_not_predicate author, :changed?

      author.name << " Griffin"
      assert_predicate author, :name_changed?

      author.save!
      author.reload

      assert_equal "Sean Griffin", author.name
      assert_not_predicate author, :changed?
    end
  end
end