Skip to content

Commit

Permalink
Merge pull request #2802 from schneems/schneems/raise_controller_omni…
Browse files Browse the repository at this point in the history
…authable

[close #2755] Raise incompatible route error
  • Loading branch information
José Valim committed Dec 20, 2013
2 parents 71c4392 + a00921f commit 29da146
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/devise/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ def devise_for(*resources)
raise_no_devise_method_error!(mapping.class_name)
end

if options[:controllers] && options[:controllers][:omniauth_callbacks]
unless mapping.omniauthable?
msg = "Mapping omniauth_callbacks on a resource that is not omniauthable\n"
msg << "Please add `devise :omniauthable` to the `#{mapping.class_name}` model"
raise msg
end
end

routes = mapping.used_routes

devise_scope mapping.name do
Expand Down
8 changes: 8 additions & 0 deletions test/routes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ class CustomizedRoutingTest < ActionController::TestCase
test 'map with format false is not permanent' do
assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
end

test 'checks if mapping has proper configuration for omniauth callback' do
assert_raise ArgumentError do
@routes.dup.eval_block do
devise_for :admin, controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
end
end
end
end

class ScopedRoutingTest < ActionController::TestCase
Expand Down

0 comments on commit 29da146

Please sign in to comment.