Sha256: e52e1d10a9c33f7591b95e240e2a217480d5fed805de7408670641277e14b9b6
Contents?: true
Size: 1.87 KB
Versions: 5
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' describe InfoparkComponentCache::Guards::ValidUntil do let(:cache_component_stub) do double.tap do |cache_component_stub| cache_component_stub.stub(:cache_key) do |input| input.inspect end end end let(:minimum_valid_until) { 10.minutes.since.to_iso } let(:obj_stub) do double.tap do |obj_stub| obj_stub.stub(:scoped).and_return(obj_stub) obj_stub.stub(:where).and_return(obj_stub) obj_stub.stub(:minimum) do |field| minimum_valid_until if field == :valid_until end end end before { InfoparkComponentCache::CmsStateGuard.obj_root_class = obj_stub } subject { described_class.new(cache_component_stub) } context "with cache disabled" do disable_cache context "without a call to guard!" do it { is_expected.not_to be_consistent } end context "with a call to guard!" do before { subject.guard! } it { is_expected.not_to be_consistent } end end context "with cache enabled" do enable_cache before { Rails.cache.clear } context "without a call to guard!" do it { is_expected.not_to be_consistent } end context "with a call to guard!" do before { subject.guard! } it { is_expected.to be_consistent } end context "after minimum valid until changes to a present date" do before { subject.guard! } before { obj_stub.stub(:minimum).and_return(Time.now.to_iso) } it { is_expected.not_to be_consistent } end context "after minimum valid until changes to a past date" do before { subject.guard! } before { obj_stub.stub(:minimum).and_return(1.month.ago.to_iso) } it { is_expected.not_to be_consistent } end context "nil valid until" do let(:minimum_valid_until) { nil } before { subject.guard! } it { is_expected.to be_consistent } end end end
Version data entries
5 entries across 5 versions & 1 rubygems