teamon-merb-auth-slice-password-reset 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +219 -0
- data/Rakefile +57 -0
- data/TODO +2 -0
- data/app/controllers/application.rb +5 -0
- data/app/controllers/passwords.rb +37 -0
- data/app/helpers/application_helper.rb +64 -0
- data/app/helpers/mailer_helper.rb +28 -0
- data/app/mailers/password_reset_mailer.rb +19 -0
- data/app/mailers/views/password_reset_mailer/new_password.html.erb +3 -0
- data/app/mailers/views/password_reset_mailer/password_reset.text.erb +5 -0
- data/app/views/layout/merb_auth_slice_password_reset.html.erb +16 -0
- data/app/views/passwords/forgot_password.html.erb +7 -0
- data/lib/merb-auth-slice-password-reset.rb +85 -0
- data/lib/merb-auth-slice-password-reset/merbtasks.rb +112 -0
- data/lib/merb-auth-slice-password-reset/mixins/senile_user.rb +90 -0
- data/lib/merb-auth-slice-password-reset/mixins/senile_user/ar_senile_user.rb +19 -0
- data/lib/merb-auth-slice-password-reset/mixins/senile_user/dm_senile_user.rb +22 -0
- data/lib/merb-auth-slice-password-reset/mixins/senile_user/sq_senile_user.rb +20 -0
- data/lib/merb-auth-slice-password-reset/slicetasks.rb +18 -0
- data/lib/merb-auth-slice-password-reset/spectasks.rb +75 -0
- data/public/javascripts/master.js +0 -0
- data/public/stylesheets/master.css +2 -0
- data/spec/mailers/password_reset_mailer_spec.rb +49 -0
- data/spec/mixins/senile_user_spec.rb +111 -0
- data/spec/spec_helper.rb +61 -0
- data/stubs/app/controllers/passwords.rb +13 -0
- data/stubs/app/mailers/views/password_reset_mailer/new_password.html.erb +3 -0
- data/stubs/app/mailers/views/password_reset_mailer/password_reset.text.erb +5 -0
- data/stubs/app/views/passwords/forgot_password.html.erb +7 -0
- metadata +141 -0
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "PasswordResetMailer" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Merb::Router.prepare { add_slice(:merb_auth_slice_password_reset)}
|
7
|
+
User.auto_migrate!
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
Merb::Router.reset!
|
12
|
+
end
|
13
|
+
|
14
|
+
describe MerbAuthSlicePasswordReset::PasswordResetMailer do
|
15
|
+
|
16
|
+
def deliver(action, mail_opts= {},opts = {})
|
17
|
+
MerbAuthSlicePasswordReset::PasswordResetMailer.dispatch_and_deliver action, mail_opts, opts
|
18
|
+
@delivery = Merb::Mailer.deliveries.last
|
19
|
+
end
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
@u = User.new(:email => "homer@simpsons.com", :login => "homer", :password_reset_code => "12345")
|
23
|
+
@mailer_params = { :from => "info@mysite.com", :to => @u.email, :subject => "Welcome to MySite.com" }
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
Merb::Mailer.deliveries.clear
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should send mail to homer@simpsons.com for the password reset email" do
|
31
|
+
deliver(:password_reset, @mailer_params, :user => @u)
|
32
|
+
@delivery.assigns(:headers).should include("to: homer@simpsons.com")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should send the mail from 'info@mysite.com' for the the password reset email" do
|
36
|
+
deliver(:password_reset, @mailer_params, :user => @u)
|
37
|
+
@delivery.assigns(:headers).should include("from: info@mysite.com")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should mention the password reset link in the the password reset emails" do
|
41
|
+
deliver(:password_reset, @mailer_params, :user => @u)
|
42
|
+
the_url = MerbAuthSlicePasswordReset::PasswordResetMailer.new.slice_url(:reset_password, :password_reset_code => @u.password_reset_code)
|
43
|
+
the_url.should_not be_nil
|
44
|
+
@delivery.text.should include(the_url)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Senile User" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Merb::Router.prepare { add_slice(:merb_auth_slice_password_reset) }
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
Merb::Router.reset!
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "SenileUser Mixin" do
|
14
|
+
|
15
|
+
include SenileUserSpecHelper
|
16
|
+
|
17
|
+
before(:all) do
|
18
|
+
User.auto_migrate!
|
19
|
+
end
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
@user = User.new(user_attributes)
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) do
|
26
|
+
User.all.destroy!
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should add the 'password_reset_code' property to the user model" do
|
30
|
+
@user.should respond_to(:password_reset_code)
|
31
|
+
@user.should respond_to(:password_reset_code=)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# describe "SenileUser Mixin Activation Code" do
|
38
|
+
#
|
39
|
+
# include SenileUserSpecHelper
|
40
|
+
#
|
41
|
+
# before(:all) do
|
42
|
+
# User.auto_migrate!
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# after(:each) do
|
46
|
+
# User.all.destroy!
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# before(:each) do
|
50
|
+
# @user = User.new(user_attributes)
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# it "should set the activation_code" do
|
54
|
+
# @user.activation_code.should be_nil
|
55
|
+
# @user.save
|
56
|
+
# @user.activation_code.should_not be_nil
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
#
|
61
|
+
# describe "Activation" do
|
62
|
+
#
|
63
|
+
# include SenileUserSpecHelper
|
64
|
+
#
|
65
|
+
# before(:all) do
|
66
|
+
# User.auto_migrate!
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# before(:each) do
|
70
|
+
# User.all.destroy!
|
71
|
+
# @user = User.create(user_attributes)
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# after(:each) do
|
75
|
+
# User.all.destroy!
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# it "should mark users as active" do
|
79
|
+
# @user.should_not be_active
|
80
|
+
# @user.activate
|
81
|
+
# @user.should be_active
|
82
|
+
# @user.reload
|
83
|
+
# @user.should be_active
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# it "should mark user as (just) activated" do
|
87
|
+
# @user.activate
|
88
|
+
# @user.should be_recently_activated
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# it "should set the activated_at property to the current date and time" do
|
92
|
+
# now = DateTime.now
|
93
|
+
# DateTime.should_receive(:now).and_return(now)
|
94
|
+
# @user.activate
|
95
|
+
# @user.activated_at.should == now
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# it "should clear out the activation code" do
|
99
|
+
# @user.activation_code.should_not be_nil
|
100
|
+
# @user.activate
|
101
|
+
# @user.activation_code.should be_nil
|
102
|
+
# end
|
103
|
+
#
|
104
|
+
# it "should send out the activation notification" do
|
105
|
+
# @user.should_receive(:send_activation_notification)
|
106
|
+
# @user.activate
|
107
|
+
# end
|
108
|
+
#
|
109
|
+
# end
|
110
|
+
|
111
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'merb-core'
|
3
|
+
require 'merb-slices'
|
4
|
+
require 'spec'
|
5
|
+
require 'dm-core'
|
6
|
+
require 'dm-validations'
|
7
|
+
|
8
|
+
# Add merb-auth-slice-password-reset.rb to the search path
|
9
|
+
Merb::Plugins.config[:merb_slices][:auto_register] = true
|
10
|
+
Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', 'merb-auth-slice-password-reset.rb')
|
11
|
+
|
12
|
+
# Using Merb.root below makes sure that the correct root is set for
|
13
|
+
# - testing standalone, without being installed as a gem and no host application
|
14
|
+
# - testing from within the host application; its root will be used
|
15
|
+
Merb.start_environment(
|
16
|
+
:testing => true,
|
17
|
+
:adapter => 'runner',
|
18
|
+
:environment => ENV['MERB_ENV'] || 'test',
|
19
|
+
:merb_root => Merb.root,
|
20
|
+
:session_store => :memory,
|
21
|
+
:exception_details => true
|
22
|
+
)
|
23
|
+
|
24
|
+
module Merb
|
25
|
+
module Test
|
26
|
+
module SliceHelper
|
27
|
+
|
28
|
+
# The absolute path to the current slice
|
29
|
+
def current_slice_root
|
30
|
+
@current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
31
|
+
end
|
32
|
+
|
33
|
+
# Whether the specs are being run from a host application or standalone
|
34
|
+
def standalone?
|
35
|
+
Merb.root == ::MerbAuthSlicePasswordReset.root
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module SenileUserSpecHelper
|
43
|
+
def user_attributes(options = {})
|
44
|
+
{ :login => 'fred',
|
45
|
+
:email => 'fred@example.com'
|
46
|
+
}.merge(options)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Merb::Mailer
|
51
|
+
self.delivery_method = :test_send
|
52
|
+
end
|
53
|
+
|
54
|
+
Spec::Runner.configure do |config|
|
55
|
+
config.include(Merb::Test::ViewHelper)
|
56
|
+
config.include(Merb::Test::RouteHelper)
|
57
|
+
config.include(Merb::Test::ControllerHelper)
|
58
|
+
config.include(Merb::Test::SliceHelper)
|
59
|
+
config.include(SenileUserSpecHelper)
|
60
|
+
config.before(:all){ User.auto_migrate! }
|
61
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class MerbAuthSlicePasswordReset::Passwords < MerbAuthSlicePasswordReset::Application
|
2
|
+
|
3
|
+
private
|
4
|
+
|
5
|
+
def redirect_after_password_reset
|
6
|
+
redirect "/", :message => {:notice => "New password sent".t}
|
7
|
+
end
|
8
|
+
|
9
|
+
def redirect_after_sending_confirmation
|
10
|
+
redirect "/", :message => {:notice => "Password Reset confirmaation sent".t}
|
11
|
+
end
|
12
|
+
|
13
|
+
end # MerbAuthSlicePasswordReset::Passwords
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<form action="" method="post">
|
2
|
+
<p>
|
3
|
+
<label for="<%= @login_param_name %>"><%= @login_param_name.to_s.capitalize.t %></label>
|
4
|
+
<input type="text" class="text" name="<%= @login_param_name %>" id="<%= @login_param_name %>" />
|
5
|
+
</p>
|
6
|
+
<input type="submit" value="Reset password" />
|
7
|
+
</form>
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teamon-merb-auth-slice-password-reset
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Neighman, Christian Kebekus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-10 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-slices
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: merb-auth-core
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 1.0.0
|
32
|
+
version:
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: merb-auth-more
|
35
|
+
version_requirement:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.0
|
41
|
+
version:
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: merb-mailer
|
44
|
+
version_requirement:
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.0.0
|
50
|
+
version:
|
51
|
+
description: Merb Slice that adds basic password-reset functionality to merb-auth-based merb applications.
|
52
|
+
email: has.sox@gmail.com
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- README.textile
|
59
|
+
- LICENSE
|
60
|
+
- TODO
|
61
|
+
files:
|
62
|
+
- LICENSE
|
63
|
+
- README.textile
|
64
|
+
- Rakefile
|
65
|
+
- TODO
|
66
|
+
- lib/merb-auth-slice-password-reset
|
67
|
+
- lib/merb-auth-slice-password-reset/merbtasks.rb
|
68
|
+
- lib/merb-auth-slice-password-reset/mixins
|
69
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user
|
70
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/ar_senile_user.rb
|
71
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/dm_senile_user.rb
|
72
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/sq_senile_user.rb
|
73
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user.rb
|
74
|
+
- lib/merb-auth-slice-password-reset/slicetasks.rb
|
75
|
+
- lib/merb-auth-slice-password-reset/spectasks.rb
|
76
|
+
- lib/merb-auth-slice-password-reset.rb
|
77
|
+
- spec/mailers
|
78
|
+
- spec/mailers/password_reset_mailer_spec.rb
|
79
|
+
- spec/mixins
|
80
|
+
- spec/mixins/senile_user_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- app/controllers
|
83
|
+
- app/controllers/application.rb
|
84
|
+
- app/controllers/passwords.rb
|
85
|
+
- app/helpers
|
86
|
+
- app/helpers/application_helper.rb
|
87
|
+
- app/helpers/mailer_helper.rb
|
88
|
+
- app/mailers
|
89
|
+
- app/mailers/password_reset_mailer.rb
|
90
|
+
- app/mailers/views
|
91
|
+
- app/mailers/views/password_reset_mailer
|
92
|
+
- app/mailers/views/password_reset_mailer/new_password.html.erb
|
93
|
+
- app/mailers/views/password_reset_mailer/password_reset.text.erb
|
94
|
+
- app/views
|
95
|
+
- app/views/layout
|
96
|
+
- app/views/layout/merb_auth_slice_password_reset.html.erb
|
97
|
+
- app/views/passwords
|
98
|
+
- app/views/passwords/forgot_password.html.erb
|
99
|
+
- public/javascripts
|
100
|
+
- public/javascripts/master.js
|
101
|
+
- public/stylesheets
|
102
|
+
- public/stylesheets/master.css
|
103
|
+
- stubs/app
|
104
|
+
- stubs/app/controllers
|
105
|
+
- stubs/app/controllers/passwords.rb
|
106
|
+
- stubs/app/mailers
|
107
|
+
- stubs/app/mailers/views
|
108
|
+
- stubs/app/mailers/views/password_reset_mailer
|
109
|
+
- stubs/app/mailers/views/password_reset_mailer/new_password.html.erb
|
110
|
+
- stubs/app/mailers/views/password_reset_mailer/password_reset.text.erb
|
111
|
+
- stubs/app/views
|
112
|
+
- stubs/app/views/passwords
|
113
|
+
- stubs/app/views/passwords/forgot_password.html.erb
|
114
|
+
has_rdoc: true
|
115
|
+
homepage: http://merbivore.com/
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: "0"
|
126
|
+
version:
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: "0"
|
132
|
+
version:
|
133
|
+
requirements: []
|
134
|
+
|
135
|
+
rubyforge_project: merb
|
136
|
+
rubygems_version: 1.2.0
|
137
|
+
signing_key:
|
138
|
+
specification_version: 2
|
139
|
+
summary: Merb Slice that adds basic password-reset functionality to merb-auth-based merb applications.
|
140
|
+
test_files: []
|
141
|
+
|