Commit 43810b27c9fb16d9b411f99ea1fb80e4c337c199

Authored by AntonioTerceiro
1 parent 19443585

ActionItem78: testing != cancel instead of == finished



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@691 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/change_password.rb
@@ -45,9 +45,9 @@ class ChangePassword < Task @@ -45,9 +45,9 @@ class ChangePassword < Task
45 # validations for updating a ChangePassword task 45 # validations for updating a ChangePassword task
46 46
47 # only require the new password when actually changing it. 47 # only require the new password when actually changing it.
48 - validates_presence_of :password, :on => :update, :if => lambda { |change| change.status == Task::Status::FINISHED }  
49 - validates_presence_of :password_confirmation, :on => :update, :if => lambda { |change| change.status == Task::Status::FINISHED }  
50 - validates_confirmation_of :password, :if => lambda { |change| change.status == Task::Status::FINISHED } 48 + validates_presence_of :password, :on => :update, :if => lambda { |change| change.status != Task::Status::CANCELLED }
  49 + validates_presence_of :password_confirmation, :on => :update, :if => lambda { |change| change.status != Task::Status::CANCELLED }
  50 + validates_confirmation_of :password, :if => lambda { |change| change.status != Task::Status::CANCELLED }
51 51
52 def initialize(*args) 52 def initialize(*args)
53 super(*args) 53 super(*args)
test/unit/change_password_test.rb
@@ -87,6 +87,8 @@ class ChangePasswordTest < Test::Unit::TestCase @@ -87,6 +87,8 @@ class ChangePasswordTest < Test::Unit::TestCase
87 change.password = 'newpass' 87 change.password = 'newpass'
88 change.password_confirmation = 'newpass' 88 change.password_confirmation = 'newpass'
89 change.finish 89 change.finish
  90 +
  91 + assert User.find(person.user.id).authenticated?('newpass')
90 end 92 end
91 93
92 should 'not require password and password confirmation when cancelling' do 94 should 'not require password and password confirmation when cancelling' do
@@ -101,7 +103,6 @@ class ChangePasswordTest < Test::Unit::TestCase @@ -101,7 +103,6 @@ class ChangePasswordTest < Test::Unit::TestCase
101 assert_nothing_raised do 103 assert_nothing_raised do
102 change.cancel 104 change.cancel
103 end 105 end
104 -  
105 end 106 end
106 107
107 108