thoughtbot-clearance 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.textile +4 -0
- data/README.textile +17 -10
- data/Rakefile +1 -1
- data/generators/clearance/templates/README +0 -9
- data/generators/clearance/templates/app/views/sessions/new.html.erb +1 -1
- data/generators/clearance/templates/app/views/users/new.html.erb +1 -1
- data/lib/clearance.rb +0 -1
- data/shoulda_macros/clearance.rb +13 -0
- metadata +2 -3
- data/lib/clearance/test/test_helper.rb +0 -20
data/CHANGELOG.textile
CHANGED
data/README.textile
CHANGED
@@ -6,7 +6,7 @@ Rails authentication for developers who write tests.
|
|
6
6
|
|
7
7
|
h2. Integration with Suspenders
|
8
8
|
|
9
|
-
Clearance is based on the same conventions and tools as "Suspenders":http://github.com/thoughtbot/suspenders
|
9
|
+
Clearance is based on the same conventions and tools as "Suspenders":http://github.com/thoughtbot/suspenders If you use it, you already have some configuration mentioned below.
|
10
10
|
|
11
11
|
h2. Gem installation (Rails 2.1+)
|
12
12
|
|
@@ -15,7 +15,7 @@ In config/environment.rb:
|
|
15
15
|
config.gem "thoughtbot-clearance",
|
16
16
|
:lib => 'clearance',
|
17
17
|
:source => 'http://gems.github.com',
|
18
|
-
:version => '>= 0.4.
|
18
|
+
:version => '>= 0.4.7'
|
19
19
|
|
20
20
|
In config/environments/test.rb:
|
21
21
|
|
@@ -97,13 +97,7 @@ In config/environment.rb:
|
|
97
97
|
|
98
98
|
h2. Tests
|
99
99
|
|
100
|
-
The tests use "Shoulda":http://thoughtbot.com/projects/shoulda >= 2.9.1 and "Factory Girl":http://thoughtbot.com/projects/factory_girl >= 1.1.5.
|
101
|
-
|
102
|
-
class Test::Unit::TestCase
|
103
|
-
self.use_transactional_fixtures = true
|
104
|
-
self.use_instantiated_fixtures = false
|
105
|
-
include Clearance::Test::TestHelper
|
106
|
-
end
|
100
|
+
The tests use "Shoulda":http://thoughtbot.com/projects/shoulda >= 2.9.1 and "Factory Girl":http://thoughtbot.com/projects/factory_girl >= 1.1.5.
|
107
101
|
|
108
102
|
The generator will create a user factory in test/factories/clearance.rb unless
|
109
103
|
you have it defined somewhere else.
|
@@ -114,7 +108,7 @@ Rails authentication with Clearance uses the standard approach thoughtbot and ou
|
|
114
108
|
|
115
109
|
Users sign up (UsersController) using an email address and a password (User model). They get an email (ClearanceMailer) with a confirmation link to confirm their registration (ConfirmationController).
|
116
110
|
|
117
|
-
|
111
|
+
Signed up and email confirmed users can sign in and out (SessionsController). If they forget their password, they request an email (ClearanceMailer) containing a link to change it (PasswordsController).
|
118
112
|
|
119
113
|
h2. Usage: actions which require an authenticated user
|
120
114
|
|
@@ -198,6 +192,19 @@ Clearance has a method named sign_user_in that you can overwrite with that logic
|
|
198
192
|
end
|
199
193
|
end
|
200
194
|
|
195
|
+
h2. Write your own tests with Clearance's helpers
|
196
|
+
|
197
|
+
sign_in_as, sign_out, should_be_signed_in_as, should_not_be_signed_in, should_deny_access, signed_in_user_context, and more helpers are available in your test suite. Look in vendor/gems/clearance/shoulda_macros for the full list.
|
198
|
+
|
199
|
+
context "when signed in on GET to new" do
|
200
|
+
setup do
|
201
|
+
@user = Factory(:email_confirmed_user)
|
202
|
+
sign_in_as @user
|
203
|
+
get :new
|
204
|
+
end
|
205
|
+
should_be_signed_in_as { @user }
|
206
|
+
end
|
207
|
+
|
201
208
|
h2. Authors
|
202
209
|
|
203
210
|
* thoughtbot, inc.
|
data/Rakefile
CHANGED
@@ -50,7 +50,7 @@ task :default => ['test:all', 'test:features']
|
|
50
50
|
|
51
51
|
gem_spec = Gem::Specification.new do |gem_spec|
|
52
52
|
gem_spec.name = "clearance"
|
53
|
-
gem_spec.version = "0.4.
|
53
|
+
gem_spec.version = "0.4.7"
|
54
54
|
gem_spec.summary = "Rails authentication for developers who write tests."
|
55
55
|
gem_spec.email = "support@thoughtbot.com"
|
56
56
|
gem_spec.homepage = "http://github.com/thoughtbot/clearance"
|
@@ -41,14 +41,5 @@ In config/environment.rb:
|
|
41
41
|
*something* in your config/routes.rb:
|
42
42
|
|
43
43
|
map.root :controller => 'home'
|
44
|
-
|
45
|
-
4. To run tests you need to add the Clearance module to your
|
46
|
-
test/test_helper.rb:
|
47
|
-
|
48
|
-
class Test::Unit::TestCase
|
49
|
-
self.use_transactional_fixtures = true
|
50
|
-
self.use_instantiated_fixtures = false
|
51
|
-
include Clearance::Test::TestHelper
|
52
|
-
end
|
53
44
|
|
54
45
|
*******************************************************************************
|
data/lib/clearance.rb
CHANGED
@@ -9,6 +9,5 @@ require 'clearance/test/functional/confirmations_controller_test'
|
|
9
9
|
require 'clearance/test/functional/passwords_controller_test'
|
10
10
|
require 'clearance/test/functional/sessions_controller_test'
|
11
11
|
require 'clearance/test/functional/users_controller_test'
|
12
|
-
require 'clearance/test/test_helper'
|
13
12
|
require 'clearance/test/unit/clearance_mailer_test'
|
14
13
|
require 'clearance/test/unit/user_test'
|
data/shoulda_macros/clearance.rb
CHANGED
@@ -217,6 +217,19 @@ end
|
|
217
217
|
module Clearance
|
218
218
|
module Shoulda
|
219
219
|
module Helpers
|
220
|
+
def sign_in_as(user = nil)
|
221
|
+
unless user
|
222
|
+
user = Factory(:user)
|
223
|
+
user.confirm_email!
|
224
|
+
end
|
225
|
+
@request.session[:user_id] = user.id
|
226
|
+
return user
|
227
|
+
end
|
228
|
+
|
229
|
+
def sign_out
|
230
|
+
@request.session[:user_id] = nil
|
231
|
+
end
|
232
|
+
|
220
233
|
def blank_confirmation_options(attribute)
|
221
234
|
opts = { attribute => attribute.to_s }
|
222
235
|
opts.merge("#{attribute}_confirmation".to_sym => "")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2009-02-
|
18
|
+
date: 2009-02-11 21:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- lib/clearance/test/functional/passwords_controller_test.rb
|
108
108
|
- lib/clearance/test/functional/sessions_controller_test.rb
|
109
109
|
- lib/clearance/test/functional/users_controller_test.rb
|
110
|
-
- lib/clearance/test/test_helper.rb
|
111
110
|
- lib/clearance/test/unit
|
112
111
|
- lib/clearance/test/unit/clearance_mailer_test.rb
|
113
112
|
- lib/clearance/test/unit/user_test.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Clearance
|
2
|
-
module Test
|
3
|
-
module TestHelper
|
4
|
-
|
5
|
-
def sign_in_as(user = nil)
|
6
|
-
unless user
|
7
|
-
user = Factory(:user)
|
8
|
-
user.confirm_email!
|
9
|
-
end
|
10
|
-
@request.session[:user_id] = user.id
|
11
|
-
return user
|
12
|
-
end
|
13
|
-
|
14
|
-
def sign_out
|
15
|
-
@request.session[:user_id] = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|