mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 22:34:02 +08:00
6e161d3e75
The most common thing that we do with fab! is: fab!(:thing) { Fabricate(:thing) } This commit adds a shorthand for this which is just simply: fab!(:thing) i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
48 lines
1.2 KiB
Ruby
48 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe ThemeSvgSprite do
|
|
fab!(:theme)
|
|
|
|
describe "#refetch!" do
|
|
context "when an upload exists" do
|
|
before do
|
|
fname = "custom-theme-icon-sprite.svg"
|
|
upload = UploadCreator.new(file_from_fixtures(fname), fname, for_theme: true).create_for(-1)
|
|
|
|
theme.set_field(
|
|
target: :common,
|
|
name: SvgSprite.theme_sprite_variable_name,
|
|
upload_id: upload.id,
|
|
type: :theme_upload_var,
|
|
)
|
|
|
|
theme.save!
|
|
end
|
|
|
|
it "fetches values from the store and puts them in the table" do
|
|
expect(ThemeSvgSprite.count).to eq(1)
|
|
|
|
sprite = ThemeSvgSprite.first
|
|
original_content = sprite.sprite
|
|
|
|
expect(original_content).not_to be_empty
|
|
|
|
sprite.update!(sprite: "INVALID")
|
|
|
|
ThemeSvgSprite.refetch!
|
|
|
|
sprite.reload
|
|
expect(sprite.sprite).to eq(original_content)
|
|
expect(ThemeSvgSprite.count).to eq(1)
|
|
end
|
|
end
|
|
|
|
# It needs to do this since the cache is based on values in this table
|
|
it "expires the svg sprite cache" do
|
|
SvgSprite.expects(:expire_cache)
|
|
|
|
ThemeSvgSprite.refetch!
|
|
end
|
|
end
|
|
end
|