Skip to content

Commit bd099f6

Browse files
committed
coerce test to deal with unique index
1 parent fa939cd commit bd099f6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,17 @@ class EnumTest < ActiveRecord::TestCase
17631763
Book.where(author_id: nil, name: nil).delete_all
17641764
Book.connection.add_index(:books, [:author_id, :name], unique: true)
17651765
end
1766+
1767+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1768+
coerce_tests! %r{with large number label}
1769+
test "with large number label coerced" do
1770+
Book.connection.remove_index(:books, column: [:author_id, :name])
1771+
1772+
send(:'original_with large number label')
1773+
ensure
1774+
Book.where(author_id: nil, name: nil).delete_all
1775+
Book.connection.add_index(:books, [:author_id, :name], unique: true)
1776+
end
17661777
end
17671778

17681779
require "models/task"
@@ -1925,3 +1936,28 @@ class MultiDbMigratorTest < ActiveRecord::TestCase
19251936
# Test fails on Windows AppVeyor CI for unknown reason.
19261937
coerce_tests! :test_migrator_db_has_no_schema_migrations_table if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
19271938
end
1939+
1940+
require "models/book"
1941+
class FieldOrderedValuesTest < ActiveRecord::TestCase
1942+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1943+
coerce_tests! :test_in_order_of_with_enums_values
1944+
def test_in_order_of_with_enums_values_coerced
1945+
Book.connection.remove_index(:books, column: [:author_id, :name])
1946+
1947+
original_test_in_order_of_with_enums_values
1948+
ensure
1949+
Book.where(author_id: nil, name: nil).delete_all
1950+
Book.connection.add_index(:books, [:author_id, :name], unique: true)
1951+
end
1952+
1953+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1954+
coerce_tests! :test_in_order_of_with_enums_keys
1955+
def test_in_order_of_with_enums_keys_coerced
1956+
Book.connection.remove_index(:books, column: [:author_id, :name])
1957+
1958+
original_test_in_order_of_with_enums_keys
1959+
ensure
1960+
Book.where(author_id: nil, name: nil).delete_all
1961+
Book.connection.add_index(:books, [:author_id, :name], unique: true)
1962+
end
1963+
end

0 commit comments

Comments
 (0)