From 68bd6809a7c433bbc4cd568810c0a0d24ec198ba Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Thu, 4 Aug 2011 22:50:06 +0300 Subject: [PATCH 1/2] Speed up tests by defaulting to 1 stretch in test env --- lib/generators/templates/devise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/templates/devise.rb b/lib/generators/templates/devise.rb index 46b4930c..35f20552 100644 --- a/lib/generators/templates/devise.rb +++ b/lib/generators/templates/devise.rb @@ -61,7 +61,7 @@ Devise.setup do |config| # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. - config.stretches = 10 + config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. # config.pepper = <%= SecureRandom.hex(64).inspect %> From 372dfecf0541fd2e6d8d9c4fc3339d10ae773213 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Thu, 4 Aug 2011 23:00:12 +0300 Subject: [PATCH 2/2] Added a comment about the stretch change --- lib/generators/templates/devise.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/generators/templates/devise.rb b/lib/generators/templates/devise.rb index 35f20552..e72f0624 100644 --- a/lib/generators/templates/devise.rb +++ b/lib/generators/templates/devise.rb @@ -61,6 +61,8 @@ Devise.setup do |config| # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. + # Limiting the stretches to just one in test env will increase the performance of + # your tests dramatically if you create a lot of users. config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password.