thoughtbot-clearance 0.3.2 → 0.3.3
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 +10 -7
- data/Rakefile +6 -14
- data/generators/clearance/clearance_generator.rb +1 -1
- data/lib/clearance/app/controllers/application_controller.rb +1 -1
- data/lib/clearance/test/functional/confirmations_controller_test.rb +2 -2
- data/lib/clearance/test/functional/passwords_controller_test.rb +5 -5
- data/lib/clearance/version.rb +6 -6
- data/test/rails_root/test/test_helper.rb +2 -8
- metadata +11 -2
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/MIT-LICENSE +0 -20
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/README +0 -34
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/init.rb +0 -9
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/USAGE +0 -18
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/factory_generator.rb +0 -17
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/factory.rb +0 -5
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/fixtures.yml +0 -19
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/migration.rb +0 -16
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/model.rb +0 -2
- data/test/rails_root/vendor/plugins/factory_girl_on_rails/rails_generators/factory/templates/unit_test.rb +0 -7
data/README.textile
CHANGED
@@ -6,14 +6,14 @@ Simple, complete Ruby web app authentication.
|
|
6
6
|
|
7
7
|
h2. Gem installation (Rails 2.1+)
|
8
8
|
|
9
|
-
|
9
|
+
In config/environments/test.rb:
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
config.gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => "http://gems.github.com"
|
12
|
+
config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => "http://gems.github.com"
|
13
|
+
|
14
|
+
In config/environment.rb:
|
15
|
+
|
16
|
+
config.gem "thoughtbot-clearance", :lib => 'clearance', :source => 'http://gems.github.com/'
|
17
17
|
|
18
18
|
Then:
|
19
19
|
|
@@ -101,6 +101,9 @@ Your users table needs a few columns.
|
|
101
101
|
end
|
102
102
|
|
103
103
|
add_index :users, [:email, :crypted_password]
|
104
|
+
add_index :users, [:id, :salt]
|
105
|
+
add_index :users, :email
|
106
|
+
add_index :users, :remember_token
|
104
107
|
|
105
108
|
h2. Routes
|
106
109
|
|
data/Rakefile
CHANGED
@@ -1,35 +1,27 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'date'
|
4
|
-
|
4
|
+
|
5
5
|
test_files_pattern = 'test/rails_root/test/{unit,functional,other}/**/*_test.rb'
|
6
6
|
Rake::TestTask.new do |t|
|
7
7
|
t.libs << 'lib'
|
8
8
|
t.pattern = test_files_pattern
|
9
9
|
t.verbose = false
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
desc "Run the test suite"
|
13
13
|
task :default => :test
|
14
|
-
|
14
|
+
|
15
15
|
spec = Gem::Specification.new do |s|
|
16
16
|
s.name = "clearance"
|
17
17
|
s.summary = "Simple, complete Rails authentication."
|
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.", "
|
21
|
+
s.authors = ["thoughtbot, inc.", "Josh Nichols", "Mike Breen"]
|
22
22
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
23
23
|
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'rubygems'
|
27
|
-
require 'jeweler'
|
28
|
-
Jeweler.gemspec = spec
|
29
|
-
rescue LoadError
|
30
|
-
puts "Jeweler not available. sudo gem install technicalpickles-jeweler --source=http://gems.github.com"
|
31
|
-
end
|
32
|
-
|
24
|
+
|
33
25
|
namespace :generator do
|
34
26
|
task :templates do
|
35
27
|
app_files = FileList["test/rails_root/app/{controllers,models,views}/**/*"]
|
@@ -55,4 +47,4 @@ namespace :generator do
|
|
55
47
|
end
|
56
48
|
end
|
57
49
|
end
|
58
|
-
end
|
50
|
+
end
|
@@ -10,7 +10,7 @@ module Clearance
|
|
10
10
|
context "with the User with the given id's salt" do
|
11
11
|
setup do
|
12
12
|
@user = Factory :user
|
13
|
-
get :new, :user_id => @user.
|
13
|
+
get :new, :user_id => @user.to_param, :salt => @user.salt
|
14
14
|
end
|
15
15
|
|
16
16
|
should 'find the User record with the given id and salt' do
|
@@ -27,7 +27,7 @@ module Clearance
|
|
27
27
|
salt = ''
|
28
28
|
assert_not_equal salt, user.salt
|
29
29
|
|
30
|
-
get :new, :user_id => user.
|
30
|
+
get :new, :user_id => user.to_param, :salt => ''
|
31
31
|
end
|
32
32
|
|
33
33
|
should_respond_with :not_found
|
@@ -12,7 +12,7 @@ module Clearance
|
|
12
12
|
setup { @user = Factory :user }
|
13
13
|
|
14
14
|
context 'A GET to #new' do
|
15
|
-
setup { get :new, :user_id => @
|
15
|
+
setup { get :new, :user_id => @user.to_param }
|
16
16
|
|
17
17
|
should_respond_with :success
|
18
18
|
should_render_template 'new'
|
@@ -59,7 +59,7 @@ module Clearance
|
|
59
59
|
context "with an existing user's id and password" do
|
60
60
|
setup do
|
61
61
|
get :edit,
|
62
|
-
:user_id => @user.
|
62
|
+
:user_id => @user.to_param,
|
63
63
|
:password => @user.crypted_password,
|
64
64
|
:email => @user.email
|
65
65
|
end
|
@@ -86,7 +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 :edit, :user_id => @user.
|
89
|
+
get :edit, :user_id => @user.to_param, :password => ''
|
90
90
|
end
|
91
91
|
|
92
92
|
should_respond_with :not_found
|
@@ -100,7 +100,7 @@ module Clearance
|
|
100
100
|
context 'A PUT to #update' do
|
101
101
|
context "with an existing user's id but not password" do
|
102
102
|
setup do
|
103
|
-
put :update, :user_id => @user.
|
103
|
+
put :update, :user_id => @user.to_param, :password => ''
|
104
104
|
end
|
105
105
|
|
106
106
|
should "not update the user's password" do
|
@@ -154,7 +154,7 @@ module Clearance
|
|
154
154
|
@encrypted_new_password = Digest::SHA1.hexdigest encryption_format
|
155
155
|
|
156
156
|
put(:update,
|
157
|
-
:user_id => @user.
|
157
|
+
:user_id => @user.to_param,
|
158
158
|
:password => @user.crypted_password,
|
159
159
|
:user => {
|
160
160
|
:password => new_password,
|
data/lib/clearance/version.rb
CHANGED
@@ -7,21 +7,15 @@ ActiveRecord::Migration.verbose = false
|
|
7
7
|
ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
|
8
8
|
|
9
9
|
gem 'mocha'
|
10
|
-
gem 'thoughtbot-quietbacktrace'
|
11
10
|
gem 'thoughtbot-factory_girl' # from github
|
12
11
|
|
13
12
|
require 'mocha'
|
14
|
-
require 'quietbacktrace'
|
15
13
|
require 'factory_girl'
|
14
|
+
require File.expand_path(File.dirname(__FILE__)) + '/factories'
|
16
15
|
|
17
16
|
class Test::Unit::TestCase
|
18
|
-
|
19
17
|
self.use_transactional_fixtures = true
|
20
18
|
self.use_instantiated_fixtures = false
|
21
|
-
|
22
|
-
self.backtrace_silencers << :rails_vendor
|
23
|
-
self.backtrace_filters << :rails_root
|
24
|
-
|
19
|
+
|
25
20
|
include Clearance::Test::TestHelper
|
26
|
-
|
27
21
|
end
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2008-10-
|
17
|
+
date: 2008-10-16 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -142,8 +142,10 @@ files:
|
|
142
142
|
- test/rails_root/config/routes.rb
|
143
143
|
- test/rails_root/db
|
144
144
|
- test/rails_root/db/bootstrap
|
145
|
+
- test/rails_root/db/development.sqlite3
|
145
146
|
- test/rails_root/db/migrate
|
146
147
|
- test/rails_root/db/migrate/001_create_users.rb
|
148
|
+
- test/rails_root/db/schema.rb
|
147
149
|
- test/rails_root/db/test.sqlite3
|
148
150
|
- test/rails_root/doc
|
149
151
|
- test/rails_root/doc/README_FOR_APP
|
@@ -198,6 +200,8 @@ files:
|
|
198
200
|
- test/rails_root/script/server
|
199
201
|
- test/rails_root/test
|
200
202
|
- test/rails_root/test/factories.rb
|
203
|
+
- test/rails_root/test/fixtures
|
204
|
+
- test/rails_root/test/fixtures/mailer
|
201
205
|
- test/rails_root/test/functional
|
202
206
|
- test/rails_root/test/functional/confirmations_controller_test.rb
|
203
207
|
- test/rails_root/test/functional/passwords_controller_test.rb
|
@@ -211,6 +215,11 @@ files:
|
|
211
215
|
- test/rails_root/test/unit
|
212
216
|
- test/rails_root/test/unit/user_mailer_test.rb
|
213
217
|
- test/rails_root/test/unit/user_test.rb
|
218
|
+
- test/rails_root/tmp
|
219
|
+
- test/rails_root/tmp/cache
|
220
|
+
- test/rails_root/tmp/pids
|
221
|
+
- test/rails_root/tmp/sessions
|
222
|
+
- test/rails_root/tmp/sockets
|
214
223
|
- test/rails_root/vendor
|
215
224
|
- test/rails_root/vendor/gems
|
216
225
|
- test/rails_root/vendor/gems/mocha-0.9.1
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 [name of plugin creator]
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,34 +0,0 @@
|
|
1
|
-
factory_girl_on_rails
|
2
|
-
=====================
|
3
|
-
|
4
|
-
factory_girl_on_rails provides some minor creature comforts for using factory_girl on a Rails project:
|
5
|
-
|
6
|
-
* Automatically load factories in RAILS_ROOT/test/factories
|
7
|
-
* A generator for putting new factories in RAILS_ROOT/test/factories
|
8
|
-
|
9
|
-
|
10
|
-
Installing
|
11
|
-
==========
|
12
|
-
|
13
|
-
script/plugin install git://github.com/technicalpickles/factory_girl_on_rails.git
|
14
|
-
|
15
|
-
Example
|
16
|
-
=======
|
17
|
-
|
18
|
-
After installing this plugin, you just start using factories in RAILS_ROOT/test/factories.
|
19
|
-
|
20
|
-
As a convenience, a factory generator is provided:
|
21
|
-
|
22
|
-
`./script/generate factory account`
|
23
|
-
|
24
|
-
creates an Account factory: test/factories/account_factory.rb
|
25
|
-
|
26
|
-
`./script/generate factory post title:string body:text published:boolean`
|
27
|
-
|
28
|
-
creates a Post factory with a string title, text body, and published flag.
|
29
|
-
|
30
|
-
|
31
|
-
Copyright
|
32
|
-
=========
|
33
|
-
|
34
|
-
Copyright (c) 2008 Josh Nichols, released under the MIT license
|
@@ -1,18 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
Stubs out a new factory. Pass the factory name name, under_scored,
|
3
|
-
and an optional list of attribute pairs as arguments.
|
4
|
-
|
5
|
-
Attribute pairs are column_name:sql_type arguments specifying the
|
6
|
-
model's attributes. Timestamps are added by default, so you don't have to
|
7
|
-
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
8
|
-
|
9
|
-
This generates a file in test/factories.
|
10
|
-
|
11
|
-
Examples:
|
12
|
-
`./script/generate factory account`
|
13
|
-
|
14
|
-
creates an Account factory: test/factories/account_factory.rb
|
15
|
-
|
16
|
-
`./script/generate factory post title:string body:text published:boolean`
|
17
|
-
|
18
|
-
creates a Post factory with a string title, text body, and published flag.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class FactoryGenerator < Rails::Generator::NamedBase
|
2
|
-
def manifest
|
3
|
-
record do |m|
|
4
|
-
m.directory File.join('test/factories', class_path)
|
5
|
-
m.template 'factory.rb', File.join('test/factories', class_path, "#{file_name}_factory.rb")
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def factory_line(attribute)
|
10
|
-
"#{file_name}.#{attribute.name} '#{attribute.default}'"
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
def banner
|
15
|
-
"Usage: #{$0} #{spec.name} FactoryName [field:type, field:type]"
|
16
|
-
end
|
17
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
-
|
3
|
-
<% unless attributes.empty? -%>
|
4
|
-
one:
|
5
|
-
<% for attribute in attributes -%>
|
6
|
-
<%= attribute.name %>: <%= attribute.default %>
|
7
|
-
<% end -%>
|
8
|
-
|
9
|
-
two:
|
10
|
-
<% for attribute in attributes -%>
|
11
|
-
<%= attribute.name %>: <%= attribute.default %>
|
12
|
-
<% end -%>
|
13
|
-
<% else -%>
|
14
|
-
# one:
|
15
|
-
# column: value
|
16
|
-
#
|
17
|
-
# two:
|
18
|
-
# column: value
|
19
|
-
<% end -%>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :<%= table_name %> do |t|
|
4
|
-
<% for attribute in attributes -%>
|
5
|
-
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
-
<% end -%>
|
7
|
-
<% unless options[:skip_timestamps] %>
|
8
|
-
t.timestamps
|
9
|
-
<% end -%>
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.down
|
14
|
-
drop_table :<%= table_name %>
|
15
|
-
end
|
16
|
-
end
|