This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted for Rspec2. This won't work in RSpec 1. | |
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb | |
Rspec.configure do |config| | |
config.before(:each) do | |
Capybara.current_driver = :selenium if example.metadata[:js] | |
end | |
config.after(:each) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This custom version of the authenticate method allows the user to use login or email as unique keys. | |
# Please note that if using this method it's highly recommended that you make the email property, of the user model, a required one. | |
# Also consider adding a unique index to the email field. For that create a migration with: add_index :users, :email, :unique => true | |
# It's equally advisable to remove the nullable option from the email field. | |
def self.authenticate(login, password) | |
return nil if login.blank? || password.blank? | |
u = find :first, :conditions => ['(email = ? OR login = ?) and activated_at IS NOT NULL', login, login] # need to get the salt | |
u && u.authenticated?(password) ? u : nil | |
end |
NewerOlder