josevalim-auth_helpers 0.1.1 → 0.1.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/README CHANGED
@@ -1,14 +1,14 @@
1
- AuthHelpers
2
- License: MIT
3
- Version: 0.1
4
-
5
- You can also read this README in pretty html at the GitHub project Wiki page:
6
-
7
- http://wiki.github.com/josevalim/auth_helpers
8
-
9
- Description
10
- -----------
11
-
1
+ AuthHelpers
2
+ License: MIT
3
+ Version: 0.2
4
+
5
+ You can also read this README in pretty html at the GitHub project Wiki page:
6
+
7
+ http://wiki.github.com/josevalim/auth_helpers
8
+
9
+ Description
10
+ -----------
11
+
12
12
  AuthHelpers is a collection of modules to include in your model to deal with
13
13
  authentication.
14
14
 
@@ -23,22 +23,22 @@ While working in different projects, requisites change and sometimes you need
23
23
  something that works between something simple and something fully featured. This
24
24
  is the scope of AuthHelpers: you have modules and you include them where you
25
25
  want.
26
-
27
- Installation
28
- ------------
29
-
26
+
27
+ Installation
28
+ ------------
29
+
30
30
  Install AuthHelpers is very easy. It is stored in GitHub, so just run the
31
- following:
32
-
33
- gem sources -a http://gems.github.com
34
- sudo gem install josevalim-auth_helpers
35
-
36
- If you want it as plugin, just do:
37
-
38
- script/plugin install git://github.com/josevalim/auth_helpers.git
39
-
40
- Modules
41
- -------
31
+ following:
32
+
33
+ gem sources -a http://gems.github.com
34
+ sudo gem install josevalim-auth_helpers
35
+
36
+ If you want it as plugin, just do:
37
+
38
+ script/plugin install git://github.com/josevalim/auth_helpers.git
39
+
40
+ Modules
41
+ -------
42
42
 
43
43
  class Account < ActiveRecord::Base
44
44
  SALT = APP_NAME
@@ -105,21 +105,21 @@ So if you want to test the Account model declared above, just do:
105
105
  include AuthHelpers::Spec::Recoverable
106
106
  include AuthHelpers::Spec::Rememberable
107
107
  include AuthHelpers::Spec::Validatable
108
-
109
- before(:each) do
110
- @valid_attributes = {
111
- :email => "is.valid@email.com",
112
- :email_confirmation => "is.valid@email.com",
113
- :password => "abcdef",
114
- :password_confirmation => "abcdef"
115
- }
116
- end
117
-
118
- it "should create a new instance given valid attributes" do
119
- Account.create!(@valid_attributes)
108
+
109
+ before(:each) do
110
+ @valid_attributes = {
111
+ :email => "is.valid@email.com",
112
+ :email_confirmation => "is.valid@email.com",
113
+ :password => "abcdef",
114
+ :password_confirmation => "abcdef"
115
+ }
116
+ end
117
+
118
+ it "should create a new instance given valid attributes" do
119
+ Account.create!(@valid_attributes)
120
120
  end
121
121
  end
122
-
122
+
123
123
  The only requisite you have for the tests is to have a @valid_attributes instance
124
124
  variable set with a hash of valid attributes. You also need Remarkable to run
125
125
  those tests.
@@ -141,14 +141,15 @@ example for the Account model above:
141
141
  t.recoverable
142
142
  t.rememberable
143
143
  t.timestamps
144
- end
145
-
146
- Notifications
147
- ------------
144
+ end
145
+
146
+ Notifications
147
+ -------------
148
148
 
149
149
  AuthHelpers also comes with default notification files. At some point you will
150
150
  want to prettify your notification views, so you just need to do:
151
151
 
152
- AuthHelpers::Notifier.sender = %("José Valim" <jose.valim@gmail.com>)
152
+ AuthHelpers::Notifier.sender = %("José Valim" <jose.valim@gmail.com>)
153
153
  AuthHelpers::Notifier.template_root = "#{RAILS_ROOT}/app/views"
154
154
 
155
155
  Then make a copy of the plugin views folder to your app/views and start to work
@@ -165,11 +166,11 @@ Example app
165
166
  -----------
166
167
 
167
168
  http://github.com/josevalim/starter
168
-
169
- Bugs and Feedback
170
- -----------------
171
-
172
- If you discover any bugs, please send an e-mail to jose.valim@gmail.com
173
-
174
- Copyright (c) 2009 José Valim
175
- http://josevalim.blogspot.com/
169
+
170
+ Bugs and Feedback
171
+ -----------------
172
+
173
+ If you discover any bugs, please send an e-mail to jose.valim@gmail.com
174
+
175
+ Copyright (c) 2009 José Valim
176
+ http://josevalim.blogspot.com/
@@ -32,6 +32,12 @@ module AuthHelpers
32
32
  self.save(false)
33
33
  end
34
34
 
35
+ # Returns a hash to be store in session
36
+ #
37
+ def remember_me_cookie_hash
38
+ { :value => self.token, :expires => self.token_expires_at }
39
+ end
40
+
35
41
  # Change if you want to set another token_expiration_interval or add
36
42
  # custom logic (admin has one day token, clients have 2 weeks).
37
43
  #
@@ -17,6 +17,12 @@ module AuthHelpers
17
17
  @rememberable.token_expires_at.should_not be_nil
18
18
  end
19
19
 
20
+ it 'should return a remember_me cookie hash' do
21
+ @rememberable.remember_me!
22
+ @rememberable.remember_me_cookie_hash[:value].should == @rememberable.token
23
+ @rememberable.remember_me_cookie_hash[:expires].should == @rememberable.token_expires_at
24
+ end
25
+
20
26
  it 'should forget the remember me token' do
21
27
  @rememberable.remember_me!
22
28
  @rememberable.forget_me!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josevalim-auth_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jos\xC3\xA9 Valim"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-23 00:00:00 -07:00
12
+ date: 2009-04-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency