mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use column limit to build invalid records
`validate column sizes` test assumes a string limit of 255 but SQL Server adapter (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/) uses 4000. This PR changes the test to use column definition. This removes the need coerce & re-implement the same tests in the SQL Server adapter.
This commit is contained in:
parent
3a2e361457
commit
09bafea708
1 changed files with 3 additions and 3 deletions
|
@ -247,12 +247,12 @@ class ActiveRecord::Encryption::EncryptableRecordTest < ActiveRecord::Encryption
|
|||
end
|
||||
|
||||
# Only run for adapters that add a default string limit when not provided (MySQL, 255)
|
||||
if EncryptedAuthor.columns_hash["name"].limit
|
||||
if author_name_limit = EncryptedAuthor.columns_hash["name"].limit
|
||||
# No column limits in SQLite
|
||||
test "validate column sizes" do
|
||||
assert EncryptedAuthor.new(name: "jorge").valid?
|
||||
assert_not EncryptedAuthor.new(name: "a" * 256).valid?
|
||||
author = EncryptedAuthor.create(name: "a" * 256)
|
||||
assert_not EncryptedAuthor.new(name: "a" * (author_name_limit + 1)).valid?
|
||||
author = EncryptedAuthor.create(name: "a" * (author_name_limit + 1))
|
||||
assert_not author.valid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue