sorcery 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. data/README.rdoc +1 -1
  2. data/VERSION +1 -1
  3. data/lib/sorcery/crypto_providers/bcrypt.rb +2 -4
  4. data/lib/sorcery/initializers/initializer.rb +58 -58
  5. data/lib/sorcery/model/submodules/activity_logging.rb +1 -1
  6. data/lib/sorcery/model/submodules/brute_force_protection.rb +1 -1
  7. data/lib/sorcery/model/submodules/reset_password.rb +1 -1
  8. data/lib/sorcery/model.rb +21 -1
  9. data/lib/sorcery/test_helpers/internal/rails.rb +52 -0
  10. data/lib/sorcery/test_helpers/internal/sinatra.rb +122 -0
  11. data/lib/sorcery/test_helpers/internal.rb +55 -0
  12. data/lib/sorcery/test_helpers/rails.rb +5 -43
  13. data/lib/sorcery/test_helpers/sinatra.rb +59 -102
  14. data/lib/sorcery/test_helpers.rb +0 -47
  15. data/lib/sorcery.rb +7 -0
  16. data/sorcery.gemspec +5 -2
  17. data/spec/Gemfile +1 -1
  18. data/spec/Gemfile.lock +12 -4
  19. data/spec/rails3/Gemfile +1 -1
  20. data/spec/rails3/Gemfile.lock +2 -2
  21. data/spec/rails3/spec/controller_activity_logging_spec.rb +2 -4
  22. data/spec/rails3/spec/controller_oauth_spec.rb +3 -3
  23. data/spec/rails3/spec/controller_session_timeout_spec.rb +20 -19
  24. data/spec/rails3/spec/controller_spec.rb +6 -16
  25. data/spec/rails3/spec/spec_helper.rb +2 -2
  26. data/spec/rails3/spec/user_activation_spec.rb +2 -12
  27. data/spec/rails3/spec/user_brute_force_protection_spec.rb +2 -30
  28. data/spec/rails3/spec/user_remember_me_spec.rb +3 -11
  29. data/spec/rails3/spec/user_reset_password_spec.rb +13 -14
  30. data/spec/rails3/spec/user_spec.rb +18 -2
  31. data/spec/sinatra/Gemfile +1 -1
  32. data/spec/sinatra/Gemfile.lock +2 -2
  33. data/spec/sinatra/spec/controller_session_timeout_spec.rb +23 -22
  34. data/spec/sinatra/spec/spec_helper.rb +2 -1
  35. metadata +5 -2
@@ -20,21 +20,20 @@ describe "User with reset_password submodule" do
20
20
  User.sorcery_config.reset!
21
21
  end
22
22
 
23
- it "should respond to 'deliver_reset_password_instructions!'" do
24
- create_new_user
25
- @user.should respond_to(:deliver_reset_password_instructions!)
26
- end
27
-
28
- it "should respond to 'reset_password!" do
29
- create_new_user
30
- @user.should respond_to(:reset_password!)
31
- end
32
-
33
- it "should respond to 'load_from_reset_password_token'" do
34
- create_new_user
35
- User.should respond_to(:load_from_reset_password_token)
23
+ context "API" do
24
+ before(:all) do
25
+ create_new_user
26
+ end
27
+
28
+ specify { @user.should respond_to(:deliver_reset_password_instructions!) }
29
+
30
+ specify { @user.should respond_to(:reset_password!) }
31
+
32
+ it "should respond to .load_from_reset_password_token" do
33
+ User.should respond_to(:load_from_reset_password_token)
34
+ end
36
35
  end
37
-
36
+
38
37
  it "should allow configuration option 'reset_password_token_attribute_name'" do
39
38
  sorcery_model_property_set(:reset_password_token_attribute_name, :my_code)
40
39
  User.sorcery_config.reset_password_token_attribute_name.should equal(:my_code)
@@ -9,6 +9,9 @@ describe "User with no submodules (core)" do
9
9
  describe User, "when app has plugin loaded" do
10
10
  it "should respond to the plugin activation class method" do
11
11
  ActiveRecord::Base.should respond_to(:authenticates_with_sorcery!)
12
+ end
13
+
14
+ it "User should respond_to .authenticates_with_sorcery!" do
12
15
  User.should respond_to(:authenticates_with_sorcery!)
13
16
  end
14
17
  end
@@ -109,8 +112,21 @@ describe "User with no submodules (core)" do
109
112
  User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'wrong!').should be_false
110
113
  end
111
114
 
112
- it "should respond to the class method encrypt" do
113
- User.should respond_to(:encrypt)
115
+ specify { User.should respond_to(:encrypt) }
116
+
117
+ it "subclass should inherit config if defined so" do
118
+ sorcery_reload!([],{:subclasses_inherit_config => true})
119
+ class Admin < User
120
+ end
121
+ Admin.sorcery_config.should_not be_nil
122
+ Admin.sorcery_config.should == User.sorcery_config
123
+ end
124
+
125
+ it "subclass should not inherit config if not defined so" do
126
+ sorcery_reload!([],{:subclasses_inherit_config => false})
127
+ class Admin2 < User
128
+ end
129
+ Admin2.sorcery_config.should be_nil
114
130
  end
115
131
  end
116
132
 
data/spec/sinatra/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra', '>= 1.2.0'
4
4
  gem 'sqlite3-ruby', :require => 'sqlite3'
5
- gem "sorcery", '0.4.0', :path => '../../'
5
+ gem "sorcery", '>= 0.1.0', :path => '../../'
6
6
 
7
7
  group :development, :test do
8
8
  gem "rspec", "~> 2.5.0"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.4.0)
4
+ sorcery (0.4.2)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  json (>= 1.5.1)
7
7
  oauth (>= 0.4.4)
@@ -129,6 +129,6 @@ DEPENDENCIES
129
129
  ruby-debug19
130
130
  simplecov (>= 0.3.8)
131
131
  sinatra (>= 1.2.0)
132
- sorcery (= 0.4.0)!
132
+ sorcery (>= 0.1.0)!
133
133
  sqlite3-ruby
134
134
  timecop
@@ -28,29 +28,30 @@ describe Sinatra::Application do
28
28
  last_response.should be_a_redirect
29
29
  end
30
30
 
31
- it "with 'session_timeout_from_last_action' should not logout if there was activity" do
32
- session[:user_id] = nil
33
- sorcery_controller_property_set(:session_timeout,2)
34
- sorcery_controller_property_set(:session_timeout_from_last_action, true)
35
- get "/test_login", :username => 'gizmo', :password => 'secret'
36
- Timecop.travel(Time.now+1)
37
- get "/test_should_be_logged_in"
38
- session[:user_id].should_not be_nil
39
- Timecop.travel(Time.now+1)
40
- get "/test_should_be_logged_in"
41
- session[:user_id].should_not be_nil
42
- last_response.should be_ok
43
- end
31
+ context "with 'session_timeout_from_last_action'" do
32
+ it "should not logout if there was activity" do
33
+ session[:user_id] = nil
34
+ sorcery_controller_property_set(:session_timeout,2)
35
+ sorcery_controller_property_set(:session_timeout_from_last_action, true)
36
+ get "/test_login", :username => 'gizmo', :password => 'secret'
37
+ Timecop.travel(Time.now+1)
38
+ get "/test_should_be_logged_in"
39
+ session[:user_id].should_not be_nil
40
+ Timecop.travel(Time.now+1)
41
+ get "/test_should_be_logged_in"
42
+ session[:user_id].should_not be_nil
43
+ last_response.should be_ok
44
+ end
44
45
 
45
- it "with 'session_timeout_from_last_action' should logout if there was no activity" do
46
- sorcery_controller_property_set(:session_timeout,0.5)
47
- sorcery_controller_property_set(:session_timeout_from_last_action, true)
48
- get "/test_login", :username => 'gizmo', :password => 'secret'
49
- Timecop.travel(Time.now+0.6)
50
- get "/test_should_be_logged_in"
51
- session[:user_id].should be_nil
52
- last_response.should be_a_redirect
46
+ it "should logout if there was no activity" do
47
+ sorcery_controller_property_set(:session_timeout,0.5)
48
+ sorcery_controller_property_set(:session_timeout_from_last_action, true)
49
+ get "/test_login", :username => 'gizmo', :password => 'secret'
50
+ Timecop.travel(Time.now+0.6)
51
+ get "/test_should_be_logged_in"
52
+ session[:user_id].should be_nil
53
+ last_response.should be_a_redirect
54
+ end
53
55
  end
54
-
55
56
  end
56
57
  end
@@ -20,8 +20,9 @@ end
20
20
 
21
21
  Rspec.configure do |config|
22
22
  config.send(:include, RSpecMixinExample)
23
- config.send(:include, ::Sorcery::TestHelpers)
24
23
  config.send(:include, ::Sorcery::TestHelpers::Sinatra)
24
+ config.send(:include, ::Sorcery::TestHelpers::Internal)
25
+ config.send(:include, ::Sorcery::TestHelpers::Internal::Sinatra)
25
26
  config.before(:suite) do
26
27
  ActiveRecord::Migrator.migrate("#{APP_ROOT}/db/migrate/core")
27
28
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sorcery
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.0
5
+ version: 0.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Noam Ben Ari
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-21 00:00:00 +03:00
13
+ date: 2011-04-30 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -248,6 +248,9 @@ files:
248
248
  - lib/sorcery/railties/tasks.rake
249
249
  - lib/sorcery/sinatra.rb
250
250
  - lib/sorcery/test_helpers.rb
251
+ - lib/sorcery/test_helpers/internal.rb
252
+ - lib/sorcery/test_helpers/internal/rails.rb
253
+ - lib/sorcery/test_helpers/internal/sinatra.rb
251
254
  - lib/sorcery/test_helpers/rails.rb
252
255
  - lib/sorcery/test_helpers/sinatra.rb
253
256
  - sorcery.gemspec