sorcery 0.4.1 → 0.5.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.
- data/Gemfile +5 -2
- data/Gemfile.lock +12 -0
- data/README.rdoc +12 -7
- data/VERSION +1 -1
- data/lib/sorcery/controller/adapters/sinatra.rb +35 -28
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -1
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/crypto_providers/bcrypt.rb +2 -4
- data/lib/sorcery/crypto_providers/common.rb +2 -2
- data/lib/sorcery/engine.rb +0 -11
- data/lib/sorcery/initializers/initializer.rb +5 -1
- data/lib/sorcery/model/adapters/active_record.rb +28 -0
- data/lib/sorcery/model/adapters/mongoid.rb +64 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +12 -3
- data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -1
- data/lib/sorcery/model/submodules/external.rb +1 -0
- data/lib/sorcery/model/submodules/remember_me.rb +15 -1
- data/lib/sorcery/model/submodules/reset_password.rb +14 -5
- data/lib/sorcery/model/submodules/user_activation.rb +11 -1
- data/lib/sorcery/model/temporary_token.rb +1 -1
- data/lib/sorcery/model.rb +37 -10
- data/lib/sorcery/sinatra.rb +0 -1
- data/lib/sorcery/test_helpers/internal/rails.rb +53 -0
- data/lib/sorcery/test_helpers/internal/sinatra.rb +74 -0
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +74 -0
- data/lib/sorcery/test_helpers/internal.rb +56 -0
- data/lib/sorcery/test_helpers/rails.rb +5 -43
- data/lib/sorcery/test_helpers/sinatra.rb +62 -102
- data/lib/sorcery/test_helpers.rb +0 -47
- data/lib/sorcery.rb +27 -1
- data/sorcery.gemspec +162 -10
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +9 -4
- data/spec/rails3/Gemfile +1 -1
- data/spec/rails3/Gemfile.lock +6 -9
- data/spec/rails3/spec/controller_activity_logging_spec.rb +2 -4
- data/spec/rails3/spec/controller_oauth_spec.rb +3 -3
- data/spec/rails3/spec/controller_session_timeout_spec.rb +20 -19
- data/spec/rails3/spec/controller_spec.rb +6 -16
- data/spec/rails3/spec/spec_helper.rb +2 -2
- data/spec/rails3/spec/user_activation_spec.rb +2 -12
- data/spec/rails3/spec/user_brute_force_protection_spec.rb +2 -30
- data/spec/rails3/spec/user_remember_me_spec.rb +3 -11
- data/spec/rails3/spec/user_reset_password_spec.rb +15 -16
- data/spec/rails3/spec/user_spec.rb +18 -13
- data/spec/rails3_mongoid/.gitignore +4 -0
- data/spec/rails3_mongoid/.rspec +1 -0
- data/spec/rails3_mongoid/Gemfile +14 -0
- data/spec/rails3_mongoid/Gemfile.lock +143 -0
- data/spec/rails3_mongoid/Rakefile +11 -0
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +108 -0
- data/spec/rails3_mongoid/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +25 -0
- data/spec/rails3_mongoid/app/models/authentication.rb +7 -0
- data/spec/rails3_mongoid/app/models/user.rb +5 -0
- data/spec/rails3_mongoid/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongoid/config/application.rb +51 -0
- data/spec/rails3_mongoid/config/boot.rb +13 -0
- data/spec/rails3_mongoid/config/environment.rb +5 -0
- data/spec/rails3_mongoid/config/environments/development.rb +26 -0
- data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongoid/config/environments/production.rb +49 -0
- data/spec/rails3_mongoid/config/environments/test.rb +35 -0
- data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongoid/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongoid/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongoid/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongoid/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongoid/config/locales/en.yml +5 -0
- data/spec/rails3_mongoid/config/mongoid.yml +7 -0
- data/spec/rails3_mongoid/config/routes.rb +59 -0
- data/spec/rails3_mongoid/config.ru +4 -0
- data/spec/rails3_mongoid/db/schema.rb +23 -0
- data/spec/rails3_mongoid/db/seeds.rb +7 -0
- data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongoid/public/404.html +26 -0
- data/spec/rails3_mongoid/public/422.html +26 -0
- data/spec/rails3_mongoid/public/500.html +26 -0
- data/spec/rails3_mongoid/public/favicon.ico +0 -0
- data/spec/rails3_mongoid/public/images/rails.png +0 -0
- data/spec/rails3_mongoid/public/javascripts/application.js +2 -0
- data/spec/rails3_mongoid/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongoid/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongoid/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongoid/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongoid/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongoid/public/robots.txt +5 -0
- data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongoid/script/rails +6 -0
- data/spec/rails3_mongoid/spec/spec.opts +2 -0
- data/spec/rails3_mongoid/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongoid/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +178 -0
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +31 -0
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +41 -0
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +34 -0
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +51 -0
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +182 -0
- data/spec/rails3_mongoid/spec/user_spec.rb +319 -0
- data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
- data/spec/sinatra/Gemfile +4 -1
- data/spec/sinatra/Gemfile.lock +22 -39
- data/spec/sinatra/Rakefile +1 -1
- data/spec/sinatra/filters.rb +20 -14
- data/spec/sinatra/modular.rb +157 -0
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +23 -22
- data/spec/sinatra/spec/spec_helper.rb +2 -2
- data/spec/sinatra_modular/Gemfile +15 -0
- data/spec/sinatra_modular/Gemfile.lock +117 -0
- data/spec/sinatra_modular/Rakefile +11 -0
- data/spec/sinatra_modular/authentication.rb +3 -0
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +17 -0
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +17 -0
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +11 -0
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +16 -0
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +14 -0
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +15 -0
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +13 -0
- data/spec/sinatra_modular/filters.rb +27 -0
- data/spec/sinatra_modular/modular.rb +157 -0
- data/spec/sinatra_modular/myapp.rb +133 -0
- data/spec/sinatra_modular/sorcery_mailer.rb +25 -0
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +85 -0
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +70 -0
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +53 -0
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +120 -0
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +121 -0
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +64 -0
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +57 -0
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +116 -0
- data/spec/sinatra_modular/spec_modular/spec.opts +2 -0
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +51 -0
- data/spec/sinatra_modular/user.rb +6 -0
- data/spec/sinatra_modular/views/test_login.erb +4 -0
- metadata +205 -37
- data/spec/untitled folder +0 -18
|
@@ -13,6 +13,7 @@ describe "User with remember_me submodule" do
|
|
|
13
13
|
describe User, "loaded plugin configuration" do
|
|
14
14
|
before(:all) do
|
|
15
15
|
sorcery_reload!([:remember_me])
|
|
16
|
+
create_new_user
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
after(:each) do
|
|
@@ -29,32 +30,23 @@ describe "User with remember_me submodule" do
|
|
|
29
30
|
User.sorcery_config.remember_me_token_expires_at_attribute_name.should equal(:my_expires)
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
create_new_user
|
|
34
|
-
@user.should respond_to(:remember_me!)
|
|
35
|
-
end
|
|
33
|
+
specify { @user.should respond_to(:remember_me!) }
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
create_new_user
|
|
39
|
-
@user.should respond_to(:forget_me!)
|
|
40
|
-
end
|
|
35
|
+
specify { @user.should respond_to(:forget_me!) }
|
|
41
36
|
|
|
42
37
|
it "should generate a new token on 'remember_me!'" do
|
|
43
|
-
create_new_user
|
|
44
38
|
@user.remember_me_token.should be_nil
|
|
45
39
|
@user.remember_me!
|
|
46
40
|
@user.remember_me_token.should_not be_nil
|
|
47
41
|
end
|
|
48
42
|
|
|
49
43
|
it "should set an expiration based on 'remember_me_for' attribute" do
|
|
50
|
-
create_new_user
|
|
51
44
|
sorcery_model_property_set(:remember_me_for, 2 * 60 * 60 * 24)
|
|
52
45
|
@user.remember_me!
|
|
53
46
|
@user.remember_me_token_expires_at.to_s.should == (Time.now + 2 * 60 * 60 * 24).utc.to_s
|
|
54
47
|
end
|
|
55
48
|
|
|
56
49
|
it "should delete the token and expiration on 'forget_me!'" do
|
|
57
|
-
create_new_user
|
|
58
50
|
@user.remember_me!
|
|
59
51
|
@user.remember_me_token.should_not be_nil
|
|
60
52
|
@user.forget_me!
|
|
@@ -20,21 +20,20 @@ describe "User with reset_password submodule" do
|
|
|
20
20
|
User.sorcery_config.reset!
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@user.should respond_to(:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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(:change_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)
|
|
@@ -143,11 +142,11 @@ describe "User with reset_password submodule" do
|
|
|
143
142
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
144
143
|
end
|
|
145
144
|
|
|
146
|
-
it "when
|
|
145
|
+
it "when change_password! is called, should delete reset_password_token" do
|
|
147
146
|
create_new_user
|
|
148
147
|
@user.deliver_reset_password_instructions!
|
|
149
148
|
@user.reset_password_token.should_not be_nil
|
|
150
|
-
@user.
|
|
149
|
+
@user.change_password!("blabulsdf")
|
|
151
150
|
@user.save!
|
|
152
151
|
@user.reset_password_token.should be_nil
|
|
153
152
|
end
|
|
@@ -9,17 +9,10 @@ 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
|
-
User.should respond_to(:authenticates_with_sorcery!)
|
|
13
12
|
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
describe TestUser, "Testing activated class self-registration" do
|
|
18
|
-
it "should register itself as user_class if activated" do
|
|
19
|
-
TestUser.class_eval do
|
|
20
|
-
authenticates_with_sorcery!
|
|
21
|
-
end
|
|
22
|
-
::Sorcery::Controller::Config.user_class.should == TestUser
|
|
13
|
+
|
|
14
|
+
it "User should respond_to .authenticates_with_sorcery!" do
|
|
15
|
+
User.should respond_to(:authenticates_with_sorcery!)
|
|
23
16
|
end
|
|
24
17
|
end
|
|
25
18
|
|
|
@@ -109,8 +102,21 @@ describe "User with no submodules (core)" do
|
|
|
109
102
|
User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'wrong!').should be_false
|
|
110
103
|
end
|
|
111
104
|
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
specify { User.should respond_to(:encrypt) }
|
|
106
|
+
|
|
107
|
+
it "subclass should inherit config if defined so" do
|
|
108
|
+
sorcery_reload!([],{:subclasses_inherit_config => true})
|
|
109
|
+
class Admin < User
|
|
110
|
+
end
|
|
111
|
+
Admin.sorcery_config.should_not be_nil
|
|
112
|
+
Admin.sorcery_config.should == User.sorcery_config
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "subclass should not inherit config if not defined so" do
|
|
116
|
+
sorcery_reload!([],{:subclasses_inherit_config => false})
|
|
117
|
+
class Admin2 < User
|
|
118
|
+
end
|
|
119
|
+
Admin2.sorcery_config.should be_nil
|
|
114
120
|
end
|
|
115
121
|
end
|
|
116
122
|
|
|
@@ -307,5 +313,4 @@ describe "User with no submodules (core)" do
|
|
|
307
313
|
@user.external?.should be_true
|
|
308
314
|
end
|
|
309
315
|
end
|
|
310
|
-
|
|
311
316
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source 'http://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'rails', '3.0.3'
|
|
4
|
+
gem "sorcery", '>= 0.1.0', :path => '../../../'
|
|
5
|
+
gem "mongoid", "~> 2.0"
|
|
6
|
+
gem "bson_ext", "~> 1.3"
|
|
7
|
+
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem "rspec", "~> 2.5.0"
|
|
10
|
+
gem 'rspec-rails', "~> 2.5.0"
|
|
11
|
+
gem 'ruby-debug19'
|
|
12
|
+
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
|
13
|
+
gem 'timecop'
|
|
14
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../../
|
|
3
|
+
specs:
|
|
4
|
+
oauth (0.4.4)
|
|
5
|
+
sorcery (0.5.2)
|
|
6
|
+
bcrypt-ruby (~> 2.1.4)
|
|
7
|
+
oauth (>= 0.4.4)
|
|
8
|
+
oauth (>= 0.4.4)
|
|
9
|
+
oauth2 (>= 0.1.1)
|
|
10
|
+
oauth2 (>= 0.1.1)
|
|
11
|
+
|
|
12
|
+
GEM
|
|
13
|
+
remote: http://rubygems.org/
|
|
14
|
+
specs:
|
|
15
|
+
abstract (1.0.0)
|
|
16
|
+
actionmailer (3.0.3)
|
|
17
|
+
actionpack (= 3.0.3)
|
|
18
|
+
mail (~> 2.2.9)
|
|
19
|
+
actionpack (3.0.3)
|
|
20
|
+
activemodel (= 3.0.3)
|
|
21
|
+
activesupport (= 3.0.3)
|
|
22
|
+
builder (~> 2.1.2)
|
|
23
|
+
erubis (~> 2.6.6)
|
|
24
|
+
i18n (~> 0.4)
|
|
25
|
+
rack (~> 1.2.1)
|
|
26
|
+
rack-mount (~> 0.6.13)
|
|
27
|
+
rack-test (~> 0.5.6)
|
|
28
|
+
tzinfo (~> 0.3.23)
|
|
29
|
+
activemodel (3.0.3)
|
|
30
|
+
activesupport (= 3.0.3)
|
|
31
|
+
builder (~> 2.1.2)
|
|
32
|
+
i18n (~> 0.4)
|
|
33
|
+
activerecord (3.0.3)
|
|
34
|
+
activemodel (= 3.0.3)
|
|
35
|
+
activesupport (= 3.0.3)
|
|
36
|
+
arel (~> 2.0.2)
|
|
37
|
+
tzinfo (~> 0.3.23)
|
|
38
|
+
activeresource (3.0.3)
|
|
39
|
+
activemodel (= 3.0.3)
|
|
40
|
+
activesupport (= 3.0.3)
|
|
41
|
+
activesupport (3.0.3)
|
|
42
|
+
addressable (2.2.5)
|
|
43
|
+
archive-tar-minitar (0.5.2)
|
|
44
|
+
arel (2.0.6)
|
|
45
|
+
bcrypt-ruby (2.1.4)
|
|
46
|
+
bson (1.3.0)
|
|
47
|
+
bson_ext (1.3.0)
|
|
48
|
+
builder (2.1.2)
|
|
49
|
+
columnize (0.3.2)
|
|
50
|
+
diff-lcs (1.1.2)
|
|
51
|
+
erubis (2.6.6)
|
|
52
|
+
abstract (>= 1.0.0)
|
|
53
|
+
faraday (0.6.1)
|
|
54
|
+
addressable (~> 2.2.4)
|
|
55
|
+
multipart-post (~> 1.1.0)
|
|
56
|
+
rack (< 2, >= 1.1.0)
|
|
57
|
+
i18n (0.5.0)
|
|
58
|
+
linecache19 (0.5.11)
|
|
59
|
+
ruby_core_source (>= 0.1.4)
|
|
60
|
+
mail (2.2.13)
|
|
61
|
+
activesupport (>= 2.3.6)
|
|
62
|
+
i18n (>= 0.4.0)
|
|
63
|
+
mime-types (~> 1.16)
|
|
64
|
+
treetop (~> 1.4.8)
|
|
65
|
+
mime-types (1.16)
|
|
66
|
+
mongo (1.3.0)
|
|
67
|
+
bson (>= 1.3.0)
|
|
68
|
+
mongoid (2.0.1)
|
|
69
|
+
activemodel (~> 3.0)
|
|
70
|
+
mongo (~> 1.3)
|
|
71
|
+
tzinfo (~> 0.3.22)
|
|
72
|
+
will_paginate (~> 3.0.pre)
|
|
73
|
+
multi_json (1.0.1)
|
|
74
|
+
multipart-post (1.1.0)
|
|
75
|
+
oauth2 (0.4.1)
|
|
76
|
+
faraday (~> 0.6.1)
|
|
77
|
+
multi_json (>= 0.0.5)
|
|
78
|
+
polyglot (0.3.1)
|
|
79
|
+
rack (1.2.1)
|
|
80
|
+
rack-mount (0.6.13)
|
|
81
|
+
rack (>= 1.0.0)
|
|
82
|
+
rack-test (0.5.6)
|
|
83
|
+
rack (>= 1.0)
|
|
84
|
+
rails (3.0.3)
|
|
85
|
+
actionmailer (= 3.0.3)
|
|
86
|
+
actionpack (= 3.0.3)
|
|
87
|
+
activerecord (= 3.0.3)
|
|
88
|
+
activeresource (= 3.0.3)
|
|
89
|
+
activesupport (= 3.0.3)
|
|
90
|
+
bundler (~> 1.0)
|
|
91
|
+
railties (= 3.0.3)
|
|
92
|
+
railties (3.0.3)
|
|
93
|
+
actionpack (= 3.0.3)
|
|
94
|
+
activesupport (= 3.0.3)
|
|
95
|
+
rake (>= 0.8.7)
|
|
96
|
+
thor (~> 0.14.4)
|
|
97
|
+
rake (0.8.7)
|
|
98
|
+
rspec (2.5.0)
|
|
99
|
+
rspec-core (~> 2.5.0)
|
|
100
|
+
rspec-expectations (~> 2.5.0)
|
|
101
|
+
rspec-mocks (~> 2.5.0)
|
|
102
|
+
rspec-core (2.5.1)
|
|
103
|
+
rspec-expectations (2.5.0)
|
|
104
|
+
diff-lcs (~> 1.1.2)
|
|
105
|
+
rspec-mocks (2.5.0)
|
|
106
|
+
rspec-rails (2.5.0)
|
|
107
|
+
actionpack (~> 3.0)
|
|
108
|
+
activesupport (~> 3.0)
|
|
109
|
+
railties (~> 3.0)
|
|
110
|
+
rspec (~> 2.5.0)
|
|
111
|
+
ruby-debug-base19 (0.11.24)
|
|
112
|
+
columnize (>= 0.3.1)
|
|
113
|
+
linecache19 (>= 0.5.11)
|
|
114
|
+
ruby_core_source (>= 0.1.4)
|
|
115
|
+
ruby-debug19 (0.11.6)
|
|
116
|
+
columnize (>= 0.3.1)
|
|
117
|
+
linecache19 (>= 0.5.11)
|
|
118
|
+
ruby-debug-base19 (>= 0.11.19)
|
|
119
|
+
ruby_core_source (0.1.4)
|
|
120
|
+
archive-tar-minitar (>= 0.5.2)
|
|
121
|
+
simplecov (0.3.9)
|
|
122
|
+
simplecov-html (>= 0.3.7)
|
|
123
|
+
simplecov-html (0.3.9)
|
|
124
|
+
thor (0.14.6)
|
|
125
|
+
timecop (0.3.5)
|
|
126
|
+
treetop (1.4.9)
|
|
127
|
+
polyglot (>= 0.3.1)
|
|
128
|
+
tzinfo (0.3.23)
|
|
129
|
+
will_paginate (3.0.pre2)
|
|
130
|
+
|
|
131
|
+
PLATFORMS
|
|
132
|
+
ruby
|
|
133
|
+
|
|
134
|
+
DEPENDENCIES
|
|
135
|
+
bson_ext (~> 1.3)
|
|
136
|
+
mongoid (~> 2.0)
|
|
137
|
+
rails (= 3.0.3)
|
|
138
|
+
rspec (~> 2.5.0)
|
|
139
|
+
rspec-rails (~> 2.5.0)
|
|
140
|
+
ruby-debug19
|
|
141
|
+
simplecov (>= 0.3.8)
|
|
142
|
+
sorcery (>= 0.1.0)!
|
|
143
|
+
timecop
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
|
|
4
|
+
desc 'Default: Run all specs for a specific rails version.'
|
|
5
|
+
task :default => :spec
|
|
6
|
+
|
|
7
|
+
desc "Run all specs for a specific rails version"
|
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
9
|
+
t.pattern = '**/*_spec.rb'
|
|
10
|
+
t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec/spec.opts"]
|
|
11
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
require 'oauth'
|
|
2
|
+
|
|
3
|
+
class ApplicationController < ActionController::Base
|
|
4
|
+
protect_from_forgery
|
|
5
|
+
|
|
6
|
+
#before_filter :validate_session, :only => [:test_should_be_logged_in] if defined?(:validate_session)
|
|
7
|
+
before_filter :require_login_from_http_basic, :only => [:test_http_basic_auth]
|
|
8
|
+
before_filter :require_login, :only => [:test_logout, :test_should_be_logged_in, :some_action]
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
@user = User.first
|
|
12
|
+
render :text => @user.attributes.inspect
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def some_action
|
|
16
|
+
render :nothing => true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_login
|
|
20
|
+
@user = login(params[:username], params[:password])
|
|
21
|
+
render :text => ""
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_return_to
|
|
25
|
+
@user = login(params[:username], params[:password])
|
|
26
|
+
redirect_back_or_to(:index, :notice => 'haha!')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_logout
|
|
30
|
+
logout
|
|
31
|
+
render :text => ""
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_logout_with_remember
|
|
35
|
+
remember_me!
|
|
36
|
+
logout
|
|
37
|
+
render :text => ""
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_login_with_remember
|
|
41
|
+
@user = login(params[:username], params[:password])
|
|
42
|
+
remember_me!
|
|
43
|
+
|
|
44
|
+
render :text => ""
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_login_with_remember_in_login
|
|
48
|
+
@user = login(params[:username], params[:password], params[:remember])
|
|
49
|
+
|
|
50
|
+
render :text => ""
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_login_from_cookie
|
|
54
|
+
@user = current_user
|
|
55
|
+
render :text => ""
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_not_authenticated_action
|
|
59
|
+
render :text => "test_not_authenticated_action"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_should_be_logged_in
|
|
63
|
+
render :text => ""
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_http_basic_auth
|
|
67
|
+
render :text => "HTTP Basic Auth"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def login_at_test
|
|
71
|
+
login_at(:twitter)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def login_at_test2
|
|
75
|
+
login_at(:facebook)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_login_from
|
|
79
|
+
if @user = login_from(:twitter)
|
|
80
|
+
redirect_to "bla", :notice => "Success!"
|
|
81
|
+
else
|
|
82
|
+
redirect_to "blu", :alert => "Failed!"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_login_from2
|
|
87
|
+
if @user = login_from(:facebook)
|
|
88
|
+
redirect_to "bla", :notice => "Success!"
|
|
89
|
+
else
|
|
90
|
+
redirect_to "blu", :alert => "Failed!"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_create_from_provider
|
|
95
|
+
provider = params[:provider]
|
|
96
|
+
login_from(provider)
|
|
97
|
+
if @user = create_from(provider)
|
|
98
|
+
redirect_to "bla", :notice => "Success!"
|
|
99
|
+
else
|
|
100
|
+
redirect_to "blu", :alert => "Failed!"
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
protected
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class SorceryMailer < ActionMailer::Base
|
|
2
|
+
|
|
3
|
+
default :from => "notifications@example.com"
|
|
4
|
+
|
|
5
|
+
def activation_needed_email(user)
|
|
6
|
+
@user = user
|
|
7
|
+
@url = "http://example.com/login"
|
|
8
|
+
mail(:to => user.email,
|
|
9
|
+
:subject => "Welcome to My Awesome Site")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def activation_success_email(user)
|
|
13
|
+
@user = user
|
|
14
|
+
@url = "http://example.com/login"
|
|
15
|
+
mail(:to => user.email,
|
|
16
|
+
:subject => "Your account is now activated")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def reset_password_email(user)
|
|
20
|
+
@user = user
|
|
21
|
+
@url = "http://example.com/login"
|
|
22
|
+
mail(:to => user.email,
|
|
23
|
+
:subject => "Your password has been reset")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h1>Welcome to example.com, <%= @user.username %></h1>
|
|
8
|
+
<p>
|
|
9
|
+
You have successfully signed up to example.com,
|
|
10
|
+
your username is: <%= @user.username %>.<br/>
|
|
11
|
+
</p>
|
|
12
|
+
<p>
|
|
13
|
+
To login to the site, just follow this link: <%= @url %>.
|
|
14
|
+
</p>
|
|
15
|
+
<p>Thanks for joining and have a great day!</p>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Welcome to example.com, <%= @user.username %>
|
|
2
|
+
===============================================
|
|
3
|
+
|
|
4
|
+
You have successfully signed up to example.com,
|
|
5
|
+
your username is: <%= @user.username %>.
|
|
6
|
+
|
|
7
|
+
To login to the site, just follow this link: <%= @url %>.
|
|
8
|
+
|
|
9
|
+
Thanks for joining and have a great day!
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h1>Congratz, <%= @user.username %></h1>
|
|
8
|
+
<p>
|
|
9
|
+
You have successfully activated your example.com account,
|
|
10
|
+
your username is: <%= @user.username %>.<br/>
|
|
11
|
+
</p>
|
|
12
|
+
<p>
|
|
13
|
+
To login to the site, just follow this link: <%= @url %>.
|
|
14
|
+
</p>
|
|
15
|
+
<p>Thanks for joining and have a great day!</p>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Congratz, <%= @user.username %>
|
|
2
|
+
===============================================
|
|
3
|
+
|
|
4
|
+
You have successfully activated your example.com account,
|
|
5
|
+
your username is: <%= @user.username %>.
|
|
6
|
+
|
|
7
|
+
To login to the site, just follow this link: <%= @url %>.
|
|
8
|
+
|
|
9
|
+
Thanks for joining and have a great day!
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<h1>Hello, <%= @user.username %></h1>
|
|
8
|
+
<p>
|
|
9
|
+
You have requested to reset your password.
|
|
10
|
+
</p>
|
|
11
|
+
<p>
|
|
12
|
+
To choose a new password, just follow this link: <%= @url %>.
|
|
13
|
+
</p>
|
|
14
|
+
<p>Have a great day!</p>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require "action_controller/railtie"
|
|
4
|
+
require "action_mailer/railtie"
|
|
5
|
+
require "active_resource/railtie"
|
|
6
|
+
require "rails/test_unit/railtie"
|
|
7
|
+
|
|
8
|
+
require "mongoid"
|
|
9
|
+
|
|
10
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
|
11
|
+
# you've limited to :test, :development, or :production.
|
|
12
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
|
13
|
+
|
|
14
|
+
module AppRoot
|
|
15
|
+
class Application < Rails::Application
|
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
17
|
+
# Application configuration should go into files in config/initializers
|
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
19
|
+
|
|
20
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
|
21
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
|
22
|
+
|
|
23
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
|
24
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
|
25
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|
26
|
+
|
|
27
|
+
# Activate observers that should always be running.
|
|
28
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|
29
|
+
|
|
30
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
31
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
32
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
33
|
+
|
|
34
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
35
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
36
|
+
# config.i18n.default_locale = :de
|
|
37
|
+
|
|
38
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
|
39
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
|
40
|
+
|
|
41
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
|
42
|
+
config.encoding = "utf-8"
|
|
43
|
+
|
|
44
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
|
45
|
+
config.filter_parameters += [:password]
|
|
46
|
+
|
|
47
|
+
config.action_mailer.delivery_method = :test
|
|
48
|
+
|
|
49
|
+
config.active_support.deprecation = :stderr
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
|
|
3
|
+
# Set up gems listed in the Gemfile.
|
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
|
5
|
+
begin
|
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
|
7
|
+
require 'bundler'
|
|
8
|
+
Bundler.setup
|
|
9
|
+
rescue Bundler::GemNotFound => e
|
|
10
|
+
STDERR.puts e.message
|
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
|
12
|
+
exit!
|
|
13
|
+
end if File.exist?(gemfile)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
AppRoot::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_view.debug_rjs = true
|
|
15
|
+
config.action_controller.perform_caching = false
|
|
16
|
+
|
|
17
|
+
# Don't care if the mailer can't send
|
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
|
19
|
+
|
|
20
|
+
# Print deprecation notices to the Rails logger
|
|
21
|
+
config.active_support.deprecation = :log
|
|
22
|
+
|
|
23
|
+
# Only use best-standards-support built into browsers
|
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
|
25
|
+
end
|
|
26
|
+
|
|
File without changes
|