cloudfoundry-devise 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/.gitignore +12 -0
  2. data/.travis.yml +13 -0
  3. data/CHANGELOG.rdoc +755 -0
  4. data/Gemfile +35 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +366 -0
  7. data/Rakefile +34 -0
  8. data/app/controllers/devise/confirmations_controller.rb +46 -0
  9. data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
  10. data/app/controllers/devise/passwords_controller.rb +50 -0
  11. data/app/controllers/devise/registrations_controller.rb +114 -0
  12. data/app/controllers/devise/sessions_controller.rb +49 -0
  13. data/app/controllers/devise/unlocks_controller.rb +34 -0
  14. data/app/helpers/devise_helper.rb +25 -0
  15. data/app/mailers/devise/mailer.rb +15 -0
  16. data/app/views/devise/confirmations/new.html.erb +12 -0
  17. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  18. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  19. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  20. data/app/views/devise/passwords/edit.html.erb +16 -0
  21. data/app/views/devise/passwords/new.html.erb +12 -0
  22. data/app/views/devise/registrations/edit.html.erb +25 -0
  23. data/app/views/devise/registrations/new.html.erb +18 -0
  24. data/app/views/devise/sessions/new.html.erb +17 -0
  25. data/app/views/devise/shared/_links.erb +25 -0
  26. data/app/views/devise/unlocks/new.html.erb +12 -0
  27. data/cloudfoundry-devise.gemspec +25 -0
  28. data/config/locales/en.yml +59 -0
  29. data/lib/devise.rb +453 -0
  30. data/lib/devise/controllers/helpers.rb +260 -0
  31. data/lib/devise/controllers/internal_helpers.rb +161 -0
  32. data/lib/devise/controllers/rememberable.rb +52 -0
  33. data/lib/devise/controllers/scoped_views.rb +33 -0
  34. data/lib/devise/controllers/shared_helpers.rb +26 -0
  35. data/lib/devise/controllers/url_helpers.rb +53 -0
  36. data/lib/devise/delegator.rb +16 -0
  37. data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
  38. data/lib/devise/encryptors/base.rb +20 -0
  39. data/lib/devise/encryptors/clearance_sha1.rb +17 -0
  40. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  41. data/lib/devise/encryptors/sha1.rb +25 -0
  42. data/lib/devise/encryptors/sha512.rb +25 -0
  43. data/lib/devise/failure_app.rb +149 -0
  44. data/lib/devise/hooks/activatable.rb +11 -0
  45. data/lib/devise/hooks/forgetable.rb +9 -0
  46. data/lib/devise/hooks/rememberable.rb +6 -0
  47. data/lib/devise/hooks/timeoutable.rb +24 -0
  48. data/lib/devise/hooks/trackable.rb +9 -0
  49. data/lib/devise/mailers/helpers.rb +86 -0
  50. data/lib/devise/mapping.rb +175 -0
  51. data/lib/devise/models.rb +91 -0
  52. data/lib/devise/models/authenticatable.rb +181 -0
  53. data/lib/devise/models/confirmable.rb +220 -0
  54. data/lib/devise/models/database_authenticatable.rb +122 -0
  55. data/lib/devise/models/encryptable.rb +72 -0
  56. data/lib/devise/models/lockable.rb +169 -0
  57. data/lib/devise/models/omniauthable.rb +23 -0
  58. data/lib/devise/models/recoverable.rb +136 -0
  59. data/lib/devise/models/registerable.rb +21 -0
  60. data/lib/devise/models/rememberable.rb +114 -0
  61. data/lib/devise/models/serializable.rb +43 -0
  62. data/lib/devise/models/timeoutable.rb +45 -0
  63. data/lib/devise/models/token_authenticatable.rb +72 -0
  64. data/lib/devise/models/trackable.rb +30 -0
  65. data/lib/devise/models/validatable.rb +62 -0
  66. data/lib/devise/modules.rb +30 -0
  67. data/lib/devise/omniauth.rb +28 -0
  68. data/lib/devise/omniauth/config.rb +45 -0
  69. data/lib/devise/omniauth/url_helpers.rb +33 -0
  70. data/lib/devise/orm/active_record.rb +44 -0
  71. data/lib/devise/orm/mongoid.rb +31 -0
  72. data/lib/devise/param_filter.rb +41 -0
  73. data/lib/devise/path_checker.rb +18 -0
  74. data/lib/devise/rails.rb +73 -0
  75. data/lib/devise/rails/routes.rb +385 -0
  76. data/lib/devise/rails/warden_compat.rb +120 -0
  77. data/lib/devise/schema.rb +109 -0
  78. data/lib/devise/strategies/authenticatable.rb +155 -0
  79. data/lib/devise/strategies/base.rb +15 -0
  80. data/lib/devise/strategies/database_authenticatable.rb +21 -0
  81. data/lib/devise/strategies/rememberable.rb +53 -0
  82. data/lib/devise/strategies/token_authenticatable.rb +57 -0
  83. data/lib/devise/test_helpers.rb +90 -0
  84. data/lib/devise/version.rb +3 -0
  85. data/lib/generators/active_record/devise_generator.rb +71 -0
  86. data/lib/generators/active_record/templates/migration.rb +29 -0
  87. data/lib/generators/active_record/templates/migration_existing.rb +26 -0
  88. data/lib/generators/devise/devise_generator.rb +22 -0
  89. data/lib/generators/devise/install_generator.rb +24 -0
  90. data/lib/generators/devise/orm_helpers.rb +31 -0
  91. data/lib/generators/devise/views_generator.rb +98 -0
  92. data/lib/generators/mongoid/devise_generator.rb +60 -0
  93. data/lib/generators/templates/README +32 -0
  94. data/lib/generators/templates/devise.rb +215 -0
  95. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  96. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  97. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  98. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
  99. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
  100. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
  101. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
  102. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
  103. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
  104. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
  105. data/test/controllers/helpers_test.rb +254 -0
  106. data/test/controllers/internal_helpers_test.rb +96 -0
  107. data/test/controllers/sessions_controller_test.rb +16 -0
  108. data/test/controllers/url_helpers_test.rb +59 -0
  109. data/test/delegator_test.rb +19 -0
  110. data/test/devise_test.rb +72 -0
  111. data/test/encryptors_test.rb +30 -0
  112. data/test/failure_app_test.rb +207 -0
  113. data/test/generators/active_record_generator_test.rb +47 -0
  114. data/test/generators/devise_generator_test.rb +39 -0
  115. data/test/generators/install_generator_test.rb +13 -0
  116. data/test/generators/mongoid_generator_test.rb +23 -0
  117. data/test/generators/views_generator_test.rb +52 -0
  118. data/test/helpers/devise_helper_test.rb +51 -0
  119. data/test/indifferent_hash.rb +33 -0
  120. data/test/integration/authenticatable_test.rb +590 -0
  121. data/test/integration/confirmable_test.rb +262 -0
  122. data/test/integration/database_authenticatable_test.rb +82 -0
  123. data/test/integration/http_authenticatable_test.rb +82 -0
  124. data/test/integration/lockable_test.rb +212 -0
  125. data/test/integration/omniauthable_test.rb +133 -0
  126. data/test/integration/recoverable_test.rb +287 -0
  127. data/test/integration/registerable_test.rb +335 -0
  128. data/test/integration/rememberable_test.rb +158 -0
  129. data/test/integration/timeoutable_test.rb +98 -0
  130. data/test/integration/token_authenticatable_test.rb +148 -0
  131. data/test/integration/trackable_test.rb +92 -0
  132. data/test/mailers/confirmation_instructions_test.rb +95 -0
  133. data/test/mailers/reset_password_instructions_test.rb +83 -0
  134. data/test/mailers/unlock_instructions_test.rb +77 -0
  135. data/test/mapping_test.rb +128 -0
  136. data/test/models/confirmable_test.rb +334 -0
  137. data/test/models/database_authenticatable_test.rb +167 -0
  138. data/test/models/encryptable_test.rb +67 -0
  139. data/test/models/lockable_test.rb +225 -0
  140. data/test/models/recoverable_test.rb +198 -0
  141. data/test/models/rememberable_test.rb +168 -0
  142. data/test/models/serializable_test.rb +38 -0
  143. data/test/models/timeoutable_test.rb +42 -0
  144. data/test/models/token_authenticatable_test.rb +49 -0
  145. data/test/models/trackable_test.rb +5 -0
  146. data/test/models/validatable_test.rb +113 -0
  147. data/test/models_test.rb +109 -0
  148. data/test/omniauth/config_test.rb +57 -0
  149. data/test/omniauth/url_helpers_test.rb +58 -0
  150. data/test/orm/active_record.rb +9 -0
  151. data/test/orm/mongoid.rb +14 -0
  152. data/test/rails_app/Rakefile +10 -0
  153. data/test/rails_app/app/active_record/admin.rb +6 -0
  154. data/test/rails_app/app/active_record/shim.rb +2 -0
  155. data/test/rails_app/app/active_record/user.rb +6 -0
  156. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  157. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  158. data/test/rails_app/app/controllers/application_controller.rb +8 -0
  159. data/test/rails_app/app/controllers/home_controller.rb +25 -0
  160. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  161. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  162. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  163. data/test/rails_app/app/controllers/users_controller.rb +23 -0
  164. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  165. data/test/rails_app/app/mailers/users/mailer.rb +3 -0
  166. data/test/rails_app/app/mongoid/admin.rb +24 -0
  167. data/test/rails_app/app/mongoid/shim.rb +24 -0
  168. data/test/rails_app/app/mongoid/user.rb +45 -0
  169. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  170. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  171. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  172. data/test/rails_app/app/views/home/index.html.erb +1 -0
  173. data/test/rails_app/app/views/home/join.html.erb +1 -0
  174. data/test/rails_app/app/views/home/private.html.erb +1 -0
  175. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  176. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  177. data/test/rails_app/app/views/users/index.html.erb +1 -0
  178. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  179. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  180. data/test/rails_app/config.ru +4 -0
  181. data/test/rails_app/config/application.rb +41 -0
  182. data/test/rails_app/config/boot.rb +8 -0
  183. data/test/rails_app/config/database.yml +18 -0
  184. data/test/rails_app/config/environment.rb +5 -0
  185. data/test/rails_app/config/environments/development.rb +18 -0
  186. data/test/rails_app/config/environments/production.rb +33 -0
  187. data/test/rails_app/config/environments/test.rb +33 -0
  188. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  189. data/test/rails_app/config/initializers/devise.rb +197 -0
  190. data/test/rails_app/config/initializers/inflections.rb +2 -0
  191. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  192. data/test/rails_app/config/routes.rb +87 -0
  193. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +71 -0
  194. data/test/rails_app/db/schema.rb +52 -0
  195. data/test/rails_app/lib/shared_admin.rb +10 -0
  196. data/test/rails_app/lib/shared_user.rb +26 -0
  197. data/test/rails_app/public/404.html +26 -0
  198. data/test/rails_app/public/422.html +26 -0
  199. data/test/rails_app/public/500.html +26 -0
  200. data/test/rails_app/public/favicon.ico +0 -0
  201. data/test/rails_app/script/rails +10 -0
  202. data/test/routes_test.rb +240 -0
  203. data/test/support/assertions.rb +27 -0
  204. data/test/support/helpers.rb +109 -0
  205. data/test/support/integration.rb +88 -0
  206. data/test/support/locale/en.yml +4 -0
  207. data/test/support/webrat/integrations/rails.rb +24 -0
  208. data/test/test_helper.rb +27 -0
  209. data/test/test_helpers_test.rb +134 -0
  210. metadata +295 -0
@@ -0,0 +1,2 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
2
+ Rails.application.config.session_store :cookie_store, :key => "_my_app"
@@ -0,0 +1,87 @@
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
+
7
+ authenticate do
8
+ post :exhibit, :on => :member
9
+ end
10
+ end
11
+
12
+ resources :admins, :only => [:index]
13
+
14
+ # Users scope
15
+ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
16
+ match "/devise_for/sign_in", :to => "devise/sessions#new"
17
+ end
18
+
19
+ as :user do
20
+ match "/as/sign_in", :to => "devise/sessions#new"
21
+ end
22
+
23
+ match "/sign_in", :to => "devise/sessions#new"
24
+
25
+ # Admin scope
26
+ devise_for :admin, :path => "admin_area", :controllers => { :sessions => :"admins/sessions" }, :skip => :passwords
27
+
28
+ match "/admin_area/home", :to => "admins#index", :as => :admin_root
29
+ match "/anywhere", :to => "foo#bar", :as => :new_admin_password
30
+
31
+ authenticate(:admin) do
32
+ match "/private", :to => "home#private", :as => :private
33
+ end
34
+
35
+ authenticated :admin do
36
+ match "/dashboard", :to => "home#admin_dashboard"
37
+ end
38
+
39
+ authenticated do
40
+ match "/dashboard", :to => "home#user_dashboard"
41
+ end
42
+
43
+ unauthenticated do
44
+ match "/join", :to => "home#join"
45
+ end
46
+
47
+ # Routes for constraints testing
48
+ devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
49
+
50
+ constraints(:host => /192\.168\.1\.\d\d\d/) do
51
+ devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
52
+ end
53
+
54
+ devise_for :skip_admin, :class_name => "Admin", :skip => :all
55
+
56
+ # Routes for format=false testing
57
+ devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
58
+ devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
59
+
60
+ # Other routes for routing_test.rb
61
+ devise_for :reader, :class_name => "User", :only => :passwords
62
+
63
+ namespace :publisher, :path_names => { :sign_in => "i_dont_care", :sign_out => "get_out" } do
64
+ devise_for :accounts, :class_name => "Admin", :path_names => { :sign_in => "get_in" }
65
+ end
66
+
67
+ scope ":locale" do
68
+ devise_for :accounts, :singular => "manager", :class_name => "Admin",
69
+ :path_names => {
70
+ :sign_in => "login", :sign_out => "logout",
71
+ :password => "secret", :confirmation => "verification",
72
+ :unlock => "unblock", :sign_up => "register",
73
+ :registration => "management", :cancel => "giveup"
74
+ }, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }
75
+ end
76
+
77
+ namespace :sign_out_via, :module => "devise" do
78
+ devise_for :deletes, :sign_out_via => :delete, :class_name => "Admin"
79
+ devise_for :posts, :sign_out_via => :post, :class_name => "Admin"
80
+ devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "Admin"
81
+ end
82
+
83
+ match "/set", :to => "home#set"
84
+ match "/unauthenticated", :to => "home#unauthenticated"
85
+
86
+ root :to => "home#index"
87
+ end
@@ -0,0 +1,71 @@
1
+ class CreateTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :username
5
+ t.string :facebook_token
6
+
7
+ ## Database authenticatable
8
+ t.string :email, :null => false, :default => ""
9
+ t.string :encrypted_password, :null => false, :default => ""
10
+
11
+ ## Recoverable
12
+ t.string :reset_password_token
13
+ t.datetime :reset_password_sent_at
14
+
15
+ ## Rememberable
16
+ t.datetime :remember_created_at
17
+
18
+ ## Trackable
19
+ t.integer :sign_in_count, :default => 0
20
+ t.datetime :current_sign_in_at
21
+ t.datetime :last_sign_in_at
22
+ t.string :current_sign_in_ip
23
+ t.string :last_sign_in_ip
24
+
25
+ ## Encryptable
26
+ # t.string :password_salt
27
+
28
+ ## Confirmable
29
+ t.string :confirmation_token
30
+ t.datetime :confirmed_at
31
+ t.datetime :confirmation_sent_at
32
+ # t.string :unconfirmed_email # Only if using reconfirmable
33
+
34
+ ## Lockable
35
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
36
+ t.string :unlock_token # Only if unlock strategy is :email or :both
37
+ t.datetime :locked_at
38
+
39
+ # Token authenticatable
40
+ t.string :authentication_token
41
+
42
+ t.timestamps
43
+ end
44
+
45
+ create_table :admins do |t|
46
+ ## Database authenticatable
47
+ t.string :email, :null => true
48
+ t.string :encrypted_password, :null => true
49
+
50
+ ## Recoverable
51
+ t.string :reset_password_token
52
+ t.datetime :reset_password_sent_at
53
+
54
+ ## Rememberable
55
+ t.datetime :remember_created_at
56
+
57
+ ## Encryptable
58
+ t.string :password_salt
59
+
60
+ ## Lockable
61
+ t.datetime :locked_at
62
+
63
+ t.timestamps
64
+ end
65
+ end
66
+
67
+ def self.down
68
+ drop_table :users
69
+ drop_table :admins
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20100401102949) do
14
+
15
+ create_table "admins", :force => true do |t|
16
+ t.string "email"
17
+ t.string "encrypted_password", :limit => 128
18
+ t.string "password_salt"
19
+ t.string "remember_token"
20
+ t.datetime "remember_created_at"
21
+ t.string "reset_password_token"
22
+ t.integer "failed_attempts", :default => 0
23
+ t.string "unlock_token"
24
+ t.datetime "locked_at"
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ create_table "users", :force => true do |t|
30
+ t.string "username"
31
+ t.string "facebook_token"
32
+ t.string "email", :default => "", :null => false
33
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
34
+ t.string "confirmation_token"
35
+ t.datetime "confirmed_at"
36
+ t.datetime "confirmation_sent_at"
37
+ t.string "reset_password_token"
38
+ t.datetime "remember_created_at"
39
+ t.integer "sign_in_count", :default => 0
40
+ t.datetime "current_sign_in_at"
41
+ t.datetime "last_sign_in_at"
42
+ t.string "current_sign_in_ip"
43
+ t.string "last_sign_in_ip"
44
+ t.integer "failed_attempts", :default => 0
45
+ t.string "unlock_token"
46
+ t.datetime "locked_at"
47
+ t.string "authentication_token"
48
+ t.datetime "created_at"
49
+ t.datetime "updated_at"
50
+ end
51
+
52
+ end
@@ -0,0 +1,10 @@
1
+ module SharedAdmin
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :database_authenticatable, :encryptable, :registerable,
6
+ :timeoutable, :recoverable, :lockable,
7
+ :unlock_strategy => :time, :lock_strategy => :none
8
+ end
9
+
10
+ end
@@ -0,0 +1,26 @@
1
+ module SharedUser
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
6
+ :registerable, :rememberable, :timeoutable, :token_authenticatable,
7
+ :trackable, :validatable, :omniauthable
8
+
9
+ attr_accessor :other_key
10
+ attr_accessible :username, :email, :password, :password_confirmation, :remember_me
11
+
12
+ # They need to be included after Devise is called.
13
+ extend ExtendMethods
14
+ end
15
+
16
+ module ExtendMethods
17
+ def new_with_session(params, session)
18
+ super.tap do |user|
19
+ if data = session["devise.facebook_data"]
20
+ user.email = data["email"]
21
+ user.confirmed_at = Time.now
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENV_PATH = File.expand_path('../../config/environment', __FILE__)
5
+ BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
6
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
7
+ ROOT_PATH = File.expand_path('../..', __FILE__)
8
+
9
+ require BOOT_PATH
10
+ require 'rails/commands'
@@ -0,0 +1,240 @@
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
+ test 'map cancel user registration' do
90
+ assert_recognizes({:controller => 'devise/registrations', :action => 'cancel'}, {:path => 'users/cancel', :method => :get})
91
+ assert_named_route "/users/cancel", :cancel_user_registration_path
92
+ end
93
+
94
+ test 'map omniauth callbacks' do
95
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :get})
96
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :post})
97
+ assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
98
+
99
+ # named open_id
100
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :get})
101
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :post})
102
+ assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
103
+
104
+ assert_raise ActionController::RoutingError do
105
+ assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
106
+ end
107
+ end
108
+
109
+ protected
110
+
111
+ def assert_named_route(result, *args)
112
+ assert_equal result, @routes.url_helpers.send(*args)
113
+ end
114
+ end
115
+
116
+ class CustomizedRoutingTest < ActionController::TestCase
117
+ test 'map admin with :path option' do
118
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'admin_area/sign_up', :method => :get})
119
+ end
120
+
121
+ test 'map admin with :controllers option' do
122
+ assert_recognizes({:controller => 'admins/sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
123
+ end
124
+
125
+ test 'does not map admin password' do
126
+ assert_raise ActionController::RoutingError do
127
+ assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'admin_area/password/new')
128
+ end
129
+ end
130
+
131
+ test 'does only map reader password' do
132
+ assert_raise ActionController::RoutingError do
133
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, 'reader/sessions/new')
134
+ end
135
+ assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'reader/password/new')
136
+ end
137
+
138
+ test 'map account with custom path name for session sign in' do
139
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new', :locale => 'en'}, '/en/accounts/login')
140
+ end
141
+
142
+ test 'map account with custom path name for session sign out' do
143
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy', :locale => 'en'}, '/en/accounts/logout')
144
+ end
145
+
146
+ test 'map account with custom path name for password' do
147
+ assert_recognizes({:controller => 'devise/passwords', :action => 'new', :locale => 'en'}, '/en/accounts/secret/new')
148
+ end
149
+
150
+ test 'map account with custom path name for registration' do
151
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
152
+ end
153
+
154
+ test 'map account with custom path name for cancel registration' do
155
+ assert_recognizes({:controller => 'devise/registrations', :action => 'cancel', :locale => 'en'}, '/en/accounts/management/giveup')
156
+ end
157
+
158
+ test 'map deletes with :sign_out_via option' do
159
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :delete})
160
+ assert_raise ActionController::RoutingError do
161
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :get})
162
+ end
163
+ end
164
+
165
+ test 'map posts with :sign_out_via option' do
166
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :post})
167
+ assert_raise ActionController::RoutingError do
168
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :get})
169
+ end
170
+ end
171
+
172
+ test 'map delete_or_posts with :sign_out_via option' do
173
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :post})
174
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :delete})
175
+ assert_raise ActionController::RoutingError do
176
+ assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
177
+ end
178
+ end
179
+
180
+ test 'map with constraints defined in hash' do
181
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/headquarters/sign_up', :method => :get})
182
+ assert_raise ActionController::RoutingError do
183
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100/headquarters/sign_up', :method => :get})
184
+ end
185
+ end
186
+
187
+ test 'map with constraints defined in block' do
188
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/homebase/sign_up', :method => :get})
189
+ assert_raise ActionController::RoutingError do
190
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100//homebase/sign_up', :method => :get})
191
+ end
192
+ end
193
+
194
+ test 'map with format false for sessions' do
195
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in', :method => :get})
196
+ assert_raise ActionController::RoutingError do
197
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in.xml', :method => :get})
198
+ end
199
+ end
200
+
201
+ test 'map with format false for passwords' do
202
+ assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password', :method => :post})
203
+ assert_raise ActionController::RoutingError do
204
+ assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password.xml', :method => :post})
205
+ end
206
+ end
207
+
208
+ test 'map with format false for registrations' do
209
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up', :method => :get})
210
+ assert_raise ActionController::RoutingError do
211
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up.xml', :method => :get})
212
+ end
213
+ end
214
+
215
+ test 'map with format false for confirmations' do
216
+ assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation', :method => :get})
217
+ assert_raise ActionController::RoutingError do
218
+ assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation.xml', :method => :get})
219
+ end
220
+ end
221
+
222
+ test 'map with format false for unlocks' do
223
+ assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock', :method => :get})
224
+ assert_raise ActionController::RoutingError do
225
+ assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
226
+ end
227
+ end
228
+ end
229
+
230
+ class ScopedRoutingTest < ActionController::TestCase
231
+ test 'map publisher account' do
232
+ assert_recognizes({:controller => 'publisher/registrations', :action => 'new'}, {:path => '/publisher/accounts/sign_up', :method => :get})
233
+ assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
234
+ end
235
+
236
+ test 'map publisher account merges path names' do
237
+ assert_recognizes({:controller => 'publisher/sessions', :action => 'new'}, {:path => '/publisher/accounts/get_in', :method => :get})
238
+ assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
239
+ end
240
+ end