| 82 |
82 |
assert_equal [], theme.icons('icons')
|
| 83 |
83 |
end
|
| 84 |
|
def test_icons_should_be_cached
|
|
84 |
def test_icons_should_pick_up_changes_to_the_sprite
|
| 85 |
85 |
theme = Redmine::Themes::Theme.new('/tmp/test')
|
| 86 |
|
theme.stubs(:id).returns('test')
|
| 87 |
86 |
theme.stubs(:image_path).with('icons.svg').returns('themes/test/icons.svg')
|
| 88 |
87 |
asset = mock('asset')
|
| 89 |
|
asset.stubs(:content).returns('<symbol id="icon--edit"></symbol>')
|
| 90 |
88 |
asset.stubs(:digest).returns('123456')
|
|
89 |
asset.stubs(:content).returns('<symbol id="icon--edit"></symbol>')
|
| 91 |
90 |
Rails.application.assets.load_path.stubs(:find).with('themes/test/icons.svg').returns(asset)
|
| 92 |
|
# Use a memory store for this test since the test environment uses null_store
|
| 93 |
|
memory_store = ActiveSupport::Cache.lookup_store(:memory_store)
|
| 94 |
|
ActionController::Base.stubs(:cache_store).returns(memory_store)
|
| 95 |
|
|
| 96 |
|
# First call - cache miss
|
| 97 |
91 |
assert_equal ['edit'], theme.icons('icons')
|
| 98 |
|
# Second call - verify it's in the cache
|
| 99 |
|
cache_key = "theme-icons/test/icons/123456"
|
| 100 |
|
assert_equal ['edit'], memory_store.read(cache_key)
|
| 101 |
|
|
| 102 |
|
# If digest changes, it should miss cache
|
|
92 |
# A new digest must invalidate the memoized names
|
| 103 |
93 |
asset.stubs(:digest).returns('789')
|
| 104 |
94 |
asset.stubs(:content).returns('<symbol id="icon--new"></symbol>')
|
| 105 |
95 |
assert_equal ['new'], theme.icons('icons')
|