Merge and fix conflicts.
This commit is contained in:
commit
82ab50f774
|
@ -1,3 +1,7 @@
|
|||
* enhancements
|
||||
* Do not care about blank passwords on update
|
||||
* Mail views are scoped as well
|
||||
|
||||
== 0.7.2
|
||||
|
||||
* deprecation
|
||||
|
|
|
@ -26,7 +26,7 @@ class DeviseMailer < ::ActionMailer::Base
|
|||
|
||||
# Configure default email options
|
||||
def setup_mail(record, key)
|
||||
mapping = Devise.mappings.values.find { |m| m.to == record.class }
|
||||
mapping = Devise::Mapping.find_by_class(record.class)
|
||||
raise "Invalid devise resource #{record}" unless mapping
|
||||
|
||||
subject translate(mapping, key)
|
||||
|
@ -34,7 +34,19 @@ class DeviseMailer < ::ActionMailer::Base
|
|||
recipients record.email
|
||||
sent_on Time.now
|
||||
content_type 'text/html'
|
||||
body mapping.name => record, :resource => record
|
||||
body render_with_scope(key, mapping, mapping.name => record, :resource => record)
|
||||
end
|
||||
|
||||
def render_with_scope(key, mapping, assigns)
|
||||
if Devise.scoped_views
|
||||
begin
|
||||
render :file => "devise_mailer/#{mapping.as}/#{key}", :body => assigns
|
||||
rescue ActionView::MissingTemplate
|
||||
render :file => "devise_mailer/#{key}", :body => assigns
|
||||
end
|
||||
else
|
||||
render :file => "devise_mailer/#{key}", :body => assigns
|
||||
end
|
||||
end
|
||||
|
||||
# Setup subject namespaced by model. It means you're able to setup your
|
||||
|
|
|
@ -41,8 +41,9 @@ Devise.setup do |config|
|
|||
# Configure the e-mail address which will be shown in DeviseMailer.
|
||||
# config.mailer_sender = "foo.bar@yourapp.com"
|
||||
|
||||
# Configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
|
||||
# config.orm = :active_record
|
||||
# Load and configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
|
||||
# require 'devise/orm/mongo_mapper'
|
||||
# config.orm = :mongo_mapper
|
||||
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "sessions/users/new". It's turned off by default because it's slower if you
|
||||
|
|
|
@ -62,7 +62,7 @@ module Devise
|
|||
end
|
||||
end
|
||||
|
||||
# Verifies whether an incoming_password (ie from login) is the user password.
|
||||
# Verifies whether an incoming_password (ie from sign in) is the user password.
|
||||
def valid_password?(incoming_password)
|
||||
password_digest(incoming_password) == encrypted_password
|
||||
end
|
||||
|
@ -78,6 +78,14 @@ module Devise
|
|||
end
|
||||
end
|
||||
|
||||
# Overwrite update_attributes to not care for blank passwords.
|
||||
def update_attributes(attributes)
|
||||
[:password, :password_confirmation].each do |k|
|
||||
attributes.delete(k) unless attributes[k].present?
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Digests the password using the configured encryptor.
|
||||
|
|
|
@ -56,4 +56,10 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|||
confirmation_url_regexp = %r{<a href=\"http://#{host}/users/confirmation\?confirmation_token=#{user.confirmation_token}">}
|
||||
assert_match confirmation_url_regexp, mail.body
|
||||
end
|
||||
|
||||
test 'renders a scoped if scoped_views is set to true' do
|
||||
swap Devise, :scoped_views => true do
|
||||
assert_equal user.email, mail.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,13 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
|||
assert_equal salt, user.password_salt
|
||||
end
|
||||
|
||||
test 'should not care about empty password on update' do
|
||||
user = create_user
|
||||
user.update_attributes(:email => "jose.valim+updated@gmail.com", :password => "")
|
||||
user.reload
|
||||
assert_equal user.email, "jose.valim+updated@gmail.com"
|
||||
end
|
||||
|
||||
test 'should generate a base64 hash using SecureRandom for password salt' do
|
||||
ActiveSupport::SecureRandom.expects(:base64).with(15).returns('friendly_token')
|
||||
assert_equal 'friendly_token', new_user.password_salt
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= @resource.email %>
|
Loading…
Reference in New Issue