Skip to content

Commit

Permalink
Automatically add revise_auth routes in model generator (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciomacadden authored Apr 30, 2024
1 parent c074679 commit 690ed73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can accomplish this in a few different ways:

### Routes

Tell your router to add ReviseAuth's controllers:
The model generator will automatically add ReviseAuth's routes to your router:

```
# config/routes.rb
Expand Down
4 changes: 4 additions & 0 deletions lib/generators/revise_auth/model_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def add_revise_auth_model
inject_into_class "app/models/user.rb", "User", " include ReviseAuth::Model\n" if behavior == :invoke
end

def add_revise_auth_routes
route "revise_auth"
end

def copy_initializer
template "initializer.rb", "config/initializers/revise_auth.rb"
end
Expand Down
5 changes: 5 additions & 0 deletions test/generators/model_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ class ModelGeneratorTest < Rails::Generators::TestCase
assert_migration "db/migrate/create_users.rb", /t\.string :last_name/
assert_migration "db/migrate/create_users.rb", /t\.boolean :admin/
end

test "revise_auth is added to config/routes.rb" do
run_generator
assert_file "config/routes.rb", /revise_auth/
end
end

0 comments on commit 690ed73

Please sign in to comment.