Sha256: a9ab73fc4b1495ab235a8a5141e331a3b55ca808b277ff1cc4de73ba39627984

Contents?: true

Size: 860 Bytes

Versions: 9

Compression:

Stored size: 860 Bytes

Contents

require 'rails_helper'

module MnoEnterprise
  RSpec.describe BaseResource, type: :model do
    describe '#cache_key' do
      context 'for existing record' do
        let(:user) { build(:user) }

        it 'uses updated_at' do
          expect(user.cache_key).to eq("mno_enterprise/users/#{user.id}-#{user.updated_at.utc.to_s(:nsec)}")
        end

        context 'when updated_at is nil' do
          before { user.updated_at = nil }
          it { expect(user.cache_key).to eq("mno_enterprise/users/#{user.id}") }
        end

        it 'uses the named timestamp' do
          expect(user.cache_key(:confirmed_at)).to eq("mno_enterprise/users/#{user.id}-#{user.confirmed_at.utc.to_s(:nsec)}")
        end
      end

      context 'for new record' do
        it { expect(User.new.cache_key).to eq('mno_enterprise/users/new') }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mno-enterprise-core-3.1.0 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-3.0.3 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-2.0.3 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-3.0.2 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-2.0.2 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-3.0.1 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-2.0.1 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-3.0.0 spec/models/mno_enterprise/base_resource_spec.rb
mno-enterprise-core-2.0.0 spec/models/mno_enterprise/base_resource_spec.rb