diff --git a/app/models/user.rb b/app/models/user.rb index b562238..d387dbb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -328,7 +328,7 @@ class User < ActiveRecord::Base end def deliver_activation_code - return if person.identifier =~ /person_template/ + return if person.is_template? User::Mailer.deliver_activation_code(self) unless self.activation_code.blank? end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 7731e2f..69fe1a5 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -447,6 +447,13 @@ class UserTest < ActiveSupport::TestCase assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s end + should 'not try to deliver email to template users' do + Person.any_instance.stubs(:is_template?).returns(true) + assert_no_difference ActionMailer::Base.deliveries, :size do + new_user + end + end + should 'not mass assign activated at' do user = User.new :activated_at => 5.days.ago assert_nil user.activated_at -- libgit2 0.21.2