spec/models/user_spec.rb in clearance-0.10.5 vs spec/models/user_spec.rb in clearance-0.11.0
- old
+ new
@@ -18,24 +18,10 @@
it { should_not allow_value("foo@example..com").for(:email) }
it { should_not allow_value("foo@.example.com").for(:email) }
it { should_not allow_value("foo").for(:email) }
it { should_not allow_value("example.com").for(:email) }
- it "should require password confirmation on create" do
- user = Factory.build(:user, :password => 'blah',
- :password_confirmation => 'boogidy')
- (user.save).should_not be
- user.errors[:password].should be_any
- end
-
- it "should require non blank password confirmation on create" do
- user = Factory.build(:user, :password => 'blah',
- :password_confirmation => '')
- (user.save).should_not be
- user.errors[:password].should be_any
- end
-
it "should initialize salt" do
Factory(:user).salt.should_not be_nil
end
describe "encrypt password" do
@@ -110,13 +96,13 @@
before do
@user = Factory(:user)
@old_encrypted_password = @user.encrypted_password
end
- describe "who updates password with confirmation" do
+ describe "who updates password" do
before do
- @user.update_password("new_password", "new_password")
+ @user.update_password("new_password")
end
it "should change encrypted password" do
@user.encrypted_password.should_not == @old_encrypted_password
end
@@ -124,16 +110,12 @@
end
it "should not generate the same remember token for users with the same password at the same time" do
Time.stubs(:now => Time.now)
password = 'secret'
- first_user = Factory(:user,
- :password => password,
- :password_confirmation => password)
- second_user = Factory(:user,
- :password => password,
- :password_confirmation => password)
+ first_user = Factory(:user, :password => password)
+ second_user = Factory(:user, :password => password)
second_user.remember_token.should_not == first_user.remember_token
end
# recovering forgotten password
@@ -153,13 +135,13 @@
it "should generate confirmation token" do
@user.confirmation_token.should_not be_nil
end
describe "and then updates password" do
- describe 'with confirmation' do
+ describe 'with password' do
before do
- @user.update_password("new_password", "new_password")
+ @user.update_password("new_password")
end
it "should change encrypted password" do
@user.encrypted_password.should_not == @old_encrypted_password
end
@@ -167,29 +149,15 @@
it "should clear confirmation token" do
@user.confirmation_token.should be_nil
end
end
- describe 'without confirmation' do
+ describe 'with blank password' do
before do
- @user.update_password("new_password", "")
+ @user.update_password("")
end
- it "should not change encrypted password" do
- @old_encrypted_password.should == @user.encrypted_password
- end
-
- it "should not clear confirmation token" do
- @user.confirmation_token.should_not be_nil
- end
- end
-
- describe 'with blank password and confirmation' do
- before do
- @user.update_password("", "")
- end
-
it "does not change encrypted password" do
@user.encrypted_password.should == @old_encrypted_password
end
it "does not clear confirmation token" do
@@ -249,10 +217,10 @@
@user.reload.encrypted_password.should be_nil
@user.reload.remember_token.should be_nil
end
it "should initialize salt, generate remember token, and save encrypted password on update_password" do
- @user.update_password('password', 'password')
+ @user.update_password('password')
@user.salt.should_not be_nil
@user.encrypted_password.should_not be_nil
@user.remember_token.should_not be_nil
end
end