Sha256: 10e3c2da217fe01cac9aa597da191b004056eb25b05a34752b971cde923c6967

Contents?: true

Size: 944 Bytes

Versions: 2

Compression:

Stored size: 944 Bytes

Contents

require 'spec_helper'

describe "change_password" do
  let(:user) do
    u = User.create!(:name => 'alice', :new_password => 'password')
    u.changing_password = true
    u
  end
  
  it "should change password" do
    user.update_attributes(:current_password => 'password', :new_password => 'banana')
    
    user.authenticate('banana').should be_true
  end
  
  it "should reject wrong current password" do
    user.assign_attributes(:current_password => 'lemon', :new_password => 'banana')
    
    user.should_not be_valid
    user.should have(1).error_on(:current_password)
    user.errors[:current_password].first.should == "is invalid"
  end
  
  it "should reject blank string as new password" do
    user.assign_attributes(:current_password => 'password', :new_password => '')
    
    user.should_not be_valid
    user.should have(1).error_on(:new_password)
    user.errors[:new_password].first.should == "can't be blank"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mini_auth-0.2.0 spec/mini_auth/change_password_spec.rb
mini_auth-0.2.0.beta spec/mini_auth/change_password_spec.rb