Sha256: a586a505a047adf0974bacc8a3b6d2b74ab385c0fdfae13e022c48d7efa9c50e

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

# -*- encoding : utf-8 -*-

describe Card::Set::Right::Password do

  before :each do
    @user_card = Card::Auth[ 'joe@user.com' ]
  end

  describe '#update_attributes' do

    it 'should encrypt password' do
      @user_card.account.password_card.update_attributes! content: 'new password'
      expect(@user_card.account.password).not_to eq('new password')
      assert_equal @user_card.id, Card::Auth.authenticate('joe@user.com', 'new password')
    end

    it 'should validate password' do
      password_card = @user_card.account.password_card
      password_card.update_attributes content: '2b'
      expect(password_card.errors[:password]).not_to be_empty

    end

    context 'blank password' do
      it "shouldn't change the password" do
        acct = @user_card.account
        original_pw = acct.password
        expect(original_pw.size).to be > 10
        pw_card = acct.password_card
        pw_card.content = ''
        pw_card.save
        expect(original_pw).to eq(pw_card.refresh(force=true).content)
      end

      it "shouldn't break email editing" do
        @user_card.account.update_attributes! subcards: {'+*password'=>'', '+*email'=>'joe2@user.com'}
        expect(@user_card.account.email).to eq('joe2@user.com')
        expect(@user_card.account.password).not_to be_empty
      end
    end
  end



end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
card-1.16.12 mod/05_standard/spec/set/right/password_spec.rb
card-1.16.11 mod/05_standard/spec/set/right/password_spec.rb
card-1.16.10 mod/05_standard/spec/set/right/password_spec.rb
card-1.16.9 mod/05_standard/spec/set/right/password_spec.rb
card-1.16.8 mod/05_standard/spec/set/right/password_spec.rb
card-1.16.7 mod/05_standard/spec/set/right/password_spec.rb