Permalink
Browse files

Allow --skip-routes to devise generator.

  • Loading branch information...
1 parent 98acc84 commit 0b9a95e294efeaec3297851ea0d3da20100ef1fa @josevalim josevalim committed Sep 14, 2011
Showing with 10 additions and 1 deletion.
  1. +4 −1 lib/generators/devise/devise_generator.rb
  2. +6 −0 test/generators/devise_generator_test.rb
@@ -9,9 +9,12 @@ class DeviseGenerator < Rails::Generators::NamedBase
hook_for :orm
+ class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
+
def add_devise_routes
devise_route = "devise_for :#{plural_name}"
- devise_route += %Q(, :class_name => "#{class_name}") if class_name.include?("::")
+ devise_route << %Q(, :class_name => "#{class_name}") if class_name.include?("::")
+ devise_route << %Q(, :skip => :all) unless options.routes?
route devise_route
end
end
@@ -22,6 +22,12 @@ class DeviseGeneratorTest < Rails::Generators::TestCase
assert_file "config/routes.rb", match
end
+ test "route generation with skip routes" do
+ run_generator %w(monster name:string --skip-routes)
+ match = /devise_for :monsters, :skip => :all/
+ assert_file "config/routes.rb", match
+ end
+
def copy_routes
routes = File.expand_path("../../rails_app/config/routes.rb", __FILE__)
destination = File.join(destination_root, "config")

0 comments on commit 0b9a95e

Please sign in to comment.