sorcery 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +29 -104
  3. data/CHANGELOG.md +13 -1
  4. data/Gemfile +2 -16
  5. data/README.md +124 -272
  6. data/Rakefile +2 -2
  7. data/gemfiles/{mongoid-rails40.gemfile → active_record-rails42.gemfile} +1 -3
  8. data/lib/generators/sorcery/helpers.rb +4 -4
  9. data/lib/generators/sorcery/install_generator.rb +25 -19
  10. data/lib/generators/sorcery/templates/initializer.rb +27 -52
  11. data/lib/generators/sorcery/templates/migration/activity_logging.rb +2 -2
  12. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +1 -1
  13. data/lib/generators/sorcery/templates/migration/core.rb +3 -3
  14. data/lib/generators/sorcery/templates/migration/external.rb +2 -2
  15. data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -2
  16. data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -2
  17. data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -2
  18. data/lib/sorcery.rb +0 -28
  19. data/lib/sorcery/adapters/active_record_adapter.rb +7 -18
  20. data/lib/sorcery/controller.rb +19 -21
  21. data/lib/sorcery/controller/config.rb +20 -18
  22. data/lib/sorcery/controller/submodules/activity_logging.rb +7 -15
  23. data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -2
  24. data/lib/sorcery/controller/submodules/external.rb +22 -14
  25. data/lib/sorcery/controller/submodules/http_basic_auth.rb +16 -19
  26. data/lib/sorcery/controller/submodules/remember_me.rb +15 -10
  27. data/lib/sorcery/controller/submodules/session_timeout.rb +7 -8
  28. data/lib/sorcery/crypto_providers/aes256.rb +15 -15
  29. data/lib/sorcery/crypto_providers/bcrypt.rb +19 -21
  30. data/lib/sorcery/crypto_providers/common.rb +1 -1
  31. data/lib/sorcery/crypto_providers/md5.rb +5 -5
  32. data/lib/sorcery/crypto_providers/sha1.rb +5 -5
  33. data/lib/sorcery/crypto_providers/sha256.rb +2 -2
  34. data/lib/sorcery/crypto_providers/sha512.rb +3 -3
  35. data/lib/sorcery/engine.rb +3 -8
  36. data/lib/sorcery/model.rb +24 -32
  37. data/lib/sorcery/model/config.rb +64 -49
  38. data/lib/sorcery/model/submodules/activity_logging.rb +31 -12
  39. data/lib/sorcery/model/submodules/brute_force_protection.rb +23 -23
  40. data/lib/sorcery/model/submodules/external.rb +3 -7
  41. data/lib/sorcery/model/submodules/remember_me.rb +19 -7
  42. data/lib/sorcery/model/submodules/reset_password.rb +32 -36
  43. data/lib/sorcery/model/submodules/user_activation.rb +38 -50
  44. data/lib/sorcery/model/temporary_token.rb +2 -2
  45. data/lib/sorcery/protocols/oauth.rb +3 -9
  46. data/lib/sorcery/protocols/oauth2.rb +0 -2
  47. data/lib/sorcery/providers/base.rb +4 -4
  48. data/lib/sorcery/providers/facebook.rb +5 -8
  49. data/lib/sorcery/providers/github.rb +5 -7
  50. data/lib/sorcery/providers/google.rb +3 -5
  51. data/lib/sorcery/providers/heroku.rb +6 -8
  52. data/lib/sorcery/providers/jira.rb +12 -17
  53. data/lib/sorcery/providers/linkedin.rb +6 -8
  54. data/lib/sorcery/providers/liveid.rb +4 -7
  55. data/lib/sorcery/providers/paypal.rb +60 -0
  56. data/lib/sorcery/providers/salesforce.rb +3 -5
  57. data/lib/sorcery/providers/slack.rb +45 -0
  58. data/lib/sorcery/providers/twitter.rb +4 -6
  59. data/lib/sorcery/providers/vk.rb +3 -5
  60. data/lib/sorcery/providers/wechat.rb +79 -0
  61. data/lib/sorcery/providers/xing.rb +7 -10
  62. data/lib/sorcery/test_helpers/internal.rb +10 -10
  63. data/lib/sorcery/test_helpers/internal/rails.rb +16 -8
  64. data/lib/sorcery/test_helpers/rails/controller.rb +1 -1
  65. data/lib/sorcery/test_helpers/rails/integration.rb +5 -6
  66. data/lib/sorcery/version.rb +1 -1
  67. data/sorcery.gemspec +25 -27
  68. data/spec/active_record/user_activation_spec.rb +2 -3
  69. data/spec/active_record/user_activity_logging_spec.rb +2 -4
  70. data/spec/active_record/user_brute_force_protection_spec.rb +3 -4
  71. data/spec/active_record/user_oauth_spec.rb +3 -4
  72. data/spec/active_record/user_remember_me_spec.rb +3 -4
  73. data/spec/active_record/user_reset_password_spec.rb +2 -3
  74. data/spec/active_record/user_spec.rb +7 -7
  75. data/spec/controllers/controller_activity_logging_spec.rb +13 -24
  76. data/spec/controllers/controller_brute_force_protection_spec.rb +6 -8
  77. data/spec/controllers/controller_http_basic_auth_spec.rb +19 -20
  78. data/spec/controllers/controller_oauth2_spec.rb +125 -100
  79. data/spec/controllers/controller_oauth_spec.rb +86 -66
  80. data/spec/controllers/controller_remember_me_spec.rb +35 -30
  81. data/spec/controllers/controller_session_timeout_spec.rb +14 -15
  82. data/spec/controllers/controller_spec.rb +77 -111
  83. data/spec/orm/active_record.rb +1 -1
  84. data/spec/rails_app/app/active_record/authentication.rb +1 -1
  85. data/spec/rails_app/app/active_record/user.rb +2 -2
  86. data/spec/rails_app/app/controllers/sorcery_controller.rb +89 -24
  87. data/spec/rails_app/app/mailers/sorcery_mailer.rb +16 -17
  88. data/spec/rails_app/config.ru +1 -1
  89. data/spec/rails_app/config/application.rb +7 -7
  90. data/spec/rails_app/config/boot.rb +1 -1
  91. data/spec/rails_app/config/environments/test.rb +1 -1
  92. data/spec/rails_app/config/initializers/compatible_legacy_migration.rb +11 -0
  93. data/spec/rails_app/config/initializers/session_store.rb +3 -3
  94. data/spec/rails_app/config/routes.rb +11 -1
  95. data/spec/rails_app/db/migrate/activation/20101224223622_add_activation_to_users.rb +4 -4
  96. data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +8 -8
  97. data/spec/rails_app/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +5 -5
  98. data/spec/rails_app/db/migrate/core/20101224223620_create_users.rb +5 -5
  99. data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +3 -3
  100. data/spec/rails_app/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +6 -6
  101. data/spec/rails_app/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +5 -5
  102. data/spec/shared_examples/user_activation_shared_examples.rb +99 -58
  103. data/spec/shared_examples/user_activity_logging_shared_examples.rb +47 -41
  104. data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +19 -24
  105. data/spec/shared_examples/user_oauth_shared_examples.rb +7 -10
  106. data/spec/shared_examples/user_remember_me_shared_examples.rb +90 -21
  107. data/spec/shared_examples/user_reset_password_shared_examples.rb +52 -54
  108. data/spec/shared_examples/user_shared_examples.rb +215 -118
  109. data/spec/sorcery_crypto_providers_spec.rb +63 -76
  110. data/spec/spec_helper.rb +17 -13
  111. metadata +28 -83
  112. data/gemfiles/mongo_mapper-rails40.gemfile +0 -9
  113. data/gemfiles/mongo_mapper-rails41.gemfile +0 -9
  114. data/gemfiles/mongoid-rails41.gemfile +0 -9
  115. data/gemfiles/mongoid3-rails32.gemfile +0 -9
  116. data/lib/sorcery/adapters/data_mapper_adapter.rb +0 -176
  117. data/lib/sorcery/adapters/mongo_mapper_adapter.rb +0 -110
  118. data/lib/sorcery/adapters/mongoid_adapter.rb +0 -97
  119. data/lib/sorcery/railties/tasks.rake +0 -6
  120. data/spec/data_mapper/user_activation_spec.rb +0 -10
  121. data/spec/data_mapper/user_activity_logging_spec.rb +0 -14
  122. data/spec/data_mapper/user_brute_force_protection_spec.rb +0 -9
  123. data/spec/data_mapper/user_oauth_spec.rb +0 -9
  124. data/spec/data_mapper/user_remember_me_spec.rb +0 -8
  125. data/spec/data_mapper/user_reset_password_spec.rb +0 -8
  126. data/spec/data_mapper/user_spec.rb +0 -27
  127. data/spec/mongo_mapper/user_activation_spec.rb +0 -9
  128. data/spec/mongo_mapper/user_activity_logging_spec.rb +0 -8
  129. data/spec/mongo_mapper/user_brute_force_protection_spec.rb +0 -8
  130. data/spec/mongo_mapper/user_oauth_spec.rb +0 -8
  131. data/spec/mongo_mapper/user_remember_me_spec.rb +0 -8
  132. data/spec/mongo_mapper/user_reset_password_spec.rb +0 -8
  133. data/spec/mongo_mapper/user_spec.rb +0 -37
  134. data/spec/mongoid/user_activation_spec.rb +0 -9
  135. data/spec/mongoid/user_activity_logging_spec.rb +0 -8
  136. data/spec/mongoid/user_brute_force_protection_spec.rb +0 -8
  137. data/spec/mongoid/user_oauth_spec.rb +0 -8
  138. data/spec/mongoid/user_remember_me_spec.rb +0 -8
  139. data/spec/mongoid/user_reset_password_spec.rb +0 -8
  140. data/spec/mongoid/user_spec.rb +0 -51
  141. data/spec/orm/data_mapper.rb +0 -48
  142. data/spec/orm/mongo_mapper.rb +0 -10
  143. data/spec/orm/mongoid.rb +0 -22
  144. data/spec/rails_app/app/data_mapper/authentication.rb +0 -8
  145. data/spec/rails_app/app/data_mapper/user.rb +0 -7
  146. data/spec/rails_app/app/mongo_mapper/authentication.rb +0 -6
  147. data/spec/rails_app/app/mongo_mapper/user.rb +0 -7
  148. data/spec/rails_app/app/mongoid/authentication.rb +0 -7
  149. data/spec/rails_app/app/mongoid/user.rb +0 -7
@@ -17,30 +17,30 @@ module Sorcery
17
17
  ::Sorcery::Controller::Config.init!
18
18
  ::Sorcery::Controller::Config.reset!
19
19
 
20
- # remove all plugin before_filters so they won't fail other tests.
20
+ # remove all plugin before_actions so they won't fail other tests.
21
21
  # I don't like this way, but I didn't find another.
22
22
  # hopefully it won't break until Rails 4.
23
- chain = if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("4.1.0")
23
+ chain = if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('4.1.0')
24
24
  SorceryController._process_action_callbacks.send :chain
25
25
  else
26
26
  SorceryController._process_action_callbacks
27
27
  end
28
28
 
29
- chain.delete_if {|c| SUBMODULES_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
29
+ chain.delete_if { |c| SUBMODULES_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
30
30
 
31
31
  # configure
32
32
  ::Sorcery::Controller::Config.submodules = submodules
33
33
  ::Sorcery::Controller::Config.user_class = nil
34
- ActionController::Base.send(:include,::Sorcery::Controller)
35
- ::Sorcery::Controller::Config.user_class = "User"
34
+ ActionController::Base.send(:include, ::Sorcery::Controller)
35
+ ::Sorcery::Controller::Config.user_class = 'User'
36
36
 
37
37
  ::Sorcery::Controller::Config.user_config do |user|
38
- options.each do |property,value|
38
+ options.each do |property, value|
39
39
  user.send(:"#{property}=", value)
40
40
  end
41
41
  end
42
42
  User.authenticates_with_sorcery!
43
- if defined?(DataMapper) and User.ancestors.include?(DataMapper::Resource)
43
+ if defined?(DataMapper) && User.ancestors.include?(DataMapper::Resource)
44
44
  DataMapper.auto_migrate!
45
45
  User.finalize
46
46
  Authentication.finalize
@@ -60,7 +60,15 @@ module Sorcery
60
60
  # all this without calling the :logout action explicitly.
61
61
  # A dirty dirty hack.
62
62
  def clear_user_without_logout
63
- subject.instance_variable_set(:@current_user,nil)
63
+ subject.instance_variable_set(:@current_user, nil)
64
+ end
65
+
66
+ if ::Rails.version < '5.0.0'
67
+ %w(get post put).each do |method|
68
+ define_method(method) do |action, options = {}|
69
+ super action, options[:params] || {}, options[:session]
70
+ end
71
+ end
64
72
  end
65
73
  end
66
74
  end
@@ -2,7 +2,7 @@ module Sorcery
2
2
  module TestHelpers
3
3
  module Rails
4
4
  module Controller
5
- def login_user(user = nil, test_context = {})
5
+ def login_user(user = nil, _test_context = {})
6
6
  user ||= @user
7
7
  @controller.send(:auto_login, user)
8
8
  @controller.send(:after_login!, user, [user.send(user.sorcery_config.username_attribute_names.first), 'secret'])
@@ -2,20 +2,19 @@ module Sorcery
2
2
  module TestHelpers
3
3
  module Rails
4
4
  module Integration
5
-
6
- #Accepts arguments for user to login, route to use and HTTP method
7
- #Defaults - @user, 'sessions_url' and POST
5
+ # Accepts arguments for user to login, route to use and HTTP method
6
+ # Defaults - @user, 'sessions_url' and POST
8
7
  def login_user(user = nil, route = nil, http_method = :post)
9
8
  user ||= @user
10
9
  route ||= sessions_url
11
10
 
12
11
  username_attr = user.sorcery_config.username_attribute_names.first
13
12
  username = user.send(username_attr)
14
- page.driver.send(http_method, route, { :"#{username_attr}" => username, :password => 'secret' })
13
+ page.driver.send(http_method, route, :"#{username_attr}" => username, :password => 'secret')
15
14
  end
16
15
 
17
- #Accepts route and HTTP method arguments
18
- #Default - 'logout_url' and GET
16
+ # Accepts route and HTTP method arguments
17
+ # Default - 'logout_url' and GET
19
18
  def logout_user(route = nil, http_method = :get)
20
19
  route ||= logout_url
21
20
  page.driver.send(http_method, route)
@@ -1,3 +1,3 @@
1
1
  module Sorcery
2
- VERSION = "0.9.1"
2
+ VERSION = '0.10.0'
3
3
  end
@@ -3,32 +3,30 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'sorcery/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "sorcery"
6
+ s.name = 'sorcery'
7
7
  s.version = Sorcery::VERSION
8
- s.authors = ["Noam Ben Ari", "Kir Shatrov", "Grzegorz Witek"]
9
- s.email = "nbenari@gmail.com"
10
- s.description = "Provides common authentication needs such as signing in/out, activating by email and resetting password."
11
- s.summary = "Magical authentication for Rails 3 & 4 applications"
12
- s.homepage = "http://github.com/NoamB/sorcery"
13
-
14
- s.files = `git ls-files`.split($/)
15
- s.require_paths = ["lib"]
16
-
17
- s.licenses = ["MIT"]
18
-
19
- s.required_ruby_version = '>= 1.9.3'
20
-
21
- s.add_dependency "oauth", "~> 0.4", ">= 0.4.4"
22
- s.add_dependency "oauth2", ">= 0.8.0"
23
- s.add_dependency "bcrypt", "~> 3.1"
24
-
25
- s.add_development_dependency "abstract", ">= 1.0.0"
26
- s.add_development_dependency "json", ">= 1.7.7"
27
- s.add_development_dependency "yard", "~> 0.6.0"
28
-
29
- s.add_development_dependency "timecop"
30
- s.add_development_dependency "simplecov", ">= 0.3.8"
31
- s.add_development_dependency "rspec", "~> 3.0.0"
32
- s.add_development_dependency "rspec-rails", "~> 3.0.0"
8
+ s.authors = ['Noam Ben Ari', 'Kir Shatrov', 'Grzegorz Witek', 'Chase Gilliam']
9
+ s.email = 'chase.gilliam@gmail.com'
10
+ s.description = 'Provides common authentication needs such as signing in/out, activating by email and resetting password.'
11
+ s.summary = 'Magical authentication for Rails applications'
12
+ s.homepage = 'https://github.com/Sorcery/sorcery'
13
+ s.post_install_message = "As of version 1.0 oauth/oauth2 won't be automatically bundled\n"
14
+ s.post_install_message += 'you need to add those dependencies to your Gemfile'
15
+
16
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ s.require_paths = ['lib']
18
+
19
+ s.licenses = ['MIT']
20
+
21
+ s.required_ruby_version = '>= 2.0.0'
22
+
23
+ s.add_dependency 'oauth', '~> 0.4', '>= 0.4.4'
24
+ s.add_dependency 'oauth2', '~> 1.0', '>= 0.8.0'
25
+ s.add_dependency 'bcrypt', '~> 3.1'
26
+
27
+ s.add_development_dependency 'yard', '~> 0.6.0'
28
+ s.add_development_dependency 'timecop'
29
+ s.add_development_dependency 'simplecov', '>= 0.3.8'
30
+ s.add_development_dependency 'rspec-rails', '~> 3.5.0'
31
+ s.add_development_dependency 'test-unit', '~> 3.1.0'
33
32
  end
34
-
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  require 'rails_app/app/mailers/sorcery_mailer'
4
4
  require 'shared_examples/user_activation_shared_examples'
5
5
 
6
- describe User, "with activation submodule", :active_record => true do
6
+ describe User, 'with activation submodule', active_record: true do
7
7
  before(:all) do
8
8
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
9
9
  User.reset_column_information
@@ -13,6 +13,5 @@ describe User, "with activation submodule", :active_record => true do
13
13
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activation")
14
14
  end
15
15
 
16
- it_behaves_like "rails_3_activation_model"
17
-
16
+ it_behaves_like 'rails_3_activation_model'
18
17
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/user_activity_logging_shared_examples'
3
3
 
4
- describe User, "with activity logging submodule", :active_record => true do
5
-
4
+ describe User, 'with activity logging submodule', active_record: true do
6
5
  before(:all) do
7
6
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activity_logging")
8
7
  User.reset_column_information
@@ -12,6 +11,5 @@ describe User, "with activity logging submodule", :active_record => true do
12
11
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activity_logging")
13
12
  end
14
13
 
15
- it_behaves_like "rails_3_activity_logging_model"
16
-
14
+ it_behaves_like 'rails_3_activity_logging_model'
17
15
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/user_brute_force_protection_shared_examples'
3
3
 
4
- describe User, "with brute_force_protection submodule", :active_record => true do
4
+ describe User, 'with brute_force_protection submodule', active_record: true do
5
5
  before(:all) do
6
6
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/brute_force_protection")
7
7
  User.reset_column_information
@@ -11,6 +11,5 @@ describe User, "with brute_force_protection submodule", :active_record => true d
11
11
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/brute_force_protection")
12
12
  end
13
13
 
14
- it_behaves_like "rails_3_brute_force_protection_model"
15
-
16
- end
14
+ it_behaves_like 'rails_3_brute_force_protection_model'
15
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/user_oauth_shared_examples'
3
3
 
4
- describe User, "with oauth submodule", :active_record => true do
4
+ describe User, 'with oauth submodule', active_record: true do
5
5
  before(:all) do
6
6
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
7
7
  User.reset_column_information
@@ -11,6 +11,5 @@ describe User, "with oauth submodule", :active_record => true do
11
11
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
12
12
  end
13
13
 
14
- it_behaves_like "rails_3_oauth_model"
15
-
16
- end
14
+ it_behaves_like 'rails_3_oauth_model'
15
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/user_remember_me_shared_examples'
3
3
 
4
- describe User, "with remember_me submodule", :active_record => true do
4
+ describe User, 'with remember_me submodule', active_record: true do
5
5
  before(:all) do
6
6
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/remember_me")
7
7
  User.reset_column_information
@@ -11,6 +11,5 @@ describe User, "with remember_me submodule", :active_record => true do
11
11
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/remember_me")
12
12
  end
13
13
 
14
- it_behaves_like "rails_3_remember_me_model"
15
-
16
- end
14
+ it_behaves_like 'rails_3_remember_me_model'
15
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'shared_examples/user_reset_password_shared_examples'
3
3
 
4
- describe User, "with reset_password submodule", :active_record => true do
4
+ describe User, 'with reset_password submodule', active_record: true do
5
5
  before(:all) do
6
6
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/reset_password")
7
7
  User.reset_column_information
@@ -11,6 +11,5 @@ describe User, "with reset_password submodule", :active_record => true do
11
11
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/reset_password")
12
12
  end
13
13
 
14
- it_behaves_like "rails_3_reset_password_model"
15
-
14
+ it_behaves_like 'rails_3_reset_password_model'
16
15
  end
@@ -2,26 +2,26 @@ require 'spec_helper'
2
2
  require 'rails_app/app/mailers/sorcery_mailer'
3
3
  require 'shared_examples/user_shared_examples'
4
4
 
5
- describe User, "with no submodules (core)", :active_record => true do
5
+ describe User, 'with no submodules (core)', active_record: true do
6
6
  before(:all) do
7
7
  sorcery_reload!
8
8
  end
9
9
 
10
- context "when app has plugin loaded" do
11
- it "responds to the plugin activation class method" do
10
+ context 'when app has plugin loaded' do
11
+ it 'responds to the plugin activation class method' do
12
12
  expect(ActiveRecord::Base).to respond_to :authenticates_with_sorcery!
13
13
  end
14
14
 
15
- it "User responds to .authenticates_with_sorcery!" do
15
+ it 'User responds to .authenticates_with_sorcery!' do
16
16
  expect(User).to respond_to :authenticates_with_sorcery!
17
17
  end
18
18
  end
19
19
 
20
20
  # ----------------- PLUGIN CONFIGURATION -----------------------
21
21
 
22
- it_should_behave_like "rails_3_core_model"
22
+ it_should_behave_like 'rails_3_core_model'
23
23
 
24
- describe "external users" do
24
+ describe 'external users' do
25
25
  before(:all) do
26
26
  ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
27
27
  User.reset_column_information
@@ -32,6 +32,6 @@ describe User, "with no submodules (core)", :active_record => true do
32
32
  ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
33
33
  end
34
34
 
35
- it_should_behave_like "external_user"
35
+ it_should_behave_like 'external_user'
36
36
  end
37
37
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  # require 'shared_examples/controller_activity_logging_shared_examples'
4
4
 
5
- describe SorceryController do
5
+ describe SorceryController, type: :controller do
6
6
  after(:all) do
7
7
  sorcery_controller_property_set(:register_login_time, true)
8
8
  sorcery_controller_property_set(:register_logout_time, true)
@@ -11,8 +11,7 @@ describe SorceryController do
11
11
  end
12
12
 
13
13
  # ----------------- ACTIVITY LOGGING -----------------------
14
- context "with activity logging features" do
15
-
14
+ context 'with activity logging features' do
16
15
  let(:adapter) { double('sorcery_adapter') }
17
16
  let(:user) { double('user', id: 42, sorcery_adapter: adapter) }
18
17
 
@@ -20,8 +19,6 @@ describe SorceryController do
20
19
  sorcery_reload!([:activity_logging])
21
20
  end
22
21
 
23
- specify { expect(subject).to respond_to(:current_users) }
24
-
25
22
  before(:each) do
26
23
  allow(user).to receive(:username)
27
24
  allow(user).to receive_message_chain(:sorcery_config, :username_attribute_names, :first) { :username }
@@ -33,14 +30,7 @@ describe SorceryController do
33
30
  sorcery_controller_property_set(:register_last_activity_time, false)
34
31
  end
35
32
 
36
- it "'current_users' should proxy to User.current_users" do
37
- expect(User).to receive(:current_users).with(no_args)
38
-
39
- subject.current_users
40
- end
41
-
42
-
43
- it "logs login time on login" do
33
+ it 'logs login time on login' do
44
34
  now = Time.now.in_time_zone
45
35
  Timecop.freeze(now)
46
36
 
@@ -51,7 +41,7 @@ describe SorceryController do
51
41
  Timecop.return
52
42
  end
53
43
 
54
- it "logs logout time on logout" do
44
+ it 'logs logout time on logout' do
55
45
  login_user(user)
56
46
  now = Time.now.in_time_zone
57
47
  Timecop.freeze(now)
@@ -62,7 +52,7 @@ describe SorceryController do
62
52
  Timecop.return
63
53
  end
64
54
 
65
- it "logs last activity time when logged in" do
55
+ it 'logs last activity time when logged in' do
66
56
  sorcery_controller_property_set(:register_last_activity_time, true)
67
57
 
68
58
  login_user(user)
@@ -75,14 +65,14 @@ describe SorceryController do
75
65
  Timecop.return
76
66
  end
77
67
 
78
- it "logs last IP address when logged in" do
68
+ it 'logs last IP address when logged in' do
79
69
  sorcery_controller_property_set(:register_last_ip_address, true)
80
- expect(user).to receive(:set_last_ip_addess).with('0.0.0.0')
70
+ expect(user).to receive(:set_last_ip_address).with('0.0.0.0')
81
71
 
82
72
  login_user(user)
83
73
  end
84
74
 
85
- it "updates nothing but activity fields" do
75
+ it 'updates nothing but activity fields' do
86
76
  pending 'Move to model'
87
77
  original_user_name = User.last.username
88
78
  login_user(user)
@@ -91,14 +81,14 @@ describe SorceryController do
91
81
  expect(User.last.username).to eq original_user_name
92
82
  end
93
83
 
94
- it "does not register login time if configured so" do
84
+ it 'does not register login time if configured so' do
95
85
  sorcery_controller_property_set(:register_login_time, false)
96
86
 
97
87
  expect(user).to receive(:set_last_login_at).never
98
88
  login_user(user)
99
89
  end
100
90
 
101
- it "does not register logout time if configured so" do
91
+ it 'does not register logout time if configured so' do
102
92
  sorcery_controller_property_set(:register_logout_time, false)
103
93
  login_user(user)
104
94
 
@@ -106,19 +96,18 @@ describe SorceryController do
106
96
  logout_user
107
97
  end
108
98
 
109
- it "does not register last activity time if configured so" do
99
+ it 'does not register last activity time if configured so' do
110
100
  sorcery_controller_property_set(:register_last_activity_time, false)
111
101
 
112
102
  expect(user).to receive(:set_last_activity_at).never
113
103
  login_user(user)
114
104
  end
115
105
 
116
- it "does not register last IP address if configured so" do
106
+ it 'does not register last IP address if configured so' do
117
107
  sorcery_controller_property_set(:register_last_ip_address, false)
118
- expect(user).to receive(:set_last_ip_addess).never
108
+ expect(user).to receive(:set_last_ip_address).never
119
109
 
120
110
  login_user(user)
121
111
  end
122
-
123
112
  end
124
113
  end
@@ -1,16 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SorceryController do
4
-
3
+ describe SorceryController, type: :controller do
5
4
  let(:user) { double('user', id: 42, email: 'bla@bla.com') }
6
5
 
7
6
  def request_test_login
8
- get :test_login, email: 'bla@bla.com', password: 'blabla'
7
+ get :test_login, params: { email: 'bla@bla.com', password: 'blabla' }
9
8
  end
10
9
 
11
10
  # ----------------- SESSION TIMEOUT -----------------------
12
- describe "brute force protection features" do
13
-
11
+ describe 'brute force protection features' do
14
12
  before(:all) do
15
13
  sorcery_reload!([:brute_force_protection])
16
14
  end
@@ -21,7 +19,7 @@ describe SorceryController do
21
19
  Timecop.return
22
20
  end
23
21
 
24
- it "counts login retries" do
22
+ it 'counts login retries' do
25
23
  allow(User).to receive(:authenticate)
26
24
  allow(User.sorcery_adapter).to receive(:find_by_credentials).with(['bla@bla.com', 'blabla']).and_return(user)
27
25
 
@@ -30,14 +28,14 @@ describe SorceryController do
30
28
  3.times { request_test_login }
31
29
  end
32
30
 
33
- it "resets the counter on a good login" do
31
+ it 'resets the counter on a good login' do
34
32
  # dirty hack for rails 4
35
33
  allow(@controller).to receive(:register_last_activity_time_to_db)
36
34
 
37
35
  allow(User).to receive(:authenticate).and_return(user)
38
36
  expect(user).to receive_message_chain(:sorcery_adapter, :update_attribute).with(:failed_logins_count, 0)
39
37
 
40
- get :test_login, email: 'bla@bla.com', password: 'secret'
38
+ get :test_login, params: { email: 'bla@bla.com', password: 'secret' }
41
39
  end
42
40
  end
43
41
  end