diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-15 08:19:31 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-06-15 08:19:31 +0900 |
commit | e919a008485b3739706968e6ab6ce752f3245e03 (patch) | |
tree | 249f2108e1f3d4b09950308a1bad102b74957c56 /activerecord/test/cases | |
parent | 74174d786bab3208c6ed1b412394443c13e6c961 (diff) | |
download | rails-e919a008485b3739706968e6ab6ce752f3245e03.tar.gz rails-e919a008485b3739706968e6ab6ce752f3245e03.tar.bz2 rails-e919a008485b3739706968e6ab6ce752f3245e03.zip |
Should find last created record
Tables in tests are not always empty so `klass.first` does not always
find last created record.
Fixes #36479.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/attributes_test.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/test/cases/attributes_test.rb b/activerecord/test/cases/attributes_test.rb index a6fb9f0af7..d6ac5a1057 100644 --- a/activerecord/test/cases/attributes_test.rb +++ b/activerecord/test/cases/attributes_test.rb @@ -241,7 +241,7 @@ module ActiveRecord test "attributes not backed by database columns are always initialized" do OverloadedType.create! - model = OverloadedType.first + model = OverloadedType.last assert_nil model.non_existent_decimal model.non_existent_decimal = "123" @@ -253,7 +253,7 @@ module ActiveRecord attribute :non_existent_decimal, :decimal, default: 123 end child.create! - model = child.first + model = child.last assert_equal 123, model.non_existent_decimal end @@ -264,7 +264,7 @@ module ActiveRecord attribute :foo, :string, default: "lol" end child.create! - model = child.first + model = child.last assert_equal "lol", model.foo |