Merge pull request #44043 from yahonda/follow_up_43993_43296

SQLite3Adapter supports default function since #43993
This commit is contained in:
Ryuta Kamizono 2022-01-02 16:37:27 +09:00 committed by GitHub
commit 2bfcd8b025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 22 deletions

View File

@ -941,35 +941,33 @@ class DirtyTest < ActiveRecord::TestCase
assert_not_predicate person, :changed?
end
unless current_adapter?(:SQLite3Adapter)
test "partial insert off with unchanged default function attribute" do
with_partial_writes Aircraft, false do
aircraft = Aircraft.new(name: "Boeing")
assert_equal "Boeing", aircraft.name
test "partial insert off with unchanged default function attribute" do
with_partial_writes Aircraft, false do
aircraft = Aircraft.new(name: "Boeing")
assert_equal "Boeing", aircraft.name
aircraft.save!
expected_manufactured_at = Time.now
aircraft.reload
aircraft.save!
expected_manufactured_at = Time.now
aircraft.reload
assert_equal "Boeing", aircraft.name
assert_in_delta expected_manufactured_at, aircraft.manufactured_at, 1
end
assert_equal "Boeing", aircraft.name
assert_in_delta expected_manufactured_at, aircraft.manufactured_at, 1
end
end
test "partial insert off with changed default function attribute" do
with_partial_writes Aircraft, false do
manufactured_at = 1.years.ago
aircraft = Aircraft.new(name: "Boeing2", manufactured_at: manufactured_at)
test "partial insert off with changed default function attribute" do
with_partial_writes Aircraft, false do
manufactured_at = 1.years.ago
aircraft = Aircraft.new(name: "Boeing2", manufactured_at: manufactured_at)
assert_equal "Boeing2", aircraft.name
assert_equal manufactured_at.to_i, aircraft.manufactured_at.to_i
assert_equal "Boeing2", aircraft.name
assert_equal manufactured_at.to_i, aircraft.manufactured_at.to_i
aircraft.save!
aircraft.reload
aircraft.save!
aircraft.reload
assert_equal "Boeing2", aircraft.name
assert_equal manufactured_at.utc.strftime("%Y-%m-%d %H:%M:%S"), aircraft.manufactured_at.strftime("%Y-%m-%d %H:%M:%S")
end
assert_equal "Boeing2", aircraft.name
assert_equal manufactured_at.utc.strftime("%Y-%m-%d %H:%M:%S"), aircraft.manufactured_at.strftime("%Y-%m-%d %H:%M:%S")
end
end