Commit a6ab9d6fc8661778329c37130a1085e7cdae4335
Exists in
master
and in
29 other branches
Merge branch 'stable'
Showing
2 changed files
with
8 additions
and
0 deletions
Show diff stats
app/models/user.rb
@@ -292,6 +292,7 @@ class User < ActiveRecord::Base | @@ -292,6 +292,7 @@ class User < ActiveRecord::Base | ||
292 | end | 292 | end |
293 | 293 | ||
294 | def deliver_activation_code | 294 | def deliver_activation_code |
295 | + return if person.is_template? | ||
295 | User::Mailer.deliver_activation_code(self) unless self.activation_code.blank? | 296 | User::Mailer.deliver_activation_code(self) unless self.activation_code.blank? |
296 | end | 297 | end |
297 | 298 |
test/unit/user_test.rb
@@ -430,6 +430,13 @@ class UserTest < ActiveSupport::TestCase | @@ -430,6 +430,13 @@ class UserTest < ActiveSupport::TestCase | ||
430 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s | 430 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s |
431 | end | 431 | end |
432 | 432 | ||
433 | + should 'not try to deliver email to template users' do | ||
434 | + Person.any_instance.stubs(:is_template?).returns(true) | ||
435 | + assert_no_difference ActionMailer::Base.deliveries, :size do | ||
436 | + new_user | ||
437 | + end | ||
438 | + end | ||
439 | + | ||
433 | should 'not mass assign activated at' do | 440 | should 'not mass assign activated at' do |
434 | user = User.new :activated_at => 5.days.ago | 441 | user = User.new :activated_at => 5.days.ago |
435 | assert_nil user.activated_at | 442 | assert_nil user.activated_at |