Skip to content

Commit cc914ec

Browse files
committed
Few more coerced tests.
ActiveRecord::Migration::ColumnAttributesTest#test_add_column_without_limit TestAdapterWithInvalidConnection#test_0001_inspect on Model class does not raise: ActiveRecord::Migration::ColumnsTest#test_rename_column_preserves_default_value_not_null 10 failures, 5 errors, 2 skips
1 parent ce570d6 commit cc914ec

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
@@ -118,6 +118,48 @@ def test_limit_with_offset_is_kept_coerced
118118

119119

120120

121+
module ActiveRecord
122+
class Migration
123+
class ColumnAttributesTest < ActiveRecord::TestCase
124+
125+
# We have a default 4000 varying character limit.
126+
coerce_tests! :test_add_column_without_limit
127+
def test_add_column_without_limit_coerced
128+
add_column :test_models, :description, :string, limit: nil
129+
TestModel.reset_column_information
130+
TestModel.columns_hash["description"].limit.must_equal 4000
131+
end
132+
133+
end
134+
end
135+
end
136+
137+
138+
139+
140+
module ActiveRecord
141+
class Migration
142+
class ColumnsTest
143+
144+
# Our defaults are reall 70000 integers vs '70000' strings.
145+
coerce_tests! :test_rename_column_preserves_default_value_not_null
146+
def test_rename_column_preserves_default_value_not_null_coerced
147+
add_column 'test_models', 'salary', :integer, :default => 70000
148+
default_before = connection.columns("test_models").find { |c| c.name == "salary" }.default
149+
assert_equal 70000, default_before
150+
rename_column "test_models", "salary", "annual_salary"
151+
assert TestModel.column_names.include?("annual_salary")
152+
default_after = connection.columns("test_models").find { |c| c.name == "annual_salary" }.default
153+
assert_equal 70000, default_after
154+
end
155+
156+
end
157+
end
158+
end
159+
160+
161+
162+
121163
class CoreTest < ActiveRecord::TestCase
122164

123165
# I think fixtures are useing the wrong time zone and the `:first`
@@ -399,6 +441,17 @@ def test_schema_dump_keeps_large_precision_integer_columns_as_decimal_coerced
399441

400442

401443

444+
445+
class TestAdapterWithInvalidConnection < ActiveRecord::TestCase
446+
447+
# We trust Rails on this since we do not want to install mysql.
448+
coerce_tests! %r{inspect on Model class does not raise}
449+
450+
end
451+
452+
453+
454+
402455
require 'models/topic'
403456
class TransactionTest < ActiveRecord::TestCase
404457

0 commit comments

Comments
 (0)