thoughtbot-clearance 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +147 -60
- data/Rakefile +29 -21
- data/TODO.textile +1 -15
- data/generators/clearance/clearance_generator.rb +31 -9
- data/generators/clearance/lib/insert_commands.rb +103 -0
- data/generators/clearance/lib/rake_commands.rb +22 -0
- data/generators/clearance/templates/README +37 -0
- data/generators/clearance/templates/app/views/clearance_mailer/change_password.html.erb +3 -1
- data/generators/clearance/templates/app/views/passwords/edit.html.erb +4 -4
- data/generators/clearance/templates/db/migrate/create_users_with_clearance_columns.rb +21 -0
- data/generators/clearance/templates/db/migrate/update_users_with_clearance_columns.rb +41 -0
- data/generators/clearance/templates/test/{factories.rb → factories/clearance_user.rb} +1 -1
- data/lib/clearance.rb +3 -4
- data/lib/clearance/app/controllers/application_controller.rb +47 -61
- data/lib/clearance/app/controllers/confirmations_controller.rb +25 -33
- data/lib/clearance/app/controllers/passwords_controller.rb +41 -46
- data/lib/clearance/app/controllers/sessions_controller.rb +49 -56
- data/lib/clearance/app/controllers/users_controller.rb +21 -29
- data/lib/clearance/app/models/clearance_mailer.rb +15 -19
- data/lib/clearance/app/models/user.rb +53 -56
- data/lib/clearance/test/functional/confirmations_controller_test.rb +4 -35
- data/lib/clearance/test/functional/passwords_controller_test.rb +9 -5
- data/lib/clearance/test/functional/sessions_controller_test.rb +67 -17
- data/lib/clearance/test/functional/users_controller_test.rb +15 -7
- data/lib/clearance/test/test_helper.rb +10 -81
- data/lib/clearance/test/unit/clearance_mailer_test.rb +5 -5
- data/lib/clearance/test/unit/user_test.rb +42 -59
- data/rails/init.rb +1 -0
- data/shoulda_macros/clearance.rb +45 -0
- metadata +14 -6
- data/generators/clearance/templates/app/views/confirmations/new.html.erb +0 -6
- data/lib/clearance/version.rb +0 -7
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'clearance'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Clearance
|
2
|
+
module Shoulda
|
3
|
+
|
4
|
+
def should_deny_access_on(command, opts = {})
|
5
|
+
context "on #{command}" do
|
6
|
+
setup { eval command }
|
7
|
+
should_deny_access(opts)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def should_deny_access(opts = {})
|
12
|
+
if opts[:flash]
|
13
|
+
should_set_the_flash_to opts[:flash]
|
14
|
+
else
|
15
|
+
should_not_set_the_flash
|
16
|
+
end
|
17
|
+
|
18
|
+
should "respond with 401 Unauthorized and render login template" do
|
19
|
+
assert_response :unauthorized,
|
20
|
+
"access was expected to be denied (401 unauthorized)"
|
21
|
+
assert_template "sessions/new",
|
22
|
+
"template was expected to be login (sessions/new)"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def logged_in_user_context(&blk)
|
27
|
+
context "A logged in user" do
|
28
|
+
setup do
|
29
|
+
@user = Factory :clearance_user
|
30
|
+
login_as @user
|
31
|
+
end
|
32
|
+
merge_block(&blk)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def public_context(&blk)
|
37
|
+
context "The public" do
|
38
|
+
setup { logout }
|
39
|
+
merge_block(&blk)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Test::Unit::TestCase.extend(Clearance::Shoulda)
|
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.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-01-
|
14
|
+
date: 2009-01-16 21:00:00 -08:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -30,6 +30,9 @@ files:
|
|
30
30
|
- TODO.textile
|
31
31
|
- generators/clearance
|
32
32
|
- generators/clearance/clearance_generator.rb
|
33
|
+
- generators/clearance/lib
|
34
|
+
- generators/clearance/lib/insert_commands.rb
|
35
|
+
- generators/clearance/lib/rake_commands.rb
|
33
36
|
- generators/clearance/templates
|
34
37
|
- generators/clearance/templates/app
|
35
38
|
- generators/clearance/templates/app/controllers
|
@@ -45,8 +48,6 @@ files:
|
|
45
48
|
- generators/clearance/templates/app/views/clearance_mailer
|
46
49
|
- generators/clearance/templates/app/views/clearance_mailer/change_password.html.erb
|
47
50
|
- generators/clearance/templates/app/views/clearance_mailer/confirmation.html.erb
|
48
|
-
- generators/clearance/templates/app/views/confirmations
|
49
|
-
- generators/clearance/templates/app/views/confirmations/new.html.erb
|
50
51
|
- generators/clearance/templates/app/views/passwords
|
51
52
|
- generators/clearance/templates/app/views/passwords/edit.html.erb
|
52
53
|
- generators/clearance/templates/app/views/passwords/new.html.erb
|
@@ -56,8 +57,14 @@ files:
|
|
56
57
|
- generators/clearance/templates/app/views/users/_form.html.erb
|
57
58
|
- generators/clearance/templates/app/views/users/edit.html.erb
|
58
59
|
- generators/clearance/templates/app/views/users/new.html.erb
|
60
|
+
- generators/clearance/templates/db
|
61
|
+
- generators/clearance/templates/db/migrate
|
62
|
+
- generators/clearance/templates/db/migrate/create_users_with_clearance_columns.rb
|
63
|
+
- generators/clearance/templates/db/migrate/update_users_with_clearance_columns.rb
|
64
|
+
- generators/clearance/templates/README
|
59
65
|
- generators/clearance/templates/test
|
60
|
-
- generators/clearance/templates/test/factories
|
66
|
+
- generators/clearance/templates/test/factories
|
67
|
+
- generators/clearance/templates/test/factories/clearance_user.rb
|
61
68
|
- generators/clearance/templates/test/functional
|
62
69
|
- generators/clearance/templates/test/functional/confirmations_controller_test.rb
|
63
70
|
- generators/clearance/templates/test/functional/passwords_controller_test.rb
|
@@ -88,8 +95,9 @@ files:
|
|
88
95
|
- lib/clearance/test/unit
|
89
96
|
- lib/clearance/test/unit/clearance_mailer_test.rb
|
90
97
|
- lib/clearance/test/unit/user_test.rb
|
91
|
-
- lib/clearance/version.rb
|
92
98
|
- lib/clearance.rb
|
99
|
+
- shoulda_macros/clearance.rb
|
100
|
+
- rails/init.rb
|
93
101
|
has_rdoc: false
|
94
102
|
homepage: http://github.com/thoughtbot/clearance
|
95
103
|
post_install_message:
|