Skip to content

Commit 0f49d25

Browse files
authored
Merge pull request #973 from yellowspot/coearce-upsert-tests
[Rails 7] Coerce tests that use upsert
2 parents 1e6790a + 4b12a97 commit 0f49d25

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,3 +2003,56 @@ def test_custom_proc_context_tags_coerced
20032003
end
20042004
end
20052005
end
2006+
2007+
# SQL Server does not support upsert yet
2008+
# TODO: Remove coerce after Rails 7.1.0 (see https://github.com/rails/rails/pull/44050)
2009+
class InsertAllTest < ActiveRecord::TestCase
2010+
coerce_tests! :test_upsert_all_only_updates_the_column_provided_via_update_only
2011+
def test_upsert_all_only_updates_the_column_provided_via_update_only_coerced
2012+
assert_raises(ArgumentError, /does not support upsert/) do
2013+
original_test_upsert_all_only_updates_the_column_provided_via_update_only
2014+
end
2015+
end
2016+
2017+
coerce_tests! :test_upsert_all_only_updates_the_list_of_columns_provided_via_update_only
2018+
def test_upsert_all_only_updates_the_list_of_columns_provided_via_update_only_coerced
2019+
assert_raises(ArgumentError, /does not support upsert/) do
2020+
original_test_upsert_all_only_updates_the_list_of_columns_provided_via_update_only
2021+
end
2022+
end
2023+
2024+
coerce_tests! :test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_true
2025+
def test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_true_coerced
2026+
assert_raises(ArgumentError, /does not support upsert/) do
2027+
original_test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_true
2028+
end
2029+
end
2030+
2031+
coerce_tests! :test_upsert_all_respects_created_at_precision_when_touched_implicitly
2032+
def test_upsert_all_respects_created_at_precision_when_touched_implicitly_coerced
2033+
assert_raises(ArgumentError, /does not support upsert/) do
2034+
original_test_upsert_all_respects_created_at_precision_when_touched_implicitly
2035+
end
2036+
end
2037+
2038+
coerce_tests! :test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_true_but_overridden
2039+
def test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_true_but_overridden_coerced
2040+
assert_raises(ArgumentError, /does not support upsert/) do
2041+
original_test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_true_but_overridden
2042+
end
2043+
end
2044+
2045+
coerce_tests! :test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_false
2046+
def test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_false_coerced
2047+
assert_raises(ArgumentError, /does not support upsert/) do
2048+
original_test_upsert_all_does_not_implicitly_set_timestamps_on_create_when_model_record_timestamps_is_false
2049+
end
2050+
end
2051+
2052+
coerce_tests! :test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden
2053+
def test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden_coerced
2054+
assert_raises(ArgumentError, /does not support upsert/) do
2055+
original_test_upsert_all_implicitly_sets_timestamps_on_create_when_model_record_timestamps_is_false_but_overridden
2056+
end
2057+
end
2058+
end

0 commit comments

Comments
 (0)