aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/type/string_test.rb
blob: 899d7ae767e9e25a45b9a65e0ba8ff2ca5f0daad (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
# 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 author.changed?

      author.name << " Griffin"
      assert author.name_changed?

      author.save!
      author.reload

      assert_equal "Sean Griffin", author.name
      assert_not author.changed?
    end
  end
end