devise-edge 1.2.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGELOG.rdoc +500 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +335 -0
  4. data/app/controllers/devise/confirmations_controller.rb +33 -0
  5. data/app/controllers/devise/oauth_callbacks_controller.rb +4 -0
  6. data/app/controllers/devise/passwords_controller.rb +41 -0
  7. data/app/controllers/devise/registrations_controller.rb +75 -0
  8. data/app/controllers/devise/sessions_controller.rb +23 -0
  9. data/app/controllers/devise/unlocks_controller.rb +34 -0
  10. data/app/helpers/devise_helper.rb +17 -0
  11. data/app/mailers/devise/mailer.rb +88 -0
  12. data/app/views/devise/confirmations/new.html.erb +12 -0
  13. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  14. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  15. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  16. data/app/views/devise/passwords/edit.html.erb +16 -0
  17. data/app/views/devise/passwords/new.html.erb +12 -0
  18. data/app/views/devise/registrations/edit.html.erb +25 -0
  19. data/app/views/devise/registrations/new.html.erb +18 -0
  20. data/app/views/devise/sessions/new.html.erb +17 -0
  21. data/app/views/devise/shared/_links.erb +25 -0
  22. data/app/views/devise/unlocks/new.html.erb +12 -0
  23. data/config/locales/en.yml +42 -0
  24. data/lib/devise.rb +371 -0
  25. data/lib/devise/controllers/helpers.rb +261 -0
  26. data/lib/devise/controllers/internal_helpers.rb +113 -0
  27. data/lib/devise/controllers/scoped_views.rb +33 -0
  28. data/lib/devise/controllers/url_helpers.rb +39 -0
  29. data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
  30. data/lib/devise/encryptors/base.rb +20 -0
  31. data/lib/devise/encryptors/clearance_sha1.rb +17 -0
  32. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  33. data/lib/devise/encryptors/sha1.rb +25 -0
  34. data/lib/devise/encryptors/sha512.rb +25 -0
  35. data/lib/devise/failure_app.rb +126 -0
  36. data/lib/devise/hooks/activatable.rb +11 -0
  37. data/lib/devise/hooks/forgetable.rb +12 -0
  38. data/lib/devise/hooks/rememberable.rb +45 -0
  39. data/lib/devise/hooks/timeoutable.rb +22 -0
  40. data/lib/devise/hooks/trackable.rb +9 -0
  41. data/lib/devise/mapping.rb +105 -0
  42. data/lib/devise/models.rb +66 -0
  43. data/lib/devise/models/authenticatable.rb +143 -0
  44. data/lib/devise/models/confirmable.rb +160 -0
  45. data/lib/devise/models/database_authenticatable.rb +94 -0
  46. data/lib/devise/models/encryptable.rb +65 -0
  47. data/lib/devise/models/lockable.rb +168 -0
  48. data/lib/devise/models/oauthable.rb +49 -0
  49. data/lib/devise/models/recoverable.rb +83 -0
  50. data/lib/devise/models/registerable.rb +21 -0
  51. data/lib/devise/models/rememberable.rb +122 -0
  52. data/lib/devise/models/timeoutable.rb +33 -0
  53. data/lib/devise/models/token_authenticatable.rb +72 -0
  54. data/lib/devise/models/trackable.rb +30 -0
  55. data/lib/devise/models/validatable.rb +60 -0
  56. data/lib/devise/modules.rb +30 -0
  57. data/lib/devise/oauth.rb +41 -0
  58. data/lib/devise/oauth/config.rb +33 -0
  59. data/lib/devise/oauth/helpers.rb +18 -0
  60. data/lib/devise/oauth/internal_helpers.rb +182 -0
  61. data/lib/devise/oauth/test_helpers.rb +29 -0
  62. data/lib/devise/oauth/url_helpers.rb +35 -0
  63. data/lib/devise/orm/active_record.rb +36 -0
  64. data/lib/devise/orm/mongo_mapper.rb +46 -0
  65. data/lib/devise/orm/mongoid.rb +29 -0
  66. data/lib/devise/path_checker.rb +18 -0
  67. data/lib/devise/rails.rb +67 -0
  68. data/lib/devise/rails/routes.rb +260 -0
  69. data/lib/devise/rails/warden_compat.rb +42 -0
  70. data/lib/devise/schema.rb +96 -0
  71. data/lib/devise/strategies/authenticatable.rb +150 -0
  72. data/lib/devise/strategies/base.rb +15 -0
  73. data/lib/devise/strategies/database_authenticatable.rb +21 -0
  74. data/lib/devise/strategies/rememberable.rb +51 -0
  75. data/lib/devise/strategies/token_authenticatable.rb +53 -0
  76. data/lib/devise/test_helpers.rb +100 -0
  77. data/lib/devise/version.rb +3 -0
  78. data/lib/generators/active_record/devise_generator.rb +28 -0
  79. data/lib/generators/active_record/templates/migration.rb +30 -0
  80. data/lib/generators/devise/devise_generator.rb +17 -0
  81. data/lib/generators/devise/install_generator.rb +24 -0
  82. data/lib/generators/devise/orm_helpers.rb +24 -0
  83. data/lib/generators/devise/views_generator.rb +63 -0
  84. data/lib/generators/mongoid/devise_generator.rb +17 -0
  85. data/lib/generators/templates/README +25 -0
  86. data/lib/generators/templates/devise.rb +168 -0
  87. data/test/controllers/helpers_test.rb +220 -0
  88. data/test/controllers/internal_helpers_test.rb +56 -0
  89. data/test/controllers/url_helpers_test.rb +59 -0
  90. data/test/devise_test.rb +65 -0
  91. data/test/encryptors_test.rb +30 -0
  92. data/test/failure_app_test.rb +148 -0
  93. data/test/integration/authenticatable_test.rb +424 -0
  94. data/test/integration/confirmable_test.rb +104 -0
  95. data/test/integration/database_authenticatable_test.rb +38 -0
  96. data/test/integration/http_authenticatable_test.rb +64 -0
  97. data/test/integration/lockable_test.rb +109 -0
  98. data/test/integration/oauthable_test.rb +258 -0
  99. data/test/integration/recoverable_test.rb +141 -0
  100. data/test/integration/registerable_test.rb +179 -0
  101. data/test/integration/rememberable_test.rb +179 -0
  102. data/test/integration/timeoutable_test.rb +80 -0
  103. data/test/integration/token_authenticatable_test.rb +99 -0
  104. data/test/integration/trackable_test.rb +64 -0
  105. data/test/mailers/confirmation_instructions_test.rb +84 -0
  106. data/test/mailers/reset_password_instructions_test.rb +72 -0
  107. data/test/mailers/unlock_instructions_test.rb +66 -0
  108. data/test/mapping_test.rb +95 -0
  109. data/test/models/confirmable_test.rb +221 -0
  110. data/test/models/database_authenticatable_test.rb +82 -0
  111. data/test/models/encryptable_test.rb +65 -0
  112. data/test/models/lockable_test.rb +204 -0
  113. data/test/models/oauthable_test.rb +21 -0
  114. data/test/models/recoverable_test.rb +155 -0
  115. data/test/models/rememberable_test.rb +271 -0
  116. data/test/models/timeoutable_test.rb +28 -0
  117. data/test/models/token_authenticatable_test.rb +37 -0
  118. data/test/models/trackable_test.rb +5 -0
  119. data/test/models/validatable_test.rb +99 -0
  120. data/test/models_test.rb +77 -0
  121. data/test/oauth/config_test.rb +44 -0
  122. data/test/oauth/url_helpers_test.rb +47 -0
  123. data/test/orm/active_record.rb +9 -0
  124. data/test/orm/mongoid.rb +10 -0
  125. data/test/rails_app/app/active_record/admin.rb +6 -0
  126. data/test/rails_app/app/active_record/shim.rb +2 -0
  127. data/test/rails_app/app/active_record/user.rb +8 -0
  128. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  129. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  130. data/test/rails_app/app/controllers/application_controller.rb +9 -0
  131. data/test/rails_app/app/controllers/home_controller.rb +12 -0
  132. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  133. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  134. data/test/rails_app/app/controllers/users_controller.rb +18 -0
  135. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  136. data/test/rails_app/app/mongoid/admin.rb +9 -0
  137. data/test/rails_app/app/mongoid/shim.rb +24 -0
  138. data/test/rails_app/app/mongoid/user.rb +10 -0
  139. data/test/rails_app/config/application.rb +35 -0
  140. data/test/rails_app/config/boot.rb +13 -0
  141. data/test/rails_app/config/environment.rb +5 -0
  142. data/test/rails_app/config/environments/development.rb +19 -0
  143. data/test/rails_app/config/environments/production.rb +33 -0
  144. data/test/rails_app/config/environments/test.rb +33 -0
  145. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  146. data/test/rails_app/config/initializers/devise.rb +172 -0
  147. data/test/rails_app/config/initializers/inflections.rb +2 -0
  148. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  149. data/test/rails_app/config/routes.rb +54 -0
  150. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +31 -0
  151. data/test/rails_app/db/schema.rb +52 -0
  152. data/test/rails_app/lib/shared_admin.rb +9 -0
  153. data/test/rails_app/lib/shared_user.rb +48 -0
  154. data/test/routes_test.rb +189 -0
  155. data/test/support/assertions.rb +24 -0
  156. data/test/support/helpers.rb +60 -0
  157. data/test/support/integration.rb +88 -0
  158. data/test/support/webrat/integrations/rails.rb +24 -0
  159. data/test/test_helper.rb +23 -0
  160. data/test/test_helpers_test.rb +101 -0
  161. metadata +335 -0
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ class TimeoutableTest < ActiveSupport::TestCase
4
+
5
+ test 'should be expired' do
6
+ assert new_user.timedout?(31.minutes.ago)
7
+ end
8
+
9
+ test 'should not be expired' do
10
+ assert_not new_user.timedout?(29.minutes.ago)
11
+ end
12
+
13
+ test 'should not be expired when params is nil' do
14
+ assert_not new_user.timedout?(nil)
15
+ end
16
+
17
+ test 'fallback to Devise config option' do
18
+ swap Devise, :timeout_in => 1.minute do
19
+ user = new_user
20
+ assert user.timedout?(2.minutes.ago)
21
+ assert_not user.timedout?(30.seconds.ago)
22
+
23
+ Devise.timeout_in = 5.minutes
24
+ assert_not user.timedout?(2.minutes.ago)
25
+ assert user.timedout?(6.minutes.ago)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class TokenAuthenticatableTest < ActiveSupport::TestCase
4
+
5
+ test 'should reset authentication token' do
6
+ user = new_user
7
+ user.reset_authentication_token
8
+ previous_token = user.authentication_token
9
+ user.reset_authentication_token
10
+ assert_not_equal previous_token, user.authentication_token
11
+ end
12
+
13
+ test 'should ensure authentication token' do
14
+ user = new_user
15
+ user.ensure_authentication_token
16
+ previous_token = user.authentication_token
17
+ user.ensure_authentication_token
18
+ assert_equal previous_token, user.authentication_token
19
+ end
20
+
21
+ test 'should authenticate a valid user with authentication token and return it' do
22
+ user = create_user
23
+ user.ensure_authentication_token!
24
+ user.confirm!
25
+ authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token)
26
+ assert_equal authenticated_user, user
27
+ end
28
+
29
+ test 'should return nil when authenticating an invalid user by authentication token' do
30
+ user = create_user
31
+ user.ensure_authentication_token!
32
+ user.confirm!
33
+ authenticated_user = User.find_for_token_authentication(:auth_token => user.authentication_token.reverse)
34
+ assert_nil authenticated_user
35
+ end
36
+
37
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class TrackableTest < ActiveSupport::TestCase
4
+
5
+ end
@@ -0,0 +1,99 @@
1
+ require 'test_helper'
2
+
3
+ class ValidatableTest < ActiveSupport::TestCase
4
+ test 'should require email to be set' do
5
+ user = new_user(:email => nil)
6
+ assert user.invalid?
7
+ assert user.errors[:email]
8
+ assert_equal 'can\'t be blank', user.errors[:email].join
9
+ end
10
+
11
+ test 'should require uniqueness of email, allowing blank' do
12
+ existing_user = create_user
13
+
14
+ user = new_user(:email => '')
15
+ assert user.invalid?
16
+ assert_no_match(/taken/, user.errors[:email].join)
17
+
18
+ user.email = existing_user.email
19
+ assert user.invalid?
20
+ assert_match(/taken/, user.errors[:email].join)
21
+ end
22
+
23
+ test 'should require correct email format, allowing blank' do
24
+ user = new_user(:email => '')
25
+ assert user.invalid?
26
+ assert_not_equal 'is invalid', user.errors[:email].join
27
+
28
+ %w(invalid_email_format email@invalid invalid$character@mail.com other@not 123).each do |email|
29
+ user.email = email
30
+ assert user.invalid?, 'should be invalid with email ' << email
31
+ assert_equal 'is invalid', user.errors[:email].join
32
+ end
33
+ end
34
+
35
+ test 'should accept valid emails' do
36
+ %w(a.b.c@example.com test_mail@gmail.com any@any.net email@test.br 123@mail.test).each do |email|
37
+ user = new_user(:email => email)
38
+ assert user.valid?, 'should be valid with email ' << email
39
+ assert_blank user.errors[:email]
40
+ end
41
+ end
42
+
43
+ test 'should require password to be set when creating a new record' do
44
+ user = new_user(:password => '', :password_confirmation => '')
45
+ assert user.invalid?
46
+ assert_equal 'can\'t be blank', user.errors[:password].join
47
+ end
48
+
49
+ test 'should require confirmation to be set when creating a new record' do
50
+ user = new_user(:password => 'new_password', :password_confirmation => 'blabla')
51
+ assert user.invalid?
52
+ assert_equal 'doesn\'t match confirmation', user.errors[:password].join
53
+ end
54
+
55
+ test 'should require password when updating/reseting password' do
56
+ user = create_user
57
+
58
+ user.password = ''
59
+ user.password_confirmation = ''
60
+
61
+ assert user.invalid?
62
+ assert_equal 'can\'t be blank', user.errors[:password].join
63
+ end
64
+
65
+ test 'should require confirmation when updating/reseting password' do
66
+ user = create_user
67
+ user.password_confirmation = 'another_password'
68
+ assert user.invalid?
69
+ assert_equal 'doesn\'t match confirmation', user.errors[:password].join
70
+ end
71
+
72
+ test 'should require a password with minimum of 6 characters' do
73
+ user = new_user(:password => '12345', :password_confirmation => '12345')
74
+ assert user.invalid?
75
+ assert_equal 'is too short (minimum is 6 characters)', user.errors[:password].join
76
+ end
77
+
78
+ test 'should require a password with maximum of 20 characters long' do
79
+ user = new_user(:password => 'x'*21, :password_confirmation => 'x'*21)
80
+ assert user.invalid?
81
+ assert_equal 'is too long (maximum is 20 characters)', user.errors[:password].join
82
+ end
83
+
84
+ test 'should not require password length when it\'s not changed' do
85
+ user = create_user.reload
86
+ user.password = user.password_confirmation = nil
87
+ assert user.valid?
88
+
89
+ user.password_confirmation = 'confirmation'
90
+ assert user.invalid?
91
+ assert_not (user.errors[:password].join =~ /is too long/)
92
+ end
93
+
94
+ test 'shuold not be included in objects with invalid API' do
95
+ assert_raise RuntimeError do
96
+ Class.new.send :include, Devise::Models::Validatable
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,77 @@
1
+ require 'test_helper'
2
+
3
+ class Configurable < User
4
+ devise :database_authenticatable, :encryptable, :confirmable, :rememberable, :timeoutable, :lockable,
5
+ :stretches => 15, :pepper => 'abcdef', :confirm_within => 5.days,
6
+ :remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
7
+ end
8
+
9
+ class Inheritable < Admin
10
+ end
11
+
12
+ class ActiveRecordTest < ActiveSupport::TestCase
13
+ def include_module?(klass, mod)
14
+ klass.devise_modules.include?(mod) &&
15
+ klass.included_modules.include?(Devise::Models::const_get(mod.to_s.classify))
16
+ end
17
+
18
+ def assert_include_modules(klass, *modules)
19
+ modules.each do |mod|
20
+ assert include_module?(klass, mod)
21
+ end
22
+
23
+ (Devise::ALL - modules).each do |mod|
24
+ assert_not include_module?(klass, mod)
25
+ end
26
+ end
27
+
28
+ test 'can cherry pick modules' do
29
+ assert_include_modules Admin, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :rememberable, :encryptable
30
+ end
31
+
32
+ test 'chosen modules are inheritable' do
33
+ assert_include_modules Inheritable, :database_authenticatable, :registerable, :timeoutable, :recoverable, :lockable, :rememberable, :encryptable
34
+ end
35
+
36
+ test 'order of module inclusion' do
37
+ correct_module_order = [:database_authenticatable, :rememberable, :encryptable, :recoverable, :registerable, :lockable, :timeoutable]
38
+ incorrect_module_order = [:database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :encryptable, :rememberable]
39
+
40
+ assert_include_modules Admin, *incorrect_module_order
41
+
42
+ # get module constants from symbol list
43
+ module_constants = correct_module_order.collect { |mod| Devise::Models::const_get(mod.to_s.classify) }
44
+
45
+ # confirm that they adhere to the order in ALL
46
+ # get included modules, filter out the noise, and reverse the order
47
+ assert_equal module_constants, (Admin.included_modules & module_constants).reverse
48
+ end
49
+
50
+ test 'set a default value for stretches' do
51
+ assert_equal 15, Configurable.stretches
52
+ end
53
+
54
+ test 'set a default value for pepper' do
55
+ assert_equal 'abcdef', Configurable.pepper
56
+ end
57
+
58
+ test 'set a default value for confirm_within' do
59
+ assert_equal 5.days, Configurable.confirm_within
60
+ end
61
+
62
+ test 'set a default value for remember_for' do
63
+ assert_equal 7.days, Configurable.remember_for
64
+ end
65
+
66
+ test 'set a default value for timeout_in' do
67
+ assert_equal 15.minutes, Configurable.timeout_in
68
+ end
69
+
70
+ test 'set a default value for unlock_in' do
71
+ assert_equal 10.days, Configurable.unlock_in
72
+ end
73
+
74
+ test 'set null fields on migrations' do
75
+ Admin.create!
76
+ end
77
+ end
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ class OauthConfigTest < ActiveSupport::TestCase
4
+ ACCESS_TOKEN = {
5
+ :access_token => "plataformatec"
6
+ }
7
+
8
+ setup { @config = Devise.oauth_configs[:facebook] }
9
+ teardown { Devise::Oauth.reset_stubs! }
10
+
11
+ test "stored OAuth2::Client" do
12
+ assert_kind_of OAuth2::Client, @config.client
13
+ end
14
+
15
+ test "build authorize url" do
16
+ url = @config.authorize_url(:redirect_uri => "foo")
17
+ assert_match "https://graph.facebook.com/oauth/authorize?", url
18
+ assert_match "scope=email%2Coffline_access", url
19
+ assert_match "client_id=APP_ID", url
20
+ assert_match "type=web_server", url
21
+ assert_match "redirect_uri=foo", url
22
+ end
23
+
24
+ test "retrieves access token object by code" do
25
+ Devise::Oauth.stub!(:facebook) do |b|
26
+ b.post('/oauth/access_token') { [200, {}, ACCESS_TOKEN.to_json] }
27
+ b.get('/me?access_token=plataformatec') { [200, {}, {}.to_json] }
28
+ end
29
+
30
+ access_token = @config.access_token_by_code("12345")
31
+ assert_kind_of OAuth2::AccessToken, access_token
32
+ assert_equal "{}", access_token.get("/me")
33
+ end
34
+
35
+ test "retrieves access token object by token" do
36
+ Devise::Oauth.stub!(:facebook) do |b|
37
+ b.get('/me?access_token=plataformatec') { [200, {}, {}.to_json] }
38
+ end
39
+
40
+ access_token = @config.access_token_by_token("plataformatec")
41
+ assert_kind_of OAuth2::AccessToken, access_token
42
+ assert_equal "{}", access_token.get("/me")
43
+ end
44
+ end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class OauthRoutesTest < ActionController::TestCase
4
+ tests ApplicationController
5
+
6
+ def assert_path_and_url(action, provider)
7
+ # Resource param
8
+ assert_equal @controller.send(action, :user, provider),
9
+ @controller.send("user_#{action}", provider)
10
+
11
+ # Default url params
12
+ assert_equal @controller.send(action, :user, provider, :param => 123),
13
+ @controller.send("user_#{action}", provider, :param => 123)
14
+
15
+ # With an object
16
+ assert_equal @controller.send(action, User.new, provider, :param => 123),
17
+ @controller.send("user_#{action}", provider, :param => 123)
18
+ end
19
+
20
+ test 'should alias oauth_callback to mapped user auth_callback' do
21
+ assert_path_and_url :oauth_callback_path, :github
22
+ assert_path_and_url :oauth_callback_url, :github
23
+ assert_path_and_url :oauth_callback_path, :facebook
24
+ assert_path_and_url :oauth_callback_url, :facebook
25
+ end
26
+
27
+ test 'should alias oauth_authorize to mapped user auth_authorize' do
28
+ assert_path_and_url :oauth_authorize_url, :github
29
+ assert_path_and_url :oauth_authorize_url, :facebook
30
+ end
31
+
32
+ test 'should adds scope, provider and redirect_uri to authorize urls' do
33
+ url = @controller.oauth_authorize_url(:user, :github)
34
+ assert_match "https://github.com/login/oauth/authorize?", url
35
+ assert_match "scope=user%2Cpublic_repo", url
36
+ assert_match "client_id=APP_ID", url
37
+ assert_match "type=web_server", url
38
+ assert_match "redirect_uri=http%3A%2F%2Ftest.host%2Fusers%2Foauth%2Fgithub%2Fcallback", url
39
+
40
+ url = @controller.oauth_authorize_url(:user, :facebook)
41
+ assert_match "https://graph.facebook.com/oauth/authorize?", url
42
+ assert_match "scope=email%2Coffline_access", url
43
+ assert_match "client_id=APP_ID", url
44
+ assert_match "type=web_server", url
45
+ assert_match "redirect_uri=http%3A%2F%2Ftest.host%2Fusers%2Foauth%2Ffacebook%2Fcallback", url
46
+ end
47
+ end
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Migration.verbose = false
2
+ ActiveRecord::Base.logger = Logger.new(nil)
3
+
4
+ ActiveRecord::Migrator.migrate(File.expand_path("../../rails_app/db/migrate/", __FILE__))
5
+
6
+ class ActiveSupport::TestCase
7
+ self.use_transactional_fixtures = true
8
+ self.use_instantiated_fixtures = false
9
+ end
@@ -0,0 +1,10 @@
1
+ Mongoid.configure do |config|
2
+ config.master = Mongo::Connection.new('127.0.0.1', 27017).db("devise-test-suite")
3
+ end
4
+
5
+ class ActiveSupport::TestCase
6
+ setup do
7
+ User.delete_all
8
+ Admin.delete_all
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin < ActiveRecord::Base
4
+ include Shim
5
+ include SharedAdmin
6
+ end
@@ -0,0 +1,2 @@
1
+ module Shim
2
+ end
@@ -0,0 +1,8 @@
1
+ require 'shared_user'
2
+
3
+ class User < ActiveRecord::Base
4
+ include Shim
5
+ include SharedUser
6
+
7
+ attr_accessible :username, :email, :password, :password_confirmation, :remember_me
8
+ end
@@ -0,0 +1,6 @@
1
+ class Admins::SessionsController < Devise::SessionsController
2
+ def new
3
+ flash[:special] = "Welcome to #{controller_path.inspect} controller!"
4
+ super
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AdminsController < ApplicationController
2
+ before_filter :authenticate_admin!
3
+
4
+ def index
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery
6
+
7
+ before_filter :current_user
8
+ before_filter :authenticate_user!, :if => :devise_controller?
9
+ end
@@ -0,0 +1,12 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def private
6
+ end
7
+
8
+ def set
9
+ session["user_provider_oauth_token"] = "something"
10
+ head :ok
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::RegistrationsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::SessionsController < ApplicationController
2
+ end
@@ -0,0 +1,18 @@
1
+ class UsersController < ApplicationController
2
+ before_filter :authenticate_user!, :except => :accept
3
+ respond_to :html, :xml
4
+
5
+ def index
6
+ user_session[:cart] = "Cart"
7
+ respond_with(current_user)
8
+ end
9
+
10
+ def accept
11
+ @current_user = current_user
12
+ end
13
+
14
+ def expire
15
+ user_session['last_request_at'] = 31.minutes.ago.utc
16
+ render :text => 'User will be expired on next request'
17
+ end
18
+ end