2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2015-05-05 01:50:13 -04:00
|
|
|
|
|
|
|
describe StylesheetCache do
|
|
|
|
|
|
|
|
describe "add" do
|
|
|
|
it "correctly cycles once MAX_TO_KEEP is hit" do
|
2017-05-03 11:31:16 -04:00
|
|
|
StylesheetCache.destroy_all
|
|
|
|
|
2015-05-05 01:50:13 -04:00
|
|
|
(StylesheetCache::MAX_TO_KEEP + 1).times do |i|
|
2017-04-12 10:52:52 -04:00
|
|
|
StylesheetCache.add("a", "d" + i.to_s, "c" + i.to_s, "map")
|
2015-05-05 01:50:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(StylesheetCache.count).to eq StylesheetCache::MAX_TO_KEEP
|
|
|
|
expect(StylesheetCache.order(:id).first.content).to eq "c1"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does nothing if digest is set and already exists" do
|
2017-08-16 10:59:38 -04:00
|
|
|
StylesheetCache.delete_all
|
2017-05-03 11:31:16 -04:00
|
|
|
|
2017-08-16 10:59:38 -04:00
|
|
|
expect(StylesheetCache.add("a", "b", "c", "map")).to be_present
|
|
|
|
expect(StylesheetCache.add("a", "b", "cc", "map")).to eq(false)
|
2015-05-05 01:50:13 -04:00
|
|
|
|
|
|
|
expect(StylesheetCache.count).to eq 1
|
|
|
|
expect(StylesheetCache.first.content).to eq "c"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|