thoughtbot-clearance 0.2.9 → 0.3.0
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/TODO.textile +1 -2
- data/lib/clearance/app/controllers/confirmations_controller.rb +5 -1
- data/lib/clearance/app/controllers/passwords_controller.rb +7 -1
- data/lib/clearance/app/controllers/sessions_controller.rb +3 -3
- data/lib/clearance/test/functional/confirmations_controller_test.rb +1 -1
- data/lib/clearance/test/functional/passwords_controller_test.rb +4 -8
- data/lib/clearance/test/functional/sessions_controller_test.rb +1 -1
- data/lib/clearance/test/unit/user_mailer_test.rb +29 -4
- data/lib/clearance/version.rb +6 -6
- data/test/rails_root/config/environment.rb +1 -2
- metadata +1 -1
data/TODO.textile
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
(highest priority first)
|
2
2
|
|
3
|
-
# change url_after_creates to be a class method or use after_filter
|
4
3
|
# activation code (like restful-auth) instead of salt?
|
5
4
|
# remove dependency on root_url?
|
6
|
-
# users#show doesn't exist, but confirmations create redirects there
|
7
5
|
# should_have_form should be pulled into shoulda
|
8
6
|
# generator should print out instructions to include modules existing files
|
9
7
|
# check to make sure attr_accessible doesn't override and w/ attr_protected
|
10
8
|
# move shoulda macros in test_helper to shoulda_macros folder
|
11
9
|
# add shoulda and factory girl dependencies to gemspec
|
12
10
|
# refactor Mailer default_url_options[:host] to something cleaner
|
11
|
+
# application controller uses protected, all other controllers use private
|
13
12
|
|
14
13
|
ideas to steal from merb-auth:
|
15
14
|
|
@@ -23,7 +23,7 @@ module Clearance
|
|
23
23
|
@user = User.find_by_id_and_salt(params[:user_id], params[:salt])
|
24
24
|
@user.confirm!
|
25
25
|
session[:user_id] = @user.id
|
26
|
-
redirect_to
|
26
|
+
redirect_to url_after_create
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -34,6 +34,10 @@ module Clearance
|
|
34
34
|
render :nothing => true, :status => :not_found
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def url_after_create
|
39
|
+
root_url
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
end
|
@@ -7,7 +7,9 @@ module Clearance
|
|
7
7
|
base.class_eval do
|
8
8
|
before_filter :existing_user?, :only => [:edit, :update]
|
9
9
|
filter_parameter_logging :password, :password_confirmation
|
10
|
+
|
10
11
|
include InstanceMethods
|
12
|
+
|
11
13
|
private
|
12
14
|
include PrivateInstanceMethods
|
13
15
|
end
|
@@ -24,7 +26,7 @@ module Clearance
|
|
24
26
|
render :action => :new
|
25
27
|
else
|
26
28
|
UserMailer.deliver_change_password user
|
27
|
-
redirect_to
|
29
|
+
redirect_to url_after_create
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
@@ -53,6 +55,10 @@ module Clearance
|
|
53
55
|
render :nothing => true, :status => :not_found
|
54
56
|
end
|
55
57
|
end
|
58
|
+
|
59
|
+
def url_after_create
|
60
|
+
new_session_url
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
64
|
end
|
@@ -11,8 +11,8 @@ module Clearance
|
|
11
11
|
|
12
12
|
include InstanceMethods
|
13
13
|
|
14
|
-
|
15
|
-
include
|
14
|
+
private
|
15
|
+
include PrivateInstanceMethods
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -30,7 +30,7 @@ module Clearance
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
module
|
33
|
+
module PrivateInstanceMethods
|
34
34
|
def login_via_password(email, password, remember_me)
|
35
35
|
user = user_model.authenticate(email, password)
|
36
36
|
if login(user)
|
@@ -28,10 +28,10 @@ module Clearance
|
|
28
28
|
end
|
29
29
|
|
30
30
|
should 'send an email to the user to edit their password' do
|
31
|
-
assert @email.subject =~ /
|
31
|
+
assert @email.subject =~ /change your password/i
|
32
32
|
end
|
33
33
|
|
34
|
-
should_redirect_to "
|
34
|
+
should_redirect_to "@controller.send(:url_after_create)"
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'with a non-existing email address' do
|
@@ -86,9 +86,7 @@ module Clearance
|
|
86
86
|
|
87
87
|
context "with an existing user's id but not password" do
|
88
88
|
setup do
|
89
|
-
get
|
90
|
-
:user_id => @user.id,
|
91
|
-
:password => '')
|
89
|
+
get :edit, :user_id => @user.id, :password => ''
|
92
90
|
end
|
93
91
|
|
94
92
|
should_respond_with :not_found
|
@@ -102,9 +100,7 @@ module Clearance
|
|
102
100
|
context 'A PUT to #update' do
|
103
101
|
context "with an existing user's id but not password" do
|
104
102
|
setup do
|
105
|
-
put
|
106
|
-
:user_id => @user.id,
|
107
|
-
:password => '')
|
103
|
+
put :update, :user_id => @user.id, :password => ''
|
108
104
|
end
|
109
105
|
|
110
106
|
should "not update the user's password" do
|
@@ -51,7 +51,7 @@ module Clearance
|
|
51
51
|
end
|
52
52
|
|
53
53
|
should_set_the_flash_to /success/i
|
54
|
-
should_redirect_to
|
54
|
+
should_redirect_to "@controller.send(:url_after_create)"
|
55
55
|
should_return_from_session :user_id, "@user.id"
|
56
56
|
|
57
57
|
should 'set the cookie' do
|
@@ -11,8 +11,8 @@ module Clearance
|
|
11
11
|
@email = UserMailer.create_change_password @user
|
12
12
|
end
|
13
13
|
|
14
|
-
should "set its from address to
|
15
|
-
assert_equal
|
14
|
+
should "set its from address to DO_NOT_REPLY" do
|
15
|
+
assert_equal DO_NOT_REPLY, @email.from[0]
|
16
16
|
end
|
17
17
|
|
18
18
|
should "contain a link to edit the user's password" do
|
@@ -25,8 +25,33 @@ module Clearance
|
|
25
25
|
assert_equal [@user.email], @email.to
|
26
26
|
end
|
27
27
|
|
28
|
-
should "have a subject of '[
|
29
|
-
assert_equal "[
|
28
|
+
should "have a subject of '[PROJECT_NAME] Change your password'" do
|
29
|
+
assert_equal @email.subject, "[#{PROJECT_NAME.humanize}] Change your password"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "A confirmation email" do
|
34
|
+
setup do
|
35
|
+
@user = Factory :user
|
36
|
+
@email = UserMailer.create_confirmation @user
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'set its recipient to the given user' do
|
40
|
+
assert_equal @user.email, @email.to[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'set its subject' do
|
44
|
+
assert_equal "[#{PROJECT_NAME.humanize}] Email confirmation", @email.subject
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'set its from address to DO_NOT_REPLY' do
|
48
|
+
assert_equal DO_NOT_REPLY, @email.from[0]
|
49
|
+
end
|
50
|
+
|
51
|
+
should "contain a link to confirm the user's account" do
|
52
|
+
host = ActionMailer::Base.default_url_options[:host]
|
53
|
+
regexp = %r{http://#{host}/users/#{@user.id}/confirmation/new\?salt=#{@user.salt}}
|
54
|
+
assert_match regexp, @email.body
|
30
55
|
end
|
31
56
|
end
|
32
57
|
end
|
data/lib/clearance/version.rb
CHANGED