1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

handle namespaced models in AR generator

closes #2043
This commit is contained in:
Vasiliy Ermolovich 2012-10-28 00:58:24 +03:00
parent 90dbae4c7a
commit 2f36d0dd32
2 changed files with 12 additions and 2 deletions

View file

@ -27,7 +27,11 @@ module ActiveRecord
attr_accessible :email, :password, :password_confirmation, :remember_me
CONTENT
class_path = class_name.to_s.split("::")
class_path = if namespaced?
class_name.to_s.split("::")
else
[class_name]
end
indent_depth = class_path.size - 1
content = content.split("\n").map { |line| " " * indent_depth + line } .join("\n") << "\n"

View file

@ -14,6 +14,12 @@ if DEVISE_ORM == :active_record
assert_migration "db/migrate/devise_create_monsters.rb", /def change/
end
test "all files for namespaced model are properly created" do
run_generator %w(admin/monster)
assert_file "app/models/admin/monster.rb", /devise/, /attr_accessible (:[a-z_]+(, )?)+/
assert_migration "db/migrate/devise_create_admin_monsters.rb", /def change/
end
test "update model migration when model exists" do
run_generator %w(monster)
assert_file "app/models/monster.rb"
@ -66,4 +72,4 @@ if DEVISE_ORM == :active_record
end
end
end
end
end