Sha256: 015a602eee1e8b7dee49b432239aacf9b3631aa83fa1d1ff3cb5721801d055b3

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

require 'spec_helper'

RSpec.describe SolidusJwt::Token, type: :model do
  subject { instance }

  let(:instance) { FactoryBot.create(:token) }

  it { is_expected.to be_valid }
  it { is_expected.to be_active }
  it { is_expected.not_to be_expired }

  context 'when token is nil' do
    let(:instance) { FactoryBot.build(:token, token: nil) }

    it 'generates one automatically' do
      expect(instance.token).to be_nil
      instance.save
      expect(instance.token).to be_present
    end
  end

  describe '.honor?' do
    subject { described_class.honor?(token) }

    let(:token) { instance.token }

    it { is_expected.to be true }

    context 'when token is inactive' do
      let(:instance) { FactoryBot.create(:token, :inactive) }

      it { is_expected.to be false }
    end

    context 'when token is expired' do
      let(:instance) { FactoryBot.create(:token, :expired) }

      it { is_expected.to be false }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_jwt-1.1.0 spec/models/solidus_jwt/token_spec.rb