mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 07:18:14 -05:00
Added the ability to change the default migrations path (introduced in Rails 5.0.3)
This commit is contained in:
@@ -13,6 +13,20 @@ if DEVISE_ORM == :active_record
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
|
||||
end
|
||||
|
||||
test "all files are properly created with changed db/migrate path in application configuration" do
|
||||
old_paths = Rails.application.config.paths["db/migrate"]
|
||||
Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
|
||||
|
||||
run_generator %w(monster)
|
||||
if Rails.version >= '5.0.3'
|
||||
assert_migration "db2/migrate/devise_create_monsters.rb", /def change/
|
||||
else
|
||||
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
|
||||
end
|
||||
|
||||
Rails.application.config.paths["db/migrate"] = old_paths
|
||||
end
|
||||
|
||||
test "all files for namespaced model are properly created" do
|
||||
run_generator %w(admin/monster)
|
||||
assert_migration "db/migrate/devise_create_admin_monsters.rb", /def change/
|
||||
@@ -25,6 +39,23 @@ if DEVISE_ORM == :active_record
|
||||
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
||||
end
|
||||
|
||||
test "update model migration when model exists with changed db/migrate path in application configuration" do
|
||||
old_paths = Rails.application.config.paths["db/migrate"]
|
||||
Rails.application.config.paths.add "db/migrate", with: "db2/migrate"
|
||||
|
||||
run_generator %w(monster)
|
||||
assert_file "app/models/monster.rb"
|
||||
run_generator %w(monster)
|
||||
|
||||
if Rails.version >= '5.0.3'
|
||||
assert_migration "db2/migrate/add_devise_to_monsters.rb"
|
||||
else
|
||||
assert_migration "db/migrate/add_devise_to_monsters.rb"
|
||||
end
|
||||
|
||||
Rails.application.config.paths["db/migrate"] = old_paths
|
||||
end
|
||||
|
||||
test "all files are properly deleted" do
|
||||
run_generator %w(monster)
|
||||
run_generator %w(monster)
|
||||
|
||||
Reference in New Issue
Block a user