UX: Do not prepend discourse to theme filename if it's already there

This commit is contained in:
David Taylor 2019-01-28 11:29:29 +00:00
parent aca0b32fda
commit 99e0820c0b
2 changed files with 10 additions and 1 deletions

View File

@ -5,7 +5,8 @@ class ThemeStore::TgzExporter
def initialize(theme)
@theme = theme
@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"
@export_name = "discourse-#{@theme.name.downcase.gsub(/[^0-9a-z.\-]/, '-')}-theme"
@export_name = "#{@theme.name.downcase.gsub(/[^0-9a-z.\-]/, '-')}-theme"
@export_name = "discourse-#{@export_name}" unless @export_name.starts_with?("discourse")
end
def package_filename

View File

@ -109,4 +109,12 @@ describe ThemeStore::TgzExporter do
end.to raise_error(RuntimeError)
end
it "doesn't prepend 'discourse' to filename if already there" do
theme.update!(name: "Discourse Header Icons")
exporter = ThemeStore::TgzExporter.new(theme)
filename = exporter.package_filename
exporter.cleanup!
expect(filename).to end_with "/discourse-header-icons-theme.tar.gz"
end
end