class NamespacedModelGeneratorTest
Public Instance Methods
test_adds_namespace_to_model()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 95 def test_adds_namespace_to_model run_generator assert_file "app/models/test_app/account.rb", /module TestApp/, / class Account < ApplicationRecord/ end
test_invokes_default_test_framework()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 139 def test_invokes_default_test_framework run_generator assert_file "test/models/test_app/account_test.rb", /module TestApp/, /class AccountTest < ActiveSupport::TestCase/ assert_file "test/fixtures/test_app/accounts.yml", /name: MyString/, /age: 1/ end
test_migration()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 108 def test_migration run_generator assert_migration "db/migrate/create_test_app_accounts.rb", /create_table :test_app_accounts/, /class CreateTestAppAccounts < ActiveRecord::Migration\[[0-9.]+\]/ end
test_migration_with_namespace()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 113 def test_migration_with_namespace run_generator ["Gallery::Image"] assert_migration "db/migrate/create_test_app_gallery_images", /class CreateTestAppGalleryImages < ActiveRecord::Migration\[[0-9.]+\]/ assert_no_migration "db/migrate/create_test_app_images" end
test_migration_with_nested_namespace()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 119 def test_migration_with_nested_namespace run_generator ["Admin::Gallery::Image"] assert_no_migration "db/migrate/create_images" assert_no_migration "db/migrate/create_gallery_images" assert_migration "db/migrate/create_test_app_admin_gallery_images", /class CreateTestAppAdminGalleryImages < ActiveRecord::Migration\[[0-9.]+\]/ assert_migration "db/migrate/create_test_app_admin_gallery_images", /create_table :test_app_admin_gallery_images/ end
test_migration_with_nested_namespace_without_pluralization()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 127 def test_migration_with_nested_namespace_without_pluralization ActiveRecord::Base.pluralize_table_names = false run_generator ["Admin::Gallery::Image"] assert_no_migration "db/migrate/create_images" assert_no_migration "db/migrate/create_gallery_images" assert_no_migration "db/migrate/create_test_app_admin_gallery_images" assert_migration "db/migrate/create_test_app_admin_gallery_image", /class CreateTestAppAdminGalleryImage < ActiveRecord::Migration\[[0-9.]+\]/ assert_migration "db/migrate/create_test_app_admin_gallery_image", /create_table :test_app_admin_gallery_image/ ensure ActiveRecord::Base.pluralize_table_names = true end
test_model_with_namespace()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 100 def test_model_with_namespace run_generator ["admin/account"] assert_file "app/models/test_app/admin.rb", /module TestApp/, /module Admin/ assert_file "app/models/test_app/admin.rb", /def self\.table_name_prefix/ assert_file "app/models/test_app/admin.rb", /'test_app_admin_'/ assert_file "app/models/test_app/admin/account.rb", /module TestApp/, /class Admin::Account < ApplicationRecord/ end
test_module_file_is_not_created()
click to toggle source
# File railties/test/generators/namespaced_generators_test.rb, line 90 def test_module_file_is_not_created run_generator assert_no_file "app/models/test_app.rb" end