namxam-devise 1.1.0.win
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +455 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +118 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +311 -0
- data/Rakefile +55 -0
- data/TODO +3 -0
- data/app/controllers/devise/confirmations_controller.rb +33 -0
- data/app/controllers/devise/passwords_controller.rb +41 -0
- data/app/controllers/devise/registrations_controller.rb +57 -0
- data/app/controllers/devise/sessions_controller.rb +23 -0
- data/app/controllers/devise/unlocks_controller.rb +34 -0
- data/app/helpers/devise_helper.rb +17 -0
- data/app/mailers/devise/mailer.rb +71 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/app/views/devise/shared/_links.erb +19 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/config/locales/en.yml +39 -0
- data/lib/devise.rb +290 -0
- data/lib/devise/controllers/helpers.rb +231 -0
- data/lib/devise/controllers/internal_helpers.rb +98 -0
- data/lib/devise/controllers/scoped_views.rb +35 -0
- data/lib/devise/controllers/url_helpers.rb +41 -0
- data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
- data/lib/devise/encryptors/base.rb +20 -0
- data/lib/devise/encryptors/bcrypt.rb +19 -0
- data/lib/devise/encryptors/clearance_sha1.rb +17 -0
- data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
- data/lib/devise/encryptors/sha1.rb +25 -0
- data/lib/devise/encryptors/sha512.rb +25 -0
- data/lib/devise/failure_app.rb +107 -0
- data/lib/devise/hooks/activatable.rb +11 -0
- data/lib/devise/hooks/forgetable.rb +11 -0
- data/lib/devise/hooks/rememberable.rb +35 -0
- data/lib/devise/hooks/timeoutable.rb +22 -0
- data/lib/devise/hooks/trackable.rb +9 -0
- data/lib/devise/mapping.rb +103 -0
- data/lib/devise/models.rb +80 -0
- data/lib/devise/models/authenticatable.rb +126 -0
- data/lib/devise/models/confirmable.rb +164 -0
- data/lib/devise/models/database_authenticatable.rb +110 -0
- data/lib/devise/models/lockable.rb +165 -0
- data/lib/devise/models/recoverable.rb +81 -0
- data/lib/devise/models/registerable.rb +8 -0
- data/lib/devise/models/rememberable.rb +104 -0
- data/lib/devise/models/timeoutable.rb +26 -0
- data/lib/devise/models/token_authenticatable.rb +60 -0
- data/lib/devise/models/trackable.rb +30 -0
- data/lib/devise/models/validatable.rb +53 -0
- data/lib/devise/modules.rb +23 -0
- data/lib/devise/orm/active_record.rb +36 -0
- data/lib/devise/orm/mongoid.rb +29 -0
- data/lib/devise/path_checker.rb +18 -0
- data/lib/devise/rails.rb +69 -0
- data/lib/devise/rails/routes.rb +248 -0
- data/lib/devise/rails/warden_compat.rb +39 -0
- data/lib/devise/schema.rb +97 -0
- data/lib/devise/strategies/authenticatable.rb +111 -0
- data/lib/devise/strategies/base.rb +33 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +43 -0
- data/lib/devise/strategies/token_authenticatable.rb +49 -0
- data/lib/devise/test_helpers.rb +90 -0
- data/lib/devise/version.rb +3 -0
- data/lib/generators/active_record/devise_generator.rb +28 -0
- data/lib/generators/active_record/templates/migration.rb +29 -0
- data/lib/generators/devise/devise_generator.rb +17 -0
- data/lib/generators/devise/install_generator.rb +24 -0
- data/lib/generators/devise/orm_helpers.rb +23 -0
- data/lib/generators/devise/templates/README +25 -0
- data/lib/generators/devise/templates/devise.rb +139 -0
- data/lib/generators/devise/views_generator.rb +63 -0
- data/lib/generators/devise_install_generator.rb +4 -0
- data/lib/generators/devise_views_generator.rb +4 -0
- data/lib/generators/mongoid/devise_generator.rb +17 -0
- data/test/controllers/helpers_test.rb +213 -0
- data/test/controllers/internal_helpers_test.rb +51 -0
- data/test/controllers/url_helpers_test.rb +58 -0
- data/test/devise_test.rb +65 -0
- data/test/encryptors_test.rb +30 -0
- data/test/failure_app_test.rb +123 -0
- data/test/integration/authenticatable_test.rb +344 -0
- data/test/integration/confirmable_test.rb +104 -0
- data/test/integration/database_authenticatable_test.rb +38 -0
- data/test/integration/http_authenticatable_test.rb +49 -0
- data/test/integration/lockable_test.rb +109 -0
- data/test/integration/recoverable_test.rb +141 -0
- data/test/integration/registerable_test.rb +153 -0
- data/test/integration/rememberable_test.rb +91 -0
- data/test/integration/timeoutable_test.rb +80 -0
- data/test/integration/token_authenticatable_test.rb +88 -0
- data/test/integration/trackable_test.rb +64 -0
- data/test/mailers/confirmation_instructions_test.rb +80 -0
- data/test/mailers/reset_password_instructions_test.rb +68 -0
- data/test/mailers/unlock_instructions_test.rb +62 -0
- data/test/mapping_test.rb +85 -0
- data/test/models/confirmable_test.rb +221 -0
- data/test/models/database_authenticatable_test.rb +148 -0
- data/test/models/lockable_test.rb +188 -0
- data/test/models/recoverable_test.rb +138 -0
- data/test/models/rememberable_test.rb +176 -0
- data/test/models/timeoutable_test.rb +28 -0
- data/test/models/token_authenticatable_test.rb +37 -0
- data/test/models/trackable_test.rb +5 -0
- data/test/models/validatable_test.rb +99 -0
- data/test/models_test.rb +77 -0
- data/test/orm/active_record.rb +9 -0
- data/test/orm/mongoid.rb +10 -0
- data/test/rails_app/app/active_record/admin.rb +3 -0
- data/test/rails_app/app/active_record/shim.rb +2 -0
- data/test/rails_app/app/active_record/user.rb +7 -0
- data/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/app/controllers/application_controller.rb +9 -0
- data/test/rails_app/app/controllers/home_controller.rb +7 -0
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
- data/test/rails_app/app/controllers/sessions_controller.rb +6 -0
- data/test/rails_app/app/controllers/users_controller.rb +18 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/mongoid/admin.rb +6 -0
- data/test/rails_app/app/mongoid/shim.rb +16 -0
- data/test/rails_app/app/mongoid/user.rb +10 -0
- data/test/rails_app/config/application.rb +35 -0
- data/test/rails_app/config/boot.rb +13 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +19 -0
- data/test/rails_app/config/environments/production.rb +33 -0
- data/test/rails_app/config/environments/test.rb +33 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +136 -0
- data/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/config/initializers/secret_token.rb +2 -0
- data/test/rails_app/config/routes.rb +47 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +27 -0
- data/test/rails_app/db/schema.rb +86 -0
- data/test/routes_test.rb +146 -0
- data/test/support/assertions.rb +24 -0
- data/test/support/helpers.rb +54 -0
- data/test/support/integration.rb +88 -0
- data/test/support/test_silencer.rb +5 -0
- data/test/support/webrat/integrations/rails.rb +32 -0
- data/test/test_helper.rb +21 -0
- data/test/test_helpers_test.rb +72 -0
- metadata +230 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# See everything in the log (default is :info)
|
13
|
+
# config.log_level = :debug
|
14
|
+
|
15
|
+
# Use a different logger for distributed setups
|
16
|
+
# config.logger = SyslogLogger.new
|
17
|
+
|
18
|
+
# Use a different cache store in production
|
19
|
+
# config.cache_store = :mem_cache_store
|
20
|
+
|
21
|
+
# Disable Rails's static asset server
|
22
|
+
# In production, Apache or nginx will already do this
|
23
|
+
config.serve_static_assets = false
|
24
|
+
|
25
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
26
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
27
|
+
|
28
|
+
# Disable delivery errors, bad email addresses will be ignored
|
29
|
+
# config.action_mailer.raise_delivery_errors = false
|
30
|
+
|
31
|
+
# Enable threaded mode
|
32
|
+
# config.threadsafe!
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Disable request forgery protection in test environment
|
18
|
+
config.action_controller.allow_forgery_protection = false
|
19
|
+
|
20
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
21
|
+
# The :test delivery method accumulates sent emails in the
|
22
|
+
# ActionMailer::Base.deliveries array.
|
23
|
+
config.action_mailer.delivery_method = :test
|
24
|
+
|
25
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
26
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
27
|
+
# like if you have constraints or database-specific column types
|
28
|
+
# config.active_record.schema_format = :sql
|
29
|
+
|
30
|
+
config.action_dispatch.show_exceptions = false
|
31
|
+
|
32
|
+
config.active_support.deprecation = :stderr
|
33
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
2
|
+
# four configuration values can also be set straight in your models.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# ==> Mailer Configuration
|
5
|
+
# Configure the e-mail address which will be shown in DeviseMailer.
|
6
|
+
config.mailer_sender = "please-change-me@config-initializers-devise.com"
|
7
|
+
|
8
|
+
# Configure the class responsible to send e-mails.
|
9
|
+
# config.mailer = "Devise::Mailer"
|
10
|
+
|
11
|
+
# ==> ORM configuration
|
12
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
13
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
14
|
+
# available as additional gems.
|
15
|
+
require "devise/orm/#{DEVISE_ORM}"
|
16
|
+
|
17
|
+
# ==> Configuration for any authentication mechanism
|
18
|
+
# Configure which keys are used when authenticating an user. By default is
|
19
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
20
|
+
# authenticating an user, both parameters are required. Remember that those
|
21
|
+
# parameters are used only when authenticating and not when retrieving from
|
22
|
+
# session. If you need permissions, you should implement that in a before filter.
|
23
|
+
# config.authentication_keys = [ :email ]
|
24
|
+
|
25
|
+
# Tell if authentication through request.params is enabled. True by default.
|
26
|
+
# config.params_authenticatable = true
|
27
|
+
|
28
|
+
# Tell if authentication through HTTP Basic Auth is enabled. True by default.
|
29
|
+
# config.http_authenticatable = true
|
30
|
+
|
31
|
+
# The realm used in Http Basic Authentication
|
32
|
+
# config.http_authentication_realm = "Application"
|
33
|
+
|
34
|
+
# ==> Configuration for :database_authenticatable
|
35
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
36
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
37
|
+
config.stretches = 20
|
38
|
+
|
39
|
+
# Define which will be the encryption algorithm. Devise also supports encryptors
|
40
|
+
# from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
|
41
|
+
# you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
|
42
|
+
# (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
|
43
|
+
config.encryptor = :authlogic_sha512
|
44
|
+
|
45
|
+
# Setup a pepper to generate the encrypted password.
|
46
|
+
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
47
|
+
|
48
|
+
# ==> Configuration for :confirmable
|
49
|
+
# The time you want to give your user to confirm his account. During this time
|
50
|
+
# he will be able to access your application without confirming. Default is nil.
|
51
|
+
# When confirm_within is zero, the user won't be able to sign in without confirming.
|
52
|
+
# You can use this to let your user access some features of your application
|
53
|
+
# without confirming the account, but blocking it after a certain period
|
54
|
+
# (ie 2 days).
|
55
|
+
# config.confirm_within = 2.days
|
56
|
+
|
57
|
+
# ==> Configuration for :rememberable
|
58
|
+
# The time the user will be remembered without asking for credentials again.
|
59
|
+
# config.remember_for = 2.weeks
|
60
|
+
|
61
|
+
# If a valid remember token can be re-used between multiple browsers.
|
62
|
+
# config.remember_across_browsers = true
|
63
|
+
|
64
|
+
# ==> Configuration for :validatable
|
65
|
+
# Range for password length
|
66
|
+
# config.password_length = 6..20
|
67
|
+
|
68
|
+
# Regex to use to validate the email address
|
69
|
+
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
|
70
|
+
|
71
|
+
# ==> Configuration for :timeoutable
|
72
|
+
# The time you want to timeout the user session without activity. After this
|
73
|
+
# time the user will be asked for credentials again.
|
74
|
+
# config.timeout_in = 10.minutes
|
75
|
+
|
76
|
+
# ==> Configuration for :lockable
|
77
|
+
# Defines which strategy will be used to lock an account.
|
78
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
79
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
80
|
+
# config.lock_strategy = :failed_attempts
|
81
|
+
|
82
|
+
# Defines which strategy will be used to unlock an account.
|
83
|
+
# :email = Sends an unlock link to the user email
|
84
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
85
|
+
# :both = Enables both strategies
|
86
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
87
|
+
# config.unlock_strategy = :both
|
88
|
+
|
89
|
+
# Number of authentication tries before locking an account if lock_strategy
|
90
|
+
# is failed attempts.
|
91
|
+
# config.maximum_attempts = 20
|
92
|
+
|
93
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
94
|
+
# config.unlock_in = 1.hour
|
95
|
+
|
96
|
+
# ==> Configuration for :token_authenticatable
|
97
|
+
# Defines name of the authentication token params key
|
98
|
+
# config.token_authentication_key = :auth_token
|
99
|
+
|
100
|
+
# ==> Scopes configuration
|
101
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
102
|
+
# "sessions/users/new". It's turned off by default because it's slower if you
|
103
|
+
# are using only default views.
|
104
|
+
# config.scoped_views = true
|
105
|
+
|
106
|
+
# Configure the default scope given to Warden. By default it's the first
|
107
|
+
# devise role declared in your routes.
|
108
|
+
# config.default_scope = :user
|
109
|
+
|
110
|
+
# Configure sign_out behavior.
|
111
|
+
# By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
|
112
|
+
# In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
|
113
|
+
# config.sign_out_all_scopes = false
|
114
|
+
|
115
|
+
# ==> Navigation configuration
|
116
|
+
# Lists the formats that should be treated as navigational. Formats like
|
117
|
+
# :html, should redirect to the sign in page when the user does not have
|
118
|
+
# access, but formats like :xml or :json, should return 401.
|
119
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
120
|
+
# should add them to the navigational formats lists. Default is [:html]
|
121
|
+
# config.navigational_formats = [:html, :iphone]
|
122
|
+
|
123
|
+
# ==> Warden configuration
|
124
|
+
# If you want to use other strategies, that are not (yet) supported by Devise,
|
125
|
+
# you can configure them inside the config.warden block. The example below
|
126
|
+
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
127
|
+
#
|
128
|
+
# config.warden do |manager|
|
129
|
+
# manager.oauth(:twitter) do |twitter|
|
130
|
+
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
|
131
|
+
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
132
|
+
# twitter.options :site => 'http://twitter.com'
|
133
|
+
# end
|
134
|
+
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
|
135
|
+
# end
|
136
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
# Resources for testing
|
3
|
+
resources :users, :only => [:index] do
|
4
|
+
get :expire, :on => :member
|
5
|
+
get :accept, :on => :member
|
6
|
+
end
|
7
|
+
|
8
|
+
resources :admins, :only => [:index]
|
9
|
+
|
10
|
+
# Users scope
|
11
|
+
devise_for :users do
|
12
|
+
match "/devise_for/sign_in", :to => "devise/sessions#new"
|
13
|
+
end
|
14
|
+
|
15
|
+
as :user do
|
16
|
+
match "/as/sign_in", :to => "devise/sessions#new"
|
17
|
+
end
|
18
|
+
|
19
|
+
match "/sign_in", :to => "devise/sessions#new"
|
20
|
+
|
21
|
+
# Admin scope
|
22
|
+
devise_for :admin, :path => "admin_area", :controllers => { :sessions => "sessions" }, :skip => :passwords
|
23
|
+
|
24
|
+
match "/admin_area/home", :to => "admins#index", :as => :admin_root
|
25
|
+
match "/anywhere", :to => "foo#bar", :as => :new_admin_password
|
26
|
+
|
27
|
+
authenticate(:admin) do
|
28
|
+
match "/private", :to => "home#private", :as => :private
|
29
|
+
end
|
30
|
+
|
31
|
+
# Other routes for routing_test.rb
|
32
|
+
namespace :publisher, :path_names => { :sign_in => "i_don_care", :sign_out => "get_out" } do
|
33
|
+
devise_for :accounts, :class_name => "User", :path_names => { :sign_in => "get_in" }
|
34
|
+
end
|
35
|
+
|
36
|
+
scope ":locale" do
|
37
|
+
devise_for :accounts, :singular => "manager", :class_name => "User",
|
38
|
+
:path_names => {
|
39
|
+
:sign_in => "login", :sign_out => "logout",
|
40
|
+
:password => "secret", :confirmation => "verification",
|
41
|
+
:unlock => "unblock", :sign_up => "register",
|
42
|
+
:registration => "management"
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
root :to => "home#index"
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CreateTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
[:users, :admins, :accounts].each do |table|
|
4
|
+
create_table table do |t|
|
5
|
+
t.database_authenticatable :null => (table == :admins)
|
6
|
+
|
7
|
+
if table != :admin
|
8
|
+
t.string :username
|
9
|
+
t.confirmable
|
10
|
+
t.recoverable
|
11
|
+
t.rememberable
|
12
|
+
t.trackable
|
13
|
+
t.lockable
|
14
|
+
t.token_authenticatable
|
15
|
+
end
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.down
|
23
|
+
[:users, :admins, :accounts].each do |table|
|
24
|
+
drop_table table
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
3
|
+
# then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
+
#
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
11
|
+
|
12
|
+
ActiveRecord::Schema.define(:version => 20100401102949) do
|
13
|
+
|
14
|
+
create_table "accounts", :force => true do |t|
|
15
|
+
t.string "email", :default => "", :null => false
|
16
|
+
t.string "encrypted_password", :default => "", :null => false
|
17
|
+
t.string "password_salt", :default => "", :null => false
|
18
|
+
t.string "username"
|
19
|
+
t.string "confirmation_token"
|
20
|
+
t.datetime "confirmed_at"
|
21
|
+
t.datetime "confirmation_sent_at"
|
22
|
+
t.string "reset_password_token"
|
23
|
+
t.string "remember_token"
|
24
|
+
t.datetime "remember_created_at"
|
25
|
+
t.integer "sign_in_count", :default => 0
|
26
|
+
t.datetime "current_sign_in_at"
|
27
|
+
t.datetime "last_sign_in_at"
|
28
|
+
t.string "current_sign_in_ip"
|
29
|
+
t.string "last_sign_in_ip"
|
30
|
+
t.integer "failed_attempts", :default => 0
|
31
|
+
t.string "unlock_token"
|
32
|
+
t.datetime "locked_at"
|
33
|
+
t.string "authentication_token"
|
34
|
+
t.datetime "created_at"
|
35
|
+
t.datetime "updated_at"
|
36
|
+
end
|
37
|
+
|
38
|
+
create_table "admins", :force => true do |t|
|
39
|
+
t.string "email", :default => ""
|
40
|
+
t.string "encrypted_password", :default => ""
|
41
|
+
t.string "password_salt", :default => ""
|
42
|
+
t.string "username"
|
43
|
+
t.string "confirmation_token"
|
44
|
+
t.datetime "confirmed_at"
|
45
|
+
t.datetime "confirmation_sent_at"
|
46
|
+
t.string "reset_password_token"
|
47
|
+
t.string "remember_token"
|
48
|
+
t.datetime "remember_created_at"
|
49
|
+
t.integer "sign_in_count", :default => 0
|
50
|
+
t.datetime "current_sign_in_at"
|
51
|
+
t.datetime "last_sign_in_at"
|
52
|
+
t.string "current_sign_in_ip"
|
53
|
+
t.string "last_sign_in_ip"
|
54
|
+
t.integer "failed_attempts", :default => 0
|
55
|
+
t.string "unlock_token"
|
56
|
+
t.datetime "locked_at"
|
57
|
+
t.string "authentication_token"
|
58
|
+
t.datetime "created_at"
|
59
|
+
t.datetime "updated_at"
|
60
|
+
end
|
61
|
+
|
62
|
+
create_table "users", :force => true do |t|
|
63
|
+
t.string "email", :default => "", :null => false
|
64
|
+
t.string "encrypted_password", :default => "", :null => false
|
65
|
+
t.string "password_salt", :default => "", :null => false
|
66
|
+
t.string "username"
|
67
|
+
t.string "confirmation_token"
|
68
|
+
t.datetime "confirmed_at"
|
69
|
+
t.datetime "confirmation_sent_at"
|
70
|
+
t.string "reset_password_token"
|
71
|
+
t.string "remember_token"
|
72
|
+
t.datetime "remember_created_at"
|
73
|
+
t.integer "sign_in_count", :default => 0
|
74
|
+
t.datetime "current_sign_in_at"
|
75
|
+
t.datetime "last_sign_in_at"
|
76
|
+
t.string "current_sign_in_ip"
|
77
|
+
t.string "last_sign_in_ip"
|
78
|
+
t.integer "failed_attempts", :default => 0
|
79
|
+
t.string "unlock_token"
|
80
|
+
t.datetime "locked_at"
|
81
|
+
t.string "authentication_token"
|
82
|
+
t.datetime "created_at"
|
83
|
+
t.datetime "updated_at"
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/test/routes_test.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DefaultRoutingTest < ActionController::TestCase
|
4
|
+
test 'map new user session' do
|
5
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => 'users/sign_in', :method => :get})
|
6
|
+
assert_named_route "/users/sign_in", :new_user_session_path
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'map create user session' do
|
10
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'create'}, {:path => 'users/sign_in', :method => :post})
|
11
|
+
assert_named_route "/users/sign_in", :user_session_path
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'map destroy user session' do
|
15
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => 'users/sign_out', :method => :get})
|
16
|
+
assert_named_route "/users/sign_out", :destroy_user_session_path
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'map new user confirmation' do
|
20
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'new'}, 'users/confirmation/new')
|
21
|
+
assert_named_route "/users/confirmation/new", :new_user_confirmation_path
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'map create user confirmation' do
|
25
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'create'}, {:path => 'users/confirmation', :method => :post})
|
26
|
+
assert_named_route "/users/confirmation", :user_confirmation_path
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'map show user confirmation' do
|
30
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => 'users/confirmation', :method => :get})
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'map new user password' do
|
34
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'users/password/new')
|
35
|
+
assert_named_route "/users/password/new", :new_user_password_path
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'map create user password' do
|
39
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => 'users/password', :method => :post})
|
40
|
+
assert_named_route "/users/password", :user_password_path
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'map edit user password' do
|
44
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'edit'}, 'users/password/edit')
|
45
|
+
assert_named_route "/users/password/edit", :edit_user_password_path
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'map update user password' do
|
49
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'update'}, {:path => 'users/password', :method => :put})
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'map new user unlock' do
|
53
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'new'}, 'users/unlock/new')
|
54
|
+
assert_named_route "/users/unlock/new", :new_user_unlock_path
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'map create user unlock' do
|
58
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'create'}, {:path => 'users/unlock', :method => :post})
|
59
|
+
assert_named_route "/users/unlock", :user_unlock_path
|
60
|
+
end
|
61
|
+
|
62
|
+
test 'map show user unlock' do
|
63
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => 'users/unlock', :method => :get})
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'map new user registration' do
|
67
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, 'users/sign_up')
|
68
|
+
assert_named_route "/users/sign_up", :new_user_registration_path
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'map create user registration' do
|
72
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'create'}, {:path => 'users', :method => :post})
|
73
|
+
assert_named_route "/users", :user_registration_path
|
74
|
+
end
|
75
|
+
|
76
|
+
test 'map edit user registration' do
|
77
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'edit'}, {:path => 'users/edit', :method => :get})
|
78
|
+
assert_named_route "/users/edit", :edit_user_registration_path
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'map update user registration' do
|
82
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'update'}, {:path => 'users', :method => :put})
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'map destroy user registration' do
|
86
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'destroy'}, {:path => 'users', :method => :delete})
|
87
|
+
end
|
88
|
+
|
89
|
+
protected
|
90
|
+
|
91
|
+
def assert_named_route(result, name)
|
92
|
+
assert_equal result, @routes.url_helpers.send(name)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class CustomizedRoutingTest < ActionController::TestCase
|
97
|
+
test 'map admin with :path option' do
|
98
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'admin_area/sign_up', :method => :get})
|
99
|
+
end
|
100
|
+
|
101
|
+
test 'map admin with :controllers option' do
|
102
|
+
assert_recognizes({:controller => 'sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
|
103
|
+
end
|
104
|
+
|
105
|
+
test 'does not map admin password' do
|
106
|
+
assert_raise ActionController::RoutingError do
|
107
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'admin_area/password/new')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
test 'map account with custom path name for session sign in' do
|
112
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new', :locale => 'en'}, '/en/accounts/login')
|
113
|
+
end
|
114
|
+
|
115
|
+
test 'map account with custom path name for session sign out' do
|
116
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy', :locale => 'en'}, '/en/accounts/logout')
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'map account with custom path name for password' do
|
120
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new', :locale => 'en'}, '/en/accounts/secret/new')
|
121
|
+
end
|
122
|
+
|
123
|
+
test 'map account with custom path name for confirmation' do
|
124
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'new', :locale => 'en'}, '/en/accounts/verification/new')
|
125
|
+
end
|
126
|
+
|
127
|
+
test 'map account with custom path name for unlock' do
|
128
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'new', :locale => 'en'}, '/en/accounts/unblock/new')
|
129
|
+
end
|
130
|
+
|
131
|
+
test 'map account with custom path name for registration' do
|
132
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
class ScopedRoutingTest < ActionController::TestCase
|
137
|
+
test 'map publisher account' do
|
138
|
+
assert_recognizes({:controller => 'publisher/registrations', :action => 'new'}, {:path => '/publisher/accounts/sign_up', :method => :get})
|
139
|
+
assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
|
140
|
+
end
|
141
|
+
|
142
|
+
test 'map publisher account merges path names' do
|
143
|
+
assert_recognizes({:controller => 'publisher/sessions', :action => 'new'}, {:path => '/publisher/accounts/get_in', :method => :get})
|
144
|
+
assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
|
145
|
+
end
|
146
|
+
end
|