Commit 19443585b782861bec54dc230ef0cdc7982557e8
1 parent
b05c01e9
Exists in
master
and in
29 other branches
ActionItem78: don't check for password and password confirmation when cancelling
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@690 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
20 additions
and
3 deletions
Show diff stats
app/models/change_password.rb
... | ... | @@ -45,9 +45,9 @@ class ChangePassword < Task |
45 | 45 | # validations for updating a ChangePassword task |
46 | 46 | |
47 | 47 | # only require the new password when actually changing it. |
48 | - validates_presence_of :password, :on => :update | |
49 | - validates_presence_of :password_confirmation, :on => :update | |
50 | - validates_confirmation_of :password | |
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 } | |
51 | 51 | |
52 | 52 | def initialize(*args) |
53 | 53 | super(*args) | ... | ... |
test/unit/change_password_test.rb
... | ... | @@ -62,6 +62,7 @@ class ChangePasswordTest < Test::Unit::TestCase |
62 | 62 | change.email = 'test@example.com' |
63 | 63 | change.save! |
64 | 64 | |
65 | + change.status = Task::Status::FINISHED | |
65 | 66 | change.password = 'right' |
66 | 67 | change.password_confirmation = 'wrong' |
67 | 68 | assert !change.valid? |
... | ... | @@ -88,4 +89,20 @@ class ChangePasswordTest < Test::Unit::TestCase |
88 | 89 | change.finish |
89 | 90 | end |
90 | 91 | |
92 | + should 'not require password and password confirmation when cancelling' do | |
93 | + User.destroy_all | |
94 | + person = User.create!(:login => 'testuser', :password => 'test', :password_confirmation => 'test', :email => 'test@example.com').person | |
95 | + | |
96 | + change = ChangePassword.new | |
97 | + change.login = 'testuser' | |
98 | + change.email = 'test@example.com' | |
99 | + change.save! | |
100 | + | |
101 | + assert_nothing_raised do | |
102 | + change.cancel | |
103 | + end | |
104 | + | |
105 | + end | |
106 | + | |
107 | + | |
91 | 108 | end | ... | ... |