scottmotte-merb-auth-slice-password-reset 0.9.14
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/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 +93 -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/mm_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 +146 -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 confirmation 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,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scottmotte-merb-auth-slice-password-reset
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.14
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Neighman, Christian Kebekus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-17 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-slices
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: merb-auth-core
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: merb-auth-more
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: merb-mailer
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.0
|
54
|
+
version:
|
55
|
+
description: Merb Slice that adds basic password-reset functionality to merb-auth-based merb applications.
|
56
|
+
email: has.sox@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README.textile
|
63
|
+
- LICENSE
|
64
|
+
- TODO
|
65
|
+
files:
|
66
|
+
- LICENSE
|
67
|
+
- README.textile
|
68
|
+
- Rakefile
|
69
|
+
- TODO
|
70
|
+
- lib/merb-auth-slice-password-reset
|
71
|
+
- lib/merb-auth-slice-password-reset/merbtasks.rb
|
72
|
+
- lib/merb-auth-slice-password-reset/mixins
|
73
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user
|
74
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/ar_senile_user.rb
|
75
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/dm_senile_user.rb
|
76
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/mm_senile_user.rb
|
77
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user/sq_senile_user.rb
|
78
|
+
- lib/merb-auth-slice-password-reset/mixins/senile_user.rb
|
79
|
+
- lib/merb-auth-slice-password-reset/slicetasks.rb
|
80
|
+
- lib/merb-auth-slice-password-reset/spectasks.rb
|
81
|
+
- lib/merb-auth-slice-password-reset.rb
|
82
|
+
- spec/mailers
|
83
|
+
- spec/mailers/password_reset_mailer_spec.rb
|
84
|
+
- spec/mixins
|
85
|
+
- spec/mixins/senile_user_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- app/controllers
|
88
|
+
- app/controllers/application.rb
|
89
|
+
- app/controllers/passwords.rb
|
90
|
+
- app/helpers
|
91
|
+
- app/helpers/application_helper.rb
|
92
|
+
- app/helpers/mailer_helper.rb
|
93
|
+
- app/mailers
|
94
|
+
- app/mailers/password_reset_mailer.rb
|
95
|
+
- app/mailers/views
|
96
|
+
- app/mailers/views/password_reset_mailer
|
97
|
+
- app/mailers/views/password_reset_mailer/new_password.html.erb
|
98
|
+
- app/mailers/views/password_reset_mailer/password_reset.text.erb
|
99
|
+
- app/views
|
100
|
+
- app/views/layout
|
101
|
+
- app/views/layout/merb_auth_slice_password_reset.html.erb
|
102
|
+
- app/views/passwords
|
103
|
+
- app/views/passwords/forgot_password.html.erb
|
104
|
+
- public/javascripts
|
105
|
+
- public/javascripts/master.js
|
106
|
+
- public/stylesheets
|
107
|
+
- public/stylesheets/master.css
|
108
|
+
- stubs/app
|
109
|
+
- stubs/app/controllers
|
110
|
+
- stubs/app/controllers/passwords.rb
|
111
|
+
- stubs/app/mailers
|
112
|
+
- stubs/app/mailers/views
|
113
|
+
- stubs/app/mailers/views/password_reset_mailer
|
114
|
+
- stubs/app/mailers/views/password_reset_mailer/new_password.html.erb
|
115
|
+
- stubs/app/mailers/views/password_reset_mailer/password_reset.text.erb
|
116
|
+
- stubs/app/views
|
117
|
+
- stubs/app/views/passwords
|
118
|
+
- stubs/app/views/passwords/forgot_password.html.erb
|
119
|
+
has_rdoc: false
|
120
|
+
homepage: http://merbivore.com/
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: "0"
|
131
|
+
version:
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: "0"
|
137
|
+
version:
|
138
|
+
requirements: []
|
139
|
+
|
140
|
+
rubyforge_project: merb
|
141
|
+
rubygems_version: 1.2.0
|
142
|
+
signing_key:
|
143
|
+
specification_version: 3
|
144
|
+
summary: Merb Slice that adds basic password-reset functionality to merb-auth-based merb applications.
|
145
|
+
test_files: []
|
146
|
+
|