1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Merge pull request #1288 from paper-trail-gem/remove-hash-rocket-output-from-install-generator

Change install generator to use new hash syntax
This commit is contained in:
Jared Beck 2021-01-21 10:34:41 -05:00 committed by GitHub
commit c3c58b739a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -40,9 +40,11 @@ module PaperTrail
# MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
# See https://github.com/paper-trail-gem/paper_trail/issues/651
def item_type_options
opt = { null: false }
opt[:limit] = 191 if mysql?
", #{opt}"
if mysql?
", { null: false, limit: 191 }"
else
", { null: false }"
end
end
def mysql?

View file

@ -35,6 +35,13 @@ RSpec.describe PaperTrail::InstallGenerator, type: :generator do
""
end
}.call
expected_item_type_options = lambda {
if described_class::MYSQL_ADAPTERS.include?(ActiveRecord::Base.connection.class.name)
", { null: false, limit: 191 }"
else
", { null: false }"
end
}.call
expect(destination_root).to(
have_structure {
directory("db") {
@ -43,6 +50,7 @@ RSpec.describe PaperTrail::InstallGenerator, type: :generator do
contains("class CreateVersions < " + expected_parent_class)
contains "def change"
contains "create_table :versions#{expected_create_table_options}"
contains " t.string :item_type#{expected_item_type_options}"
}
}
}