Sha256: d2c41871dc72c59ceb667df2c1e2ef5c2767d12392796272831690e84c61e1f6

Contents?: true

Size: 1.48 KB

Versions: 14

Compression:

Stored size: 1.48 KB

Contents

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

RSpec.describe Card::Set::Right::Password do
  let(:account)  { Card::Auth.find_account_by_email("joe@user.com") }
  let(:password_card) { account.password_card }
  let(:password) { account.password }

  specify "view: core" do
    expect(password_card.format.render_core).to have_tag :em, "encrypted"
  end

  def card_subject
    password_card
  end

  check_html_views_for_errors

  describe "#update" do
    it "encrypts password", aggregate_failures: true do
      password_card.update! content: "new password"
      expect(password).not_to eq("new password")
      authenticated = Card::Auth.authenticate "joe@user.com", "new password"
      expect(account).to eq authenticated
    end

    it "validates password" do
      password_card = account.password_card
      password_card.update content: "2b"
      expect(password_card.errors[:password]).not_to be_empty
    end

    context "blank password" do
      it "does not change the password", aggregate_failures: true do
        original_pw = account.password
        expect(original_pw.size).to be > 10
        password_card.update! content: ""
        expect(original_pw).to eq(password_card.refresh(_force = true).db_content)
      end

      it "does not break email editing", aggregate_failures: true do
        account.update! subcards: { "+*password" => "", "+*email" => "joe2@user.com" }
        expect(account.email).to eq("joe2@user.com")
        expect(account.password).not_to be_empty
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-1.100.0 mod/account/spec/set/right/password_spec.rb
card-1.99.6 mod/account/spec/set/right/password_spec.rb
card-1.99.5 mod/account/spec/set/right/password_spec.rb
card-1.99.4 mod/account/spec/set/right/password_spec.rb
card-1.99.3 mod/account/spec/set/right/password_spec.rb
card-1.99.2 mod/account/spec/set/right/password_spec.rb
card-1.99.1 mod/account/spec/set/right/password_spec.rb
card-1.99.0 mod/account/spec/set/right/password_spec.rb
card-1.98.3 mod/account/spec/set/right/password_spec.rb
card-1.98.2 mod/account/spec/set/right/password_spec.rb
card-1.98.1 mod/account/spec/set/right/password_spec.rb
card-1.98.0 mod/account/spec/set/right/password_spec.rb
card-1.97.0.1 mod/account/spec/set/right/password_spec.rb
card-1.97.0 mod/account/spec/set/right/password_spec.rb