Commit 58785a4e0aff14e6a8b179eb1a3e71b8874b020b
1 parent
44fe2549
Exists in
master
and in
27 other branches
rails3: fix email_activation
Showing
2 changed files
with
6 additions
and
5 deletions
Show diff stats
app/models/email_activation.rb
| 1 | 1 | class EmailActivation < Task |
| 2 | 2 | |
| 3 | 3 | validates_presence_of :requestor_id, :target_id |
| 4 | + validate :already_requested, :on => :create | |
| 4 | 5 | |
| 5 | 6 | alias :environment :target |
| 6 | 7 | alias :person :requestor |
| 7 | 8 | |
| 8 | - def validate_on_create | |
| 9 | + def already_requested | |
| 9 | 10 | if !self.requestor.nil? && self.requestor.user.email_activation_pending? |
| 10 | - self.errors.add_to_base(_('You have already requested activation of your mailbox.')) | |
| 11 | + self.errors.add(:base, _('You have already requested activation of your mailbox.')) | |
| 11 | 12 | end |
| 12 | 13 | end |
| 13 | 14 | ... | ... |
test/unit/email_activation_test.rb
| ... | ... | @@ -45,8 +45,8 @@ class EmailActivationTest < ActiveSupport::TestCase |
| 45 | 45 | task = EmailActivation.new(:requestor => ze.person, :target => Environment.default) |
| 46 | 46 | assert task.save! |
| 47 | 47 | |
| 48 | - anothertask = EmailActivation.new(:requestor => ze.person, :target => Environment.default) | |
| 49 | - assert !anothertask.save | |
| 48 | + another_task = EmailActivation.new(:requestor => ze.person, :target => Environment.default) | |
| 49 | + assert !another_task.save, "Should not be able to save another task" | |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | should 'deliver activation email notification' do |
| ... | ... | @@ -54,7 +54,7 @@ class EmailActivationTest < ActiveSupport::TestCase |
| 54 | 54 | |
| 55 | 55 | task = EmailActivation.new(:requestor => user.person, :target => Environment.default) |
| 56 | 56 | |
| 57 | - email = User::Mailer.deliver_activation_email_notify(user) | |
| 57 | + email = User::Mailer.activation_email_notify(user).deliver | |
| 58 | 58 | assert_match(/Welcome to #{task.requestor.environment.name} mail!/, email.subject) |
| 59 | 59 | end |
| 60 | 60 | ... | ... |