devise 2.1.2 → 3.5.10
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.travis.yml +39 -10
- data/.yardopts +9 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +445 -112
- data/CODE_OF_CONDUCT.md +22 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +10 -15
- data/Gemfile.lock +151 -129
- data/MIT-LICENSE +1 -1
- data/README.md +256 -96
- data/Rakefile +4 -2
- data/app/controllers/devise/confirmations_controller.rb +15 -7
- data/app/controllers/devise/omniauth_callbacks_controller.rb +6 -2
- data/app/controllers/devise/passwords_controller.rb +33 -9
- data/app/controllers/devise/registrations_controller.rb +66 -26
- data/app/controllers/devise/sessions_controller.rb +52 -21
- data/app/controllers/devise/unlocks_controller.rb +11 -6
- data/app/controllers/devise_controller.rb +65 -58
- data/app/helpers/devise_helper.rb +2 -2
- data/app/mailers/devise/mailer.rb +19 -10
- data/app/views/devise/confirmations/new.html.erb +8 -4
- data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +2 -2
- data/app/views/devise/mailer/unlock_instructions.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +15 -6
- data/app/views/devise/passwords/new.html.erb +8 -4
- data/app/views/devise/registrations/edit.html.erb +29 -15
- data/app/views/devise/registrations/new.html.erb +19 -8
- data/app/views/devise/sessions/new.html.erb +17 -8
- data/app/views/devise/shared/{_links.erb → _links.html.erb} +4 -4
- data/app/views/devise/unlocks/new.html.erb +8 -4
- data/config/locales/en.yml +51 -47
- data/devise.gemspec +8 -6
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2-stable +29 -0
- data/gemfiles/Gemfile.rails-3.2-stable.lock +172 -0
- data/gemfiles/Gemfile.rails-4.0-stable +30 -0
- data/gemfiles/Gemfile.rails-4.0-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.1-stable +30 -0
- data/gemfiles/Gemfile.rails-4.1-stable.lock +171 -0
- data/gemfiles/Gemfile.rails-4.2-stable +30 -0
- data/gemfiles/Gemfile.rails-4.2-stable.lock +193 -0
- data/lib/devise/controllers/helpers.rb +126 -108
- data/lib/devise/controllers/rememberable.rb +19 -17
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +96 -0
- data/lib/devise/controllers/store_location.rb +58 -0
- data/lib/devise/controllers/url_helpers.rb +7 -7
- data/lib/devise/encryptor.rb +22 -0
- data/lib/devise/failure_app.rb +85 -25
- data/lib/devise/hooks/activatable.rb +5 -6
- data/lib/devise/hooks/csrf_cleaner.rb +7 -0
- data/lib/devise/hooks/forgetable.rb +1 -1
- data/lib/devise/hooks/lockable.rb +2 -2
- data/lib/devise/hooks/proxy.rb +21 -0
- data/lib/devise/hooks/rememberable.rb +5 -4
- data/lib/devise/hooks/timeoutable.rb +16 -8
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +27 -23
- data/lib/devise/mapping.rb +11 -7
- data/lib/devise/models/authenticatable.rb +82 -66
- data/lib/devise/models/confirmable.rb +142 -55
- data/lib/devise/models/database_authenticatable.rb +59 -15
- data/lib/devise/models/lockable.rb +41 -30
- data/lib/devise/models/omniauthable.rb +3 -3
- data/lib/devise/models/recoverable.rb +56 -41
- data/lib/devise/models/rememberable.rb +65 -27
- data/lib/devise/models/timeoutable.rb +2 -8
- data/lib/devise/models/trackable.rb +6 -4
- data/lib/devise/models/validatable.rb +9 -9
- data/lib/devise/models.rb +4 -13
- data/lib/devise/modules.rb +10 -11
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/mongoid.rb +1 -1
- data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -11
- data/lib/devise/parameter_sanitizer.rb +99 -0
- data/lib/devise/rails/routes.rb +173 -115
- data/lib/devise/rails/warden_compat.rb +10 -31
- data/lib/devise/rails.rb +14 -12
- data/lib/devise/strategies/authenticatable.rb +26 -26
- data/lib/devise/strategies/base.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +8 -4
- data/lib/devise/strategies/rememberable.rb +15 -5
- data/lib/devise/test_helpers.rb +7 -5
- data/lib/devise/time_inflector.rb +14 -0
- data/lib/devise/token_generator.rb +70 -0
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +110 -52
- data/lib/generators/active_record/devise_generator.rb +34 -18
- data/lib/generators/active_record/templates/migration.rb +5 -6
- data/lib/generators/active_record/templates/migration_existing.rb +5 -6
- data/lib/generators/devise/controllers_generator.rb +44 -0
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +5 -0
- data/lib/generators/devise/orm_helpers.rb +25 -6
- data/lib/generators/devise/views_generator.rb +52 -22
- data/lib/generators/mongoid/devise_generator.rb +21 -26
- data/lib/generators/templates/README +9 -5
- data/lib/generators/templates/controllers/README +14 -0
- data/lib/generators/templates/controllers/confirmations_controller.rb +28 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
- data/lib/generators/templates/controllers/passwords_controller.rb +32 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +60 -0
- data/lib/generators/templates/controllers/sessions_controller.rb +25 -0
- data/lib/generators/templates/controllers/unlocks_controller.rb +28 -0
- data/lib/generators/templates/devise.rb +80 -43
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +2 -2
- data/lib/generators/templates/markerb/password_change.markerb +3 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +2 -2
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +3 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +11 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +3 -2
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +40 -0
- data/test/controllers/helper_methods_test.rb +21 -0
- data/test/controllers/helpers_test.rb +95 -32
- data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
- data/test/controllers/internal_helpers_test.rb +39 -14
- data/test/controllers/load_hooks_controller_test.rb +19 -0
- data/test/controllers/passwords_controller_test.rb +31 -0
- data/test/controllers/sessions_controller_test.rb +66 -6
- data/test/controllers/url_helpers_test.rb +10 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +45 -10
- data/test/failure_app_test.rb +121 -27
- data/test/generators/active_record_generator_test.rb +48 -8
- data/test/generators/controllers_generator_test.rb +48 -0
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +3 -3
- data/test/generators/views_generator_test.rb +54 -3
- data/test/helpers/devise_helper_test.rb +18 -20
- data/test/integration/authenticatable_test.rb +161 -65
- data/test/integration/confirmable_test.rb +146 -77
- data/test/integration/database_authenticatable_test.rb +43 -30
- data/test/integration/http_authenticatable_test.rb +30 -22
- data/test/integration/lockable_test.rb +64 -49
- data/test/integration/omniauthable_test.rb +17 -15
- data/test/integration/recoverable_test.rb +111 -70
- data/test/integration/registerable_test.rb +114 -79
- data/test/integration/rememberable_test.rb +87 -31
- data/test/integration/timeoutable_test.rb +77 -33
- data/test/integration/trackable_test.rb +5 -5
- data/test/mailers/confirmation_instructions_test.rb +28 -8
- data/test/mailers/reset_password_instructions_test.rb +21 -8
- data/test/mailers/unlock_instructions_test.rb +20 -6
- data/test/mapping_test.rb +12 -5
- data/test/models/authenticatable_test.rb +17 -1
- data/test/models/confirmable_test.rb +216 -62
- data/test/models/database_authenticatable_test.rb +129 -49
- data/test/models/lockable_test.rb +132 -45
- data/test/models/recoverable_test.rb +100 -54
- data/test/models/rememberable_test.rb +89 -94
- data/test/models/serializable_test.rb +12 -11
- data/test/models/timeoutable_test.rb +6 -1
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +31 -21
- data/test/models_test.rb +22 -48
- data/test/omniauth/config_test.rb +4 -4
- data/test/omniauth/url_helpers_test.rb +7 -4
- data/test/orm/active_record.rb +1 -0
- data/test/orm/mongoid.rb +2 -3
- data/test/parameter_sanitizer_test.rb +81 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/active_record/shim.rb +1 -1
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/active_record/user_without_email.rb +8 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +0 -5
- data/test/rails_app/app/controllers/application_controller.rb +6 -2
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +31 -0
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
- data/test/rails_app/app/controllers/users_controller.rb +12 -4
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +3 -0
- data/test/rails_app/app/mailers/users/mailer.rb +1 -1
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +4 -0
- data/test/rails_app/app/mongoid/admin.rb +12 -10
- data/test/rails_app/app/mongoid/shim.rb +4 -5
- data/test/rails_app/app/mongoid/user.rb +19 -22
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/app/mongoid/user_without_email.rb +33 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/home/index.html.erb +1 -1
- data/test/rails_app/app/views/home/join.html.erb +1 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +4 -0
- data/test/rails_app/bin/rake +4 -0
- data/test/rails_app/config/application.rb +4 -5
- data/test/rails_app/config/boot.rb +9 -3
- data/test/rails_app/config/environment.rb +2 -2
- data/test/rails_app/config/environments/development.rb +19 -7
- data/test/rails_app/config/environments/production.rb +68 -17
- data/test/rails_app/config/environments/test.rb +24 -16
- data/test/rails_app/config/initializers/devise.rb +22 -20
- data/test/rails_app/config/initializers/secret_token.rb +8 -2
- data/test/rails_app/config/initializers/session_store.rb +1 -0
- data/test/rails_app/config/routes.rb +71 -46
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +9 -12
- data/test/rails_app/db/schema.rb +21 -18
- data/test/rails_app/lib/shared_admin.rb +7 -4
- data/test/rails_app/lib/shared_user.rb +6 -3
- data/test/rails_app/lib/shared_user_without_email.rb +26 -0
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/rails_test.rb +9 -0
- data/test/routes_test.rb +94 -78
- data/test/support/action_controller/record_identifier.rb +10 -0
- data/test/support/assertions.rb +2 -3
- data/test/support/helpers.rb +18 -32
- data/test/support/integration.rb +17 -16
- data/test/support/locale/en.yml +4 -0
- data/test/support/mongoid.yml +6 -0
- data/test/test_helper.rb +8 -1
- data/test/test_helpers_test.rb +64 -20
- data/test/test_models.rb +33 -0
- data/test/time_helpers.rb +137 -0
- metadata +172 -51
- data/app/views/devise/_links.erb +0 -3
- data/gemfiles/Gemfile.rails-3.1.x +0 -35
- data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
- data/lib/devise/models/token_authenticatable.rb +0 -77
- data/lib/devise/strategies/token_authenticatable.rb +0 -56
- data/test/indifferent_hash.rb +0 -33
- data/test/integration/token_authenticatable_test.rb +0 -161
- data/test/models/token_authenticatable_test.rb +0 -55
- data/test/rails_app/script/rails +0 -10
@@ -0,0 +1 @@
|
|
1
|
+
RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session'
|
@@ -1,100 +1,125 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
# Resources for testing
|
3
|
-
resources :users, :
|
4
|
-
|
5
|
-
|
3
|
+
resources :users, only: [:index] do
|
4
|
+
member do
|
5
|
+
get :expire
|
6
|
+
get :accept
|
7
|
+
get :edit_form
|
8
|
+
put :update_form
|
9
|
+
end
|
6
10
|
|
7
11
|
authenticate do
|
8
|
-
post :exhibit, :
|
12
|
+
post :exhibit, on: :member
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
12
|
-
resources :admins, :
|
13
|
-
get :expire, :on => :member
|
14
|
-
end
|
16
|
+
resources :admins, only: [:index]
|
15
17
|
|
16
18
|
# Users scope
|
17
|
-
devise_for :users, :
|
19
|
+
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
20
|
+
|
21
|
+
devise_for :user_on_main_apps,
|
22
|
+
class_name: 'UserOnMainApp',
|
23
|
+
router_name: :main_app,
|
24
|
+
module: :devise
|
25
|
+
|
26
|
+
devise_for :user_on_engines,
|
27
|
+
class_name: 'UserOnEngine',
|
28
|
+
router_name: :fake_engine,
|
29
|
+
module: :devise
|
30
|
+
|
31
|
+
devise_for :user_without_email,
|
32
|
+
class_name: 'UserWithoutEmail',
|
33
|
+
router_name: :main_app,
|
34
|
+
module: :devise
|
18
35
|
|
19
36
|
as :user do
|
20
|
-
|
37
|
+
get "/as/sign_in", to: "devise/sessions#new"
|
21
38
|
end
|
22
39
|
|
23
|
-
|
40
|
+
get "/sign_in", to: "devise/sessions#new"
|
41
|
+
|
42
|
+
# Routes for custom controller testing
|
43
|
+
devise_for :user, only: [:registrations], controllers: { registrations: "custom/registrations" }, as: :custom, path: :custom
|
24
44
|
|
25
45
|
# Admin scope
|
26
|
-
devise_for :admin, :
|
46
|
+
devise_for :admin, path: "admin_area", controllers: { sessions: :"admins/sessions" }, skip: :passwords
|
27
47
|
|
28
|
-
|
29
|
-
|
48
|
+
get "/admin_area/home", to: "admins#index", as: :admin_root
|
49
|
+
get "/anywhere", to: "foo#bar", as: :new_admin_password
|
30
50
|
|
31
51
|
authenticate(:admin) do
|
32
|
-
|
52
|
+
get "/private", to: "home#private", as: :private
|
33
53
|
end
|
34
54
|
|
35
55
|
authenticate(:admin, lambda { |admin| admin.active? }) do
|
36
|
-
|
56
|
+
get "/private/active", to: "home#private", as: :private_active
|
37
57
|
end
|
38
58
|
|
39
59
|
authenticated :admin do
|
40
|
-
|
60
|
+
get "/dashboard", to: "home#admin_dashboard"
|
41
61
|
end
|
42
62
|
|
43
63
|
authenticated :admin, lambda { |admin| admin.active? } do
|
44
|
-
|
64
|
+
get "/dashboard/active", to: "home#admin_dashboard"
|
45
65
|
end
|
46
66
|
|
47
67
|
authenticated do
|
48
|
-
|
68
|
+
get "/dashboard", to: "home#user_dashboard"
|
49
69
|
end
|
50
70
|
|
51
71
|
unauthenticated do
|
52
|
-
|
72
|
+
get "/join", to: "home#join"
|
53
73
|
end
|
54
74
|
|
55
75
|
# Routes for constraints testing
|
56
|
-
devise_for :headquarters_admin, :
|
76
|
+
devise_for :headquarters_admin, class_name: "Admin", path: "headquarters", constraints: {host: /192\.168\.1\.\d\d\d/}
|
77
|
+
|
78
|
+
constraints(host: /192\.168\.1\.\d\d\d/) do
|
79
|
+
devise_for :homebase_admin, class_name: "Admin", path: "homebase"
|
80
|
+
end
|
57
81
|
|
58
|
-
|
59
|
-
devise_for :
|
82
|
+
scope(subdomain: 'sub') do
|
83
|
+
devise_for :subdomain_users, class_name: "User", only: [:sessions]
|
60
84
|
end
|
61
85
|
|
62
|
-
devise_for :skip_admin, :
|
86
|
+
devise_for :skip_admin, class_name: "Admin", skip: :all
|
63
87
|
|
64
88
|
# Routes for format=false testing
|
65
|
-
devise_for :htmlonly_admin, :
|
66
|
-
devise_for :htmlonly_users, :
|
89
|
+
devise_for :htmlonly_admin, class_name: "Admin", skip: [:confirmations, :unlocks], path: "htmlonly_admin", format: false, skip_helpers: [:confirmations, :unlocks]
|
90
|
+
devise_for :htmlonly_users, class_name: "User", only: [:confirmations, :unlocks], path: "htmlonly_users", format: false, skip_helpers: true
|
67
91
|
|
68
92
|
# Other routes for routing_test.rb
|
69
|
-
devise_for :reader, :
|
93
|
+
devise_for :reader, class_name: "User", only: :passwords
|
70
94
|
|
71
|
-
scope :
|
72
|
-
devise_for :sub_admin, :
|
95
|
+
scope host: "sub.example.com" do
|
96
|
+
devise_for :sub_admin, class_name: "Admin"
|
73
97
|
end
|
74
98
|
|
75
|
-
namespace :publisher, :
|
76
|
-
devise_for :accounts, :
|
99
|
+
namespace :publisher, path_names: { sign_in: "i_dont_care", sign_out: "get_out" } do
|
100
|
+
devise_for :accounts, class_name: "Admin", path_names: { sign_in: "get_in" }
|
77
101
|
end
|
78
102
|
|
79
|
-
scope ":locale", :
|
80
|
-
devise_for :accounts, :
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
|
103
|
+
scope ":locale", module: :invalid do
|
104
|
+
devise_for :accounts, singular: "manager", class_name: "Admin",
|
105
|
+
path_names: {
|
106
|
+
sign_in: "login", sign_out: "logout",
|
107
|
+
password: "secret", confirmation: "verification",
|
108
|
+
unlock: "unblock", sign_up: "register",
|
109
|
+
registration: "management",
|
110
|
+
cancel: "giveup", edit: "edit/profile"
|
111
|
+
}, failure_app: lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, module: :devise
|
87
112
|
end
|
88
113
|
|
89
|
-
namespace :sign_out_via, :
|
90
|
-
devise_for :deletes, :
|
91
|
-
devise_for :posts, :
|
92
|
-
devise_for :delete_or_posts, :
|
114
|
+
namespace :sign_out_via, module: "devise" do
|
115
|
+
devise_for :deletes, sign_out_via: :delete, class_name: "Admin"
|
116
|
+
devise_for :posts, sign_out_via: :post, class_name: "Admin"
|
117
|
+
devise_for :delete_or_posts, sign_out_via: [:delete, :post], class_name: "Admin"
|
93
118
|
end
|
94
119
|
|
95
|
-
|
96
|
-
|
97
|
-
|
120
|
+
get "/set", to: "home#set"
|
121
|
+
get "/unauthenticated", to: "home#unauthenticated"
|
122
|
+
get "/custom_strategy/new"
|
98
123
|
|
99
|
-
root :
|
124
|
+
root to: "home#index", via: [:get, :post]
|
100
125
|
end
|
@@ -5,8 +5,8 @@ class CreateTables < ActiveRecord::Migration
|
|
5
5
|
t.string :facebook_token
|
6
6
|
|
7
7
|
## Database authenticatable
|
8
|
-
t.string :email, :
|
9
|
-
t.string :encrypted_password, :
|
8
|
+
t.string :email, null: false, default: ""
|
9
|
+
t.string :encrypted_password, null: false, default: ""
|
10
10
|
|
11
11
|
## Recoverable
|
12
12
|
t.string :reset_password_token
|
@@ -16,7 +16,7 @@ class CreateTables < ActiveRecord::Migration
|
|
16
16
|
t.datetime :remember_created_at
|
17
17
|
|
18
18
|
## Trackable
|
19
|
-
t.integer :sign_in_count, :
|
19
|
+
t.integer :sign_in_count, default: 0
|
20
20
|
t.datetime :current_sign_in_at
|
21
21
|
t.datetime :last_sign_in_at
|
22
22
|
t.string :current_sign_in_ip
|
@@ -29,20 +29,17 @@ class CreateTables < ActiveRecord::Migration
|
|
29
29
|
# t.string :unconfirmed_email # Only if using reconfirmable
|
30
30
|
|
31
31
|
## Lockable
|
32
|
-
t.integer :failed_attempts, :
|
32
|
+
t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts
|
33
33
|
t.string :unlock_token # Only if unlock strategy is :email or :both
|
34
34
|
t.datetime :locked_at
|
35
35
|
|
36
|
-
|
37
|
-
t.string :authentication_token
|
38
|
-
|
39
|
-
t.timestamps
|
36
|
+
t.timestamps null: false
|
40
37
|
end
|
41
38
|
|
42
39
|
create_table :admins do |t|
|
43
40
|
## Database authenticatable
|
44
|
-
t.string :email, :
|
45
|
-
t.string :encrypted_password, :
|
41
|
+
t.string :email, null: true
|
42
|
+
t.string :encrypted_password, null: true
|
46
43
|
|
47
44
|
## Recoverable
|
48
45
|
t.string :reset_password_token
|
@@ -61,9 +58,9 @@ class CreateTables < ActiveRecord::Migration
|
|
61
58
|
t.datetime :locked_at
|
62
59
|
|
63
60
|
## Attribute for testing route blocks
|
64
|
-
t.boolean :active, :
|
61
|
+
t.boolean :active, default: false
|
65
62
|
|
66
|
-
t.timestamps
|
63
|
+
t.timestamps null: false
|
67
64
|
end
|
68
65
|
end
|
69
66
|
|
data/test/rails_app/db/schema.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
# This file is auto-generated from the current state of the database. Instead
|
2
3
|
# of editing this file, please use the migrations feature of Active Record to
|
3
4
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -8,43 +9,45 @@
|
|
8
9
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
10
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
11
|
#
|
11
|
-
# It's strongly recommended
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
13
|
|
13
|
-
ActiveRecord::Schema.define(:
|
14
|
+
ActiveRecord::Schema.define(version: 20100401102949) do
|
14
15
|
|
15
|
-
create_table "admins", :
|
16
|
+
create_table "admins", force: true do |t|
|
16
17
|
t.string "email"
|
17
|
-
t.string "encrypted_password"
|
18
|
-
t.string "password_salt"
|
19
|
-
t.string "remember_token"
|
20
|
-
t.datetime "remember_created_at"
|
18
|
+
t.string "encrypted_password"
|
21
19
|
t.string "reset_password_token"
|
22
|
-
t.
|
23
|
-
t.
|
20
|
+
t.datetime "reset_password_sent_at"
|
21
|
+
t.datetime "remember_created_at"
|
22
|
+
t.string "confirmation_token"
|
23
|
+
t.datetime "confirmed_at"
|
24
|
+
t.datetime "confirmation_sent_at"
|
25
|
+
t.string "unconfirmed_email"
|
24
26
|
t.datetime "locked_at"
|
27
|
+
t.boolean "active", default: false
|
25
28
|
t.datetime "created_at"
|
26
29
|
t.datetime "updated_at"
|
27
30
|
end
|
28
31
|
|
29
|
-
create_table "users", :
|
32
|
+
create_table "users", force: true do |t|
|
30
33
|
t.string "username"
|
31
34
|
t.string "facebook_token"
|
32
|
-
t.string "email",
|
33
|
-
t.string "encrypted_password",
|
34
|
-
t.string "confirmation_token"
|
35
|
-
t.datetime "confirmed_at"
|
36
|
-
t.datetime "confirmation_sent_at"
|
35
|
+
t.string "email", default: "", null: false
|
36
|
+
t.string "encrypted_password", default: "", null: false
|
37
37
|
t.string "reset_password_token"
|
38
|
+
t.datetime "reset_password_sent_at"
|
38
39
|
t.datetime "remember_created_at"
|
39
|
-
t.integer "sign_in_count",
|
40
|
+
t.integer "sign_in_count", default: 0
|
40
41
|
t.datetime "current_sign_in_at"
|
41
42
|
t.datetime "last_sign_in_at"
|
42
43
|
t.string "current_sign_in_ip"
|
43
44
|
t.string "last_sign_in_ip"
|
44
|
-
t.
|
45
|
+
t.string "confirmation_token"
|
46
|
+
t.datetime "confirmed_at"
|
47
|
+
t.datetime "confirmation_sent_at"
|
48
|
+
t.integer "failed_attempts", default: 0
|
45
49
|
t.string "unlock_token"
|
46
50
|
t.datetime "locked_at"
|
47
|
-
t.string "authentication_token"
|
48
51
|
t.datetime "created_at"
|
49
52
|
t.datetime "updated_at"
|
50
53
|
end
|
@@ -4,11 +4,14 @@ module SharedAdmin
|
|
4
4
|
included do
|
5
5
|
devise :database_authenticatable, :registerable,
|
6
6
|
:timeoutable, :recoverable, :lockable, :confirmable,
|
7
|
-
:
|
8
|
-
:
|
7
|
+
unlock_strategy: :time, lock_strategy: :none,
|
8
|
+
allow_unconfirmed_access_for: 2.weeks, reconfirmable: true
|
9
9
|
|
10
|
-
validates_length_of :reset_password_token, :
|
11
|
-
validates_uniqueness_of :email, :
|
10
|
+
validates_length_of :reset_password_token, minimum: 3, allow_blank: true
|
11
|
+
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
12
12
|
end
|
13
13
|
|
14
|
+
def raw_confirmation_token
|
15
|
+
@raw_confirmation_token
|
16
|
+
end
|
14
17
|
end
|
@@ -3,16 +3,19 @@ module SharedUser
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
6
|
-
:registerable, :rememberable, :timeoutable,
|
7
|
-
:trackable, :validatable, :omniauthable
|
6
|
+
:registerable, :rememberable, :timeoutable,
|
7
|
+
:trackable, :validatable, :omniauthable, password_length: 7..72
|
8
8
|
|
9
9
|
attr_accessor :other_key
|
10
|
-
attr_accessible :username, :email, :password, :password_confirmation, :remember_me
|
11
10
|
|
12
11
|
# They need to be included after Devise is called.
|
13
12
|
extend ExtendMethods
|
14
13
|
end
|
15
14
|
|
15
|
+
def raw_confirmation_token
|
16
|
+
@raw_confirmation_token
|
17
|
+
end
|
18
|
+
|
16
19
|
module ExtendMethods
|
17
20
|
def new_with_session(params, session)
|
18
21
|
super.tap do |user|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SharedUserWithoutEmail
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
# NOTE: This is missing :validatable and :confirmable, as they both require
|
6
|
+
# an email field at the moment. It is also missing :omniauthable because that
|
7
|
+
# adds unnecessary complexity to the setup
|
8
|
+
devise :database_authenticatable, :lockable, :recoverable,
|
9
|
+
:registerable, :rememberable, :timeoutable,
|
10
|
+
:trackable
|
11
|
+
end
|
12
|
+
|
13
|
+
# This test stub is a bit rubbish because it's tied very closely to the
|
14
|
+
# implementation where we care about this one case. However, completely
|
15
|
+
# removing the email field breaks "recoverable" tests completely, so we are
|
16
|
+
# just taking the approach here that "email" is something that is a not an
|
17
|
+
# ActiveRecord field.
|
18
|
+
def email_changed?
|
19
|
+
raise NoMethodError
|
20
|
+
end
|
21
|
+
|
22
|
+
def respond_to?(method_name, include_all=false)
|
23
|
+
return false if method_name.to_sym == :email_changed?
|
24
|
+
super(method_name, include_all)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module SharedUserWithoutOmniauth
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
6
|
+
:registerable, :rememberable, :timeoutable,
|
7
|
+
:trackable, :validatable
|
8
|
+
end
|
9
|
+
|
10
|
+
def raw_confirmation_token
|
11
|
+
@raw_confirmation_token
|
12
|
+
end
|
13
|
+
end
|
data/test/rails_test.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RailsTest < ActiveSupport::TestCase
|
4
|
+
test 'correct initializer position' do
|
5
|
+
initializer = Devise::Engine.initializers.detect { |i| i.name == 'devise.omniauth' }
|
6
|
+
assert_equal :load_config_initializers, initializer.after
|
7
|
+
assert_equal :build_middleware_stack, initializer.before
|
8
|
+
end
|
9
|
+
end
|
data/test/routes_test.rb
CHANGED
@@ -1,108 +1,110 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
+
ExpectedRoutingError = Devise.rails4? ? MiniTest::Assertion : ActionController::RoutingError
|
4
|
+
|
3
5
|
class DefaultRoutingTest < ActionController::TestCase
|
4
6
|
test 'map new user session' do
|
5
|
-
assert_recognizes({:
|
7
|
+
assert_recognizes({controller: 'devise/sessions', action: 'new'}, {path: 'users/sign_in', method: :get})
|
6
8
|
assert_named_route "/users/sign_in", :new_user_session_path
|
7
9
|
end
|
8
10
|
|
9
11
|
test 'map create user session' do
|
10
|
-
assert_recognizes({:
|
12
|
+
assert_recognizes({controller: 'devise/sessions', action: 'create'}, {path: 'users/sign_in', method: :post})
|
11
13
|
assert_named_route "/users/sign_in", :user_session_path
|
12
14
|
end
|
13
15
|
|
14
16
|
test 'map destroy user session' do
|
15
|
-
assert_recognizes({:
|
17
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: 'users/sign_out', method: :get})
|
16
18
|
assert_named_route "/users/sign_out", :destroy_user_session_path
|
17
19
|
end
|
18
20
|
|
19
21
|
test 'map new user confirmation' do
|
20
|
-
assert_recognizes({:
|
22
|
+
assert_recognizes({controller: 'devise/confirmations', action: 'new'}, 'users/confirmation/new')
|
21
23
|
assert_named_route "/users/confirmation/new", :new_user_confirmation_path
|
22
24
|
end
|
23
25
|
|
24
26
|
test 'map create user confirmation' do
|
25
|
-
assert_recognizes({:
|
27
|
+
assert_recognizes({controller: 'devise/confirmations', action: 'create'}, {path: 'users/confirmation', method: :post})
|
26
28
|
assert_named_route "/users/confirmation", :user_confirmation_path
|
27
29
|
end
|
28
30
|
|
29
31
|
test 'map show user confirmation' do
|
30
|
-
assert_recognizes({:
|
32
|
+
assert_recognizes({controller: 'devise/confirmations', action: 'show'}, {path: 'users/confirmation', method: :get})
|
31
33
|
end
|
32
34
|
|
33
35
|
test 'map new user password' do
|
34
|
-
assert_recognizes({:
|
36
|
+
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'users/password/new')
|
35
37
|
assert_named_route "/users/password/new", :new_user_password_path
|
36
38
|
end
|
37
39
|
|
38
40
|
test 'map create user password' do
|
39
|
-
assert_recognizes({:
|
41
|
+
assert_recognizes({controller: 'devise/passwords', action: 'create'}, {path: 'users/password', method: :post})
|
40
42
|
assert_named_route "/users/password", :user_password_path
|
41
43
|
end
|
42
44
|
|
43
45
|
test 'map edit user password' do
|
44
|
-
assert_recognizes({:
|
46
|
+
assert_recognizes({controller: 'devise/passwords', action: 'edit'}, 'users/password/edit')
|
45
47
|
assert_named_route "/users/password/edit", :edit_user_password_path
|
46
48
|
end
|
47
49
|
|
48
50
|
test 'map update user password' do
|
49
|
-
assert_recognizes({:
|
51
|
+
assert_recognizes({controller: 'devise/passwords', action: 'update'}, {path: 'users/password', method: :put})
|
50
52
|
end
|
51
53
|
|
52
54
|
test 'map new user unlock' do
|
53
|
-
assert_recognizes({:
|
55
|
+
assert_recognizes({controller: 'devise/unlocks', action: 'new'}, 'users/unlock/new')
|
54
56
|
assert_named_route "/users/unlock/new", :new_user_unlock_path
|
55
57
|
end
|
56
58
|
|
57
59
|
test 'map create user unlock' do
|
58
|
-
assert_recognizes({:
|
60
|
+
assert_recognizes({controller: 'devise/unlocks', action: 'create'}, {path: 'users/unlock', method: :post})
|
59
61
|
assert_named_route "/users/unlock", :user_unlock_path
|
60
62
|
end
|
61
63
|
|
62
64
|
test 'map show user unlock' do
|
63
|
-
assert_recognizes({:
|
65
|
+
assert_recognizes({controller: 'devise/unlocks', action: 'show'}, {path: 'users/unlock', method: :get})
|
64
66
|
end
|
65
67
|
|
66
68
|
test 'map new user registration' do
|
67
|
-
assert_recognizes({:
|
69
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, 'users/sign_up')
|
68
70
|
assert_named_route "/users/sign_up", :new_user_registration_path
|
69
71
|
end
|
70
72
|
|
71
73
|
test 'map create user registration' do
|
72
|
-
assert_recognizes({:
|
74
|
+
assert_recognizes({controller: 'devise/registrations', action: 'create'}, {path: 'users', method: :post})
|
73
75
|
assert_named_route "/users", :user_registration_path
|
74
76
|
end
|
75
77
|
|
76
78
|
test 'map edit user registration' do
|
77
|
-
assert_recognizes({:
|
79
|
+
assert_recognizes({controller: 'devise/registrations', action: 'edit'}, {path: 'users/edit', method: :get})
|
78
80
|
assert_named_route "/users/edit", :edit_user_registration_path
|
79
81
|
end
|
80
82
|
|
81
83
|
test 'map update user registration' do
|
82
|
-
assert_recognizes({:
|
84
|
+
assert_recognizes({controller: 'devise/registrations', action: 'update'}, {path: 'users', method: :put})
|
83
85
|
end
|
84
86
|
|
85
87
|
test 'map destroy user registration' do
|
86
|
-
assert_recognizes({:
|
88
|
+
assert_recognizes({controller: 'devise/registrations', action: 'destroy'}, {path: 'users', method: :delete})
|
87
89
|
end
|
88
90
|
|
89
91
|
test 'map cancel user registration' do
|
90
|
-
assert_recognizes({:
|
92
|
+
assert_recognizes({controller: 'devise/registrations', action: 'cancel'}, {path: 'users/cancel', method: :get})
|
91
93
|
assert_named_route "/users/cancel", :cancel_user_registration_path
|
92
94
|
end
|
93
95
|
|
94
96
|
test 'map omniauth callbacks' do
|
95
|
-
assert_recognizes({:
|
96
|
-
assert_recognizes({:
|
97
|
+
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :get})
|
98
|
+
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'facebook'}, {path: 'users/auth/facebook/callback', method: :post})
|
97
99
|
assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
|
98
100
|
|
99
101
|
# named open_id
|
100
|
-
assert_recognizes({:
|
101
|
-
assert_recognizes({:
|
102
|
+
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :get})
|
103
|
+
assert_recognizes({controller: 'users/omniauth_callbacks', action: 'google'}, {path: 'users/auth/google/callback', method: :post})
|
102
104
|
assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
|
103
105
|
|
104
|
-
assert_raise
|
105
|
-
assert_recognizes({:
|
106
|
+
assert_raise ExpectedRoutingError do
|
107
|
+
assert_recognizes({controller: 'ysers/omniauth_callbacks', action: 'twitter'}, {path: 'users/auth/twitter/callback', method: :get})
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
@@ -115,134 +117,148 @@ end
|
|
115
117
|
|
116
118
|
class CustomizedRoutingTest < ActionController::TestCase
|
117
119
|
test 'map admin with :path option' do
|
118
|
-
assert_recognizes({:
|
120
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'admin_area/sign_up', method: :get})
|
119
121
|
end
|
120
122
|
|
121
123
|
test 'map admin with :controllers option' do
|
122
|
-
assert_recognizes({:
|
124
|
+
assert_recognizes({controller: 'admins/sessions', action: 'new'}, {path: 'admin_area/sign_in', method: :get})
|
123
125
|
end
|
124
126
|
|
125
127
|
test 'does not map admin password' do
|
126
|
-
assert_raise
|
127
|
-
assert_recognizes({:
|
128
|
+
assert_raise ExpectedRoutingError do
|
129
|
+
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'admin_area/password/new')
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
131
133
|
test 'subdomain admin' do
|
132
|
-
assert_recognizes({"host"=>"sub.example.com", :
|
134
|
+
assert_recognizes({"host"=>"sub.example.com", controller: 'devise/sessions', action: 'new'}, {host: "sub.example.com", path: '/sub_admin/sign_in', method: :get})
|
133
135
|
end
|
134
136
|
|
135
137
|
test 'does only map reader password' do
|
136
|
-
assert_raise
|
137
|
-
assert_recognizes({:
|
138
|
+
assert_raise ExpectedRoutingError do
|
139
|
+
assert_recognizes({controller: 'devise/sessions', action: 'new'}, 'reader/sessions/new')
|
138
140
|
end
|
139
|
-
assert_recognizes({:
|
141
|
+
assert_recognizes({controller: 'devise/passwords', action: 'new'}, 'reader/password/new')
|
140
142
|
end
|
141
143
|
|
142
144
|
test 'map account with custom path name for session sign in' do
|
143
|
-
assert_recognizes({:
|
145
|
+
assert_recognizes({controller: 'devise/sessions', action: 'new', locale: 'en'}, '/en/accounts/login')
|
144
146
|
end
|
145
147
|
|
146
148
|
test 'map account with custom path name for session sign out' do
|
147
|
-
assert_recognizes({:
|
149
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy', locale: 'en'}, '/en/accounts/logout')
|
148
150
|
end
|
149
151
|
|
150
152
|
test 'map account with custom path name for password' do
|
151
|
-
assert_recognizes({:
|
153
|
+
assert_recognizes({controller: 'devise/passwords', action: 'new', locale: 'en'}, '/en/accounts/secret/new')
|
152
154
|
end
|
153
155
|
|
154
156
|
test 'map account with custom path name for registration' do
|
155
|
-
assert_recognizes({:
|
157
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new', locale: 'en'}, '/en/accounts/management/register')
|
158
|
+
end
|
159
|
+
|
160
|
+
test 'map account with custom path name for edit registration' do
|
161
|
+
assert_recognizes({controller: 'devise/registrations', action: 'edit', locale: 'en'}, '/en/accounts/management/edit/profile')
|
156
162
|
end
|
157
163
|
|
158
164
|
test 'map account with custom path name for cancel registration' do
|
159
|
-
assert_recognizes({:
|
165
|
+
assert_recognizes({controller: 'devise/registrations', action: 'cancel', locale: 'en'}, '/en/accounts/management/giveup')
|
160
166
|
end
|
161
167
|
|
162
168
|
test 'map deletes with :sign_out_via option' do
|
163
|
-
assert_recognizes({:
|
164
|
-
assert_raise
|
165
|
-
assert_recognizes({:
|
169
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :delete})
|
170
|
+
assert_raise ExpectedRoutingError do
|
171
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/deletes/sign_out', method: :get})
|
166
172
|
end
|
167
173
|
end
|
168
174
|
|
169
175
|
test 'map posts with :sign_out_via option' do
|
170
|
-
assert_recognizes({:
|
171
|
-
assert_raise
|
172
|
-
assert_recognizes({:
|
176
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :post})
|
177
|
+
assert_raise ExpectedRoutingError do
|
178
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/posts/sign_out', method: :get})
|
173
179
|
end
|
174
180
|
end
|
175
181
|
|
176
182
|
test 'map delete_or_posts with :sign_out_via option' do
|
177
|
-
assert_recognizes({:
|
178
|
-
assert_recognizes({:
|
179
|
-
assert_raise
|
180
|
-
assert_recognizes({:
|
183
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :post})
|
184
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :delete})
|
185
|
+
assert_raise ExpectedRoutingError do
|
186
|
+
assert_recognizes({controller: 'devise/sessions', action: 'destroy'}, {path: '/sign_out_via/delete_or_posts/sign_out', method: :get})
|
181
187
|
end
|
182
188
|
end
|
183
|
-
|
189
|
+
|
184
190
|
test 'map with constraints defined in hash' do
|
185
|
-
assert_recognizes({:
|
186
|
-
assert_raise
|
187
|
-
assert_recognizes({:
|
191
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/headquarters/sign_up', method: :get})
|
192
|
+
assert_raise ExpectedRoutingError do
|
193
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100/headquarters/sign_up', method: :get})
|
188
194
|
end
|
189
195
|
end
|
190
|
-
|
196
|
+
|
191
197
|
test 'map with constraints defined in block' do
|
192
|
-
assert_recognizes({:
|
193
|
-
assert_raise
|
194
|
-
assert_recognizes({:
|
198
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://192.168.1.100/homebase/sign_up', method: :get})
|
199
|
+
assert_raise ExpectedRoutingError do
|
200
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: 'http://10.0.0.100//homebase/sign_up', method: :get})
|
195
201
|
end
|
196
202
|
end
|
197
|
-
|
203
|
+
|
198
204
|
test 'map with format false for sessions' do
|
199
|
-
assert_recognizes({:
|
200
|
-
assert_raise
|
201
|
-
assert_recognizes({:
|
205
|
+
assert_recognizes({controller: 'devise/sessions', action: 'new'}, {path: '/htmlonly_admin/sign_in', method: :get})
|
206
|
+
assert_raise ExpectedRoutingError do
|
207
|
+
assert_recognizes({controller: 'devise/sessions', action: 'new'}, {path: '/htmlonly_admin/sign_in.xml', method: :get})
|
202
208
|
end
|
203
209
|
end
|
204
|
-
|
210
|
+
|
205
211
|
test 'map with format false for passwords' do
|
206
|
-
assert_recognizes({:
|
207
|
-
assert_raise
|
208
|
-
assert_recognizes({:
|
212
|
+
assert_recognizes({controller: 'devise/passwords', action: 'create'}, {path: '/htmlonly_admin/password', method: :post})
|
213
|
+
assert_raise ExpectedRoutingError do
|
214
|
+
assert_recognizes({controller: 'devise/passwords', action: 'create'}, {path: '/htmlonly_admin/password.xml', method: :post})
|
209
215
|
end
|
210
216
|
end
|
211
|
-
|
217
|
+
|
212
218
|
test 'map with format false for registrations' do
|
213
|
-
assert_recognizes({:
|
214
|
-
assert_raise
|
215
|
-
assert_recognizes({:
|
219
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: '/htmlonly_admin/sign_up', method: :get})
|
220
|
+
assert_raise ExpectedRoutingError do
|
221
|
+
assert_recognizes({controller: 'devise/registrations', action: 'new'}, {path: '/htmlonly_admin/sign_up.xml', method: :get})
|
216
222
|
end
|
217
223
|
end
|
218
|
-
|
224
|
+
|
219
225
|
test 'map with format false for confirmations' do
|
220
|
-
assert_recognizes({:
|
221
|
-
assert_raise
|
222
|
-
assert_recognizes({:
|
226
|
+
assert_recognizes({controller: 'devise/confirmations', action: 'show'}, {path: '/htmlonly_users/confirmation', method: :get})
|
227
|
+
assert_raise ExpectedRoutingError do
|
228
|
+
assert_recognizes({controller: 'devise/confirmations', action: 'show'}, {path: '/htmlonly_users/confirmation.xml', method: :get})
|
223
229
|
end
|
224
230
|
end
|
225
|
-
|
231
|
+
|
226
232
|
test 'map with format false for unlocks' do
|
227
|
-
assert_recognizes({:
|
228
|
-
assert_raise
|
229
|
-
assert_recognizes({:
|
233
|
+
assert_recognizes({controller: 'devise/unlocks', action: 'show'}, {path: '/htmlonly_users/unlock', method: :get})
|
234
|
+
assert_raise ExpectedRoutingError do
|
235
|
+
assert_recognizes({controller: 'devise/unlocks', action: 'show'}, {path: '/htmlonly_users/unlock.xml', method: :get})
|
230
236
|
end
|
231
237
|
end
|
232
238
|
|
233
239
|
test 'map with format false is not permanent' do
|
234
240
|
assert_equal "/set.xml", @routes.url_helpers.set_path(:xml)
|
235
241
|
end
|
242
|
+
|
243
|
+
test 'checks if mapping has proper configuration for omniauth callback' do
|
244
|
+
e = assert_raise ArgumentError do
|
245
|
+
routes = ActionDispatch::Routing::RouteSet.new
|
246
|
+
routes.draw do
|
247
|
+
devise_for :not_omniauthable, class_name: 'Admin', controllers: {omniauth_callbacks: "users/omniauth_callbacks"}
|
248
|
+
end
|
249
|
+
end
|
250
|
+
assert_match "Mapping omniauth_callbacks on a resource that is not omniauthable", e.message
|
251
|
+
end
|
236
252
|
end
|
237
253
|
|
238
254
|
class ScopedRoutingTest < ActionController::TestCase
|
239
255
|
test 'map publisher account' do
|
240
|
-
assert_recognizes({:
|
256
|
+
assert_recognizes({controller: 'publisher/registrations', action: 'new'}, {path: '/publisher/accounts/sign_up', method: :get})
|
241
257
|
assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
|
242
258
|
end
|
243
259
|
|
244
260
|
test 'map publisher account merges path names' do
|
245
|
-
assert_recognizes({:
|
261
|
+
assert_recognizes({controller: 'publisher/sessions', action: 'new'}, {path: '/publisher/accounts/get_in', method: :get})
|
246
262
|
assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
|
247
263
|
end
|
248
264
|
end
|