Skip to content

Commit

Permalink
Allow --skip-routes to devise generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Sep 14, 2011
1 parent 98acc84 commit 0b9a95e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/generators/devise/devise_generator.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/generators/devise_generator_test.rb
Expand Up @@ -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")
Expand Down

0 comments on commit 0b9a95e

Please sign in to comment.