Permalink
Browse files

Update clearance and tests to Rails3-style syntax

  • Loading branch information...
1 parent c07789c commit 0fbf771b1e0edb53075ebcd48f3f96b7bb8402ce @joshuaclayton joshuaclayton committed Jun 10, 2010
@@ -13,7 +13,7 @@ def new
def create
if user = ::User.find_by_email(params[:password][:email])
user.forgot_password!
- ::ClearanceMailer.deliver_change_password user
+ ::ClearanceMailer.change_password(user).deliver
flash_notice_after_create
redirect_to(url_after_create)
else
@@ -21,7 +21,7 @@ def create
flash_success_after_create
redirect_back_or(url_after_create)
else
- ::ClearanceMailer.deliver_confirmation(@user)
+ ::ClearanceMailer.confirmation(@user).deliver
flash_notice_after_create
redirect_to(sign_in_url)
end
@@ -1,21 +1,21 @@
class ClearanceMailer < ActionMailer::Base
def change_password(user)
+ @user = user
from Clearance.configuration.mailer_sender
- recipients user.email
+ recipients @user.email
subject I18n.t(:change_password,
:scope => [:clearance, :models, :clearance_mailer],
:default => "Change your password")
- body :user => user
end
def confirmation(user)
+ @user = user
from Clearance.configuration.mailer_sender
- recipients user.email
+ recipients @user.email
subject I18n.t(:confirmation,
:scope => [:clearance, :models, :clearance_mailer],
:default => "Account confirmation")
- body :user => user
end
end
View
@@ -98,7 +98,7 @@ def remember_me!
# user.reset_remember_token!
def reset_remember_token!
generate_remember_token
- save(false)
+ save(:validate => false)
end
# Confirm my email.
@@ -108,7 +108,7 @@ def reset_remember_token!
def confirm_email!
self.email_confirmed = true
self.confirmation_token = nil
- save(false)
+ save(:validate => false)
end
# Mark my account as forgotten password.
@@ -117,7 +117,7 @@ def confirm_email!
# user.forgot_password!
def forgot_password!
generate_confirmation_token
- save(false)
+ save(:validate => false)
end
# Update my password.
@@ -185,7 +185,7 @@ def password_required?
end
def send_confirmation_email
- ClearanceMailer.deliver_confirmation self
+ ClearanceMailer.confirmation(self).deliver
end
end
@@ -253,7 +253,7 @@ def bad_confirmation_options(attribute)
def assert_confirmation_error(model, attribute, message = "confirmation error")
warn "[DEPRECATION] assert_confirmation_error: not meant to be public, no longer used internally"
- assert model.errors.on(attribute).include?("doesn't match confirmation"),
+ assert model.errors[attribute].include?("doesn't match confirmation"),
message
end
end
View
@@ -19,14 +19,14 @@ class UserTest < ActiveSupport::TestCase
user = Factory.build(:user, :password => 'blah',
:password_confirmation => 'boogidy')
assert ! user.save
- assert user.errors.on(:password)
+ assert user.errors[:password].any?
end
should "require non blank password confirmation on create" do
user = Factory.build(:user, :password => 'blah',
:password_confirmation => '')
assert ! user.save
- assert user.errors.on(:password)
+ assert user.errors[:password].any?
end
should "initialize salt" do

0 comments on commit 0fbf771

Please sign in to comment.