public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Added password change model tests
Michael Hartl (author)
Thu Mar 20 19:59:29 -0700 2008
commit  91642098ab136e83c65a77151cfc2e9b0942790c
tree    c25924b0cc3ba783e58ccbcdc8b93bf4b48680a0
parent  f274ca1accfff806bfc1f385bf9dfc7a7b4530fb
...
186
187
188
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
191
192
...
186
187
188
 
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
0
@@ -186,7 +186,47 @@ describe Person do
0
       @person.remember_token.should_not be_nil
0
       @person.remember_token_expires_at.should_not be_nil
0
       @person.remember_token_expires_at.between?(before, after).should be_true
0
- end
0
+ end
0
+ end
0
+
0
+ describe "password edit" do
0
+
0
+ before(:each) do
0
+ @password = @person.unencrypted_password
0
+ @newpass = "foobar"
0
+ end
0
+
0
+ it "should change the password" do
0
+ @person.change_password?(:verify_password => @password,
0
+ :new_password => @newpass,
0
+ :password_confirmation => @newpass)
0
+ @person.unencrypted_password.should == @newpass
0
+ end
0
+
0
+ it "should not change password on failed verification" do
0
+ @person.change_password?(:verify_password => @password + "not!",
0
+ :new_password => @newpass,
0
+ :password_confirmation => @newpass)
0
+ @person.unencrypted_password.should_not == @newpass
0
+ @person.errors.on(:password).should =~ /incorrect/
0
+ end
0
+
0
+ it "should not change password on failed agreement" do
0
+ @person.change_password?(:verify_password => @password,
0
+ :new_password => @newpass + "not!",
0
+ :password_confirmation => @newpass)
0
+ @person.unencrypted_password.should_not == @newpass
0
+ @person.errors.on(:password).should =~ /match/
0
+ end
0
+
0
+ it "should not allow invalid new password" do
0
+ @newpass = ""
0
+ @person.change_password?(:verify_password => @password,
0
+ :new_password => @newpass,
0
+ :password_confirmation => @newpass)
0
+ @person.unencrypted_password.should_not == @newpass
0
+ @person.errors.on(:password).should_not be_nil
0
+ end
0
   end
0
 
0
 protected

Comments

    No one has commented yet.