thoughtbot-clearance 0.2.7 → 0.2.8
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/README.textile +2 -2
- data/Rakefile +2 -1
- data/TODO.textile +0 -1
- data/lib/clearance/test/functional/sessions_controller_test.rb +45 -16
- data/lib/clearance/version.rb +2 -2
- metadata +3 -3
data/README.textile
CHANGED
@@ -50,9 +50,9 @@ This will create:
|
|
50
50
|
test/unit/user_mailer_test.rb
|
51
51
|
test/unit/user_test.rb
|
52
52
|
|
53
|
-
|
53
|
+
Add the corresponding Clearance module for any file(s) you don't want to override. They are namespaced exactly like the directory structure of a Rails app:
|
54
54
|
|
55
|
-
app/models/user.rb already exists.
|
55
|
+
app/models/user.rb already exists.
|
56
56
|
include Clearance::App::Models::User
|
57
57
|
|
58
58
|
h2. Tests
|
data/Rakefile
CHANGED
@@ -18,11 +18,12 @@ spec = Gem::Specification.new do |s|
|
|
18
18
|
s.email = "dcroak@thoughtbot.com"
|
19
19
|
s.homepage = "http://github.com/thoughtbot/clearance"
|
20
20
|
s.description = "Simple, complete Rails authentication scheme."
|
21
|
-
s.authors = ["thoughtbot, inc.", "Dan Croak", "Josh Nichols", "
|
21
|
+
s.authors = ["thoughtbot, inc.", "Dan Croak", "Josh Nichols", "Jason Morrison", "Mike Burns", "Mike Breen"]
|
22
22
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
23
23
|
end
|
24
24
|
|
25
25
|
begin
|
26
|
+
require 'rubygems'
|
26
27
|
require 'jeweler'
|
27
28
|
Jeweler.gemspec = spec
|
28
29
|
rescue LoadError
|
data/TODO.textile
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
# activation code instead of salt?
|
4
4
|
# users#show doesn't exist, but confirmations create redirects there
|
5
|
-
# sessions controller test is missing remember_me tests
|
6
5
|
# mailers should not hardcode example.com as from address
|
7
6
|
# should_have_form should be pulled into shoulda
|
8
7
|
# generator should print out instructions to include modules existing files
|
@@ -24,36 +24,65 @@ module Clearance
|
|
24
24
|
|
25
25
|
context "a POST to #create with good credentials" do
|
26
26
|
setup do
|
27
|
-
post :create, :session => { :email => @user.email,
|
27
|
+
post :create, :session => { :email => @user.email,
|
28
|
+
:password => @user.password }
|
28
29
|
end
|
29
30
|
|
30
31
|
should_set_the_flash_to /success/i
|
31
32
|
should_redirect_to '@controller.send(:url_after_create)'
|
32
|
-
|
33
|
-
should "return the correct value from the session for key :user_id" do
|
34
|
-
instantiate_variables_from_assigns do
|
35
|
-
expected_value = @user.id
|
36
|
-
assert_equal expected_value, session[:user_id], "Expected #{expected_value.inspect} but was #{session[:user_id]}"
|
37
|
-
end
|
38
|
-
end
|
33
|
+
should_return_from_session :user_id, "@user.id"
|
39
34
|
end
|
40
35
|
|
41
36
|
context "a POST to #create with bad credentials" do
|
42
37
|
setup do
|
43
|
-
post :create, :session => { :email => @user.email,
|
38
|
+
post :create, :session => { :email => @user.email,
|
39
|
+
:password => "bad value" }
|
44
40
|
end
|
45
41
|
|
46
42
|
should_set_the_flash_to /bad/i
|
47
43
|
should_render_template :new
|
48
|
-
|
49
|
-
should "return nil from the session for key :user_id" do
|
50
|
-
instantiate_variables_from_assigns do
|
51
|
-
assert_nil session[:user_id], "Expected nil but was #{session[:user_id]}"
|
52
|
-
end
|
53
|
-
end
|
44
|
+
should_return_from_session :user_id, "nil"
|
54
45
|
end
|
55
46
|
|
56
|
-
#
|
47
|
+
context "a POST to #create with good credentials and remember me" do
|
48
|
+
setup do
|
49
|
+
post :create, :session => { :email => @user.email,
|
50
|
+
:password => @user.password, :remember_me => '1' }
|
51
|
+
end
|
52
|
+
|
53
|
+
should_set_the_flash_to /success/i
|
54
|
+
should_redirect_to '@controller.send(:url_after_create)'
|
55
|
+
should_return_from_session :user_id, "@user.id"
|
56
|
+
|
57
|
+
should 'set the cookie' do
|
58
|
+
assert ! cookies['auth_token'].empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
should 'set the remember me token in users table' do
|
62
|
+
assert_not_nil @user.reload.remember_token
|
63
|
+
assert_not_nil @user.reload.remember_token_expires_at
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "a POST to #create with bad credentials and remember me" do
|
68
|
+
setup do
|
69
|
+
post :create, :session => { :email => @user.email,
|
70
|
+
:password => "bad value", :remember_me => '1' }
|
71
|
+
end
|
72
|
+
|
73
|
+
should_set_the_flash_to /bad/i
|
74
|
+
should_render_template :new
|
75
|
+
should_return_from_session :user_id, "nil"
|
76
|
+
|
77
|
+
should 'not create the cookie' do
|
78
|
+
assert_nil cookies['auth_token']
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'not set the remember me token in users table' do
|
82
|
+
assert_nil @user.reload.remember_token
|
83
|
+
assert_nil @user.reload.remember_token_expires_at
|
84
|
+
end
|
85
|
+
end
|
57
86
|
end
|
58
87
|
|
59
88
|
public_context do
|
data/lib/clearance/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
8
8
|
- Dan Croak
|
9
9
|
- Josh Nichols
|
10
|
-
- Mike Breen
|
11
|
-
- Mike Burns
|
12
10
|
- Jason Morrison
|
11
|
+
- Mike Burns
|
12
|
+
- Mike Breen
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|