Generators on engine fix
This commit is contained in:
parent
f6c06ac786
commit
afc3888391
|
@ -22,10 +22,15 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def inject_devise_content
|
||||
inject_into_class(model_path, class_name, model_contents + <<CONTENT) if model_exists?
|
||||
content = model_contents + <<CONTENT
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me
|
||||
CONTENT
|
||||
|
||||
indent_size = class_name.to_s.split("::").size - 1
|
||||
content = content.split("\n").map { |line| " " * indent_size + line}.join("\n")
|
||||
|
||||
inject_into_class(model_path, class_name.to_s.split("::").last, content) if model_exists?
|
||||
end
|
||||
|
||||
def migration_data
|
||||
|
|
|
@ -34,4 +34,20 @@ if DEVISE_ORM == :active_record
|
|||
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
||||
end
|
||||
end
|
||||
|
||||
class RailsEngine ; end
|
||||
|
||||
class ActiveRecordGeneratorTest < Rails::Generators::TestCase
|
||||
tests ActiveRecord::Generators::DeviseGenerator
|
||||
destination File.expand_path("../../tmp", __FILE__)
|
||||
setup :prepare_destination
|
||||
|
||||
test "all files are properly created" do
|
||||
swap Rails::Generators, :namespace => RailsEngine do
|
||||
run_generator ["monster"]
|
||||
|
||||
assert_file "app/models/rails_engine/monster.rb", /devise/, /attr_accessible (:[a-z_]+(, )?)+/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue