Sha256: 1aabbb9100ca0e352e72880b897669b61e9ae614ae34e6fd83ab0eee2da5f656
Contents?: true
Size: 1.34 KB
Versions: 6
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe Unread::GarbageCollector do before :each do @reader = Reader.create! :name => 'David' @other_reader = Reader.create :name => 'Matz' @sti_reader = StiReader.create! wait @email1 = Email.create! wait @email2 = Email.create! end describe :run! do it "should delete all single read marks" do expect(@reader.read_marks.single.count).to eq 0 @email1.mark_as_read! :for => @reader expect(Email.unread_by(@reader)).to eq [@email2] expect(@reader.read_marks.single.count).to eq 1 Unread::GarbageCollector.new(Email).run! @reader.reload expect(@reader.read_marks.single.count).to eq 0 end it "should reset if all objects are read" do @email1.mark_as_read! :for => @reader @email2.mark_as_read! :for => @reader expect(@reader.read_marks.single.count).to eq 2 Unread::GarbageCollector.new(Email).run! expect(@reader.read_marks.single.count).to eq 0 end it "should not delete read marks from other readables" do other_read_mark = @reader.read_marks.create! do |rm| rm.readable_type = 'Foo' rm.readable_id = 42 rm.timestamp = 5.years.ago end Unread::GarbageCollector.new(Email).run! expect(ReadMark.exists?(other_read_mark.id)).to be_truthy end end end
Version data entries
6 entries across 6 versions & 1 rubygems