FIX: Use field name to name files in theme export. (#7009)
This commit is contained in:
parent
6f427589b2
commit
f68a7a16a4
|
@ -444,7 +444,7 @@ class Theme < ActiveRecord::Base
|
|||
|
||||
meta[:assets] = {}.tap do |hash|
|
||||
theme_fields.where(type_id: ThemeField.types[:theme_upload_var]).each do |field|
|
||||
hash[field.name] = "assets/#{field.upload.original_filename}"
|
||||
hash[field.name] = field.file_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ class ThemeField < ActiveRecord::Base
|
|||
canonical: -> (h) { "locales/#{h[:name]}.yml" }),
|
||||
ThemeFileMatcher.new(regex: /(?!)/, # Never match uploads by filename, they must be named in about.json
|
||||
names: nil, types: :theme_upload_var, targets: :common,
|
||||
canonical: -> (h) { "assets/#{h[:filename]}" }),
|
||||
canonical: -> (h) { "assets/#{h[:name]}#{File.extname(h[:filename])}" }),
|
||||
]
|
||||
|
||||
# For now just work for standard fields
|
||||
|
|
|
@ -9,8 +9,11 @@ describe ThemeStore::TgzExporter do
|
|||
theme.set_field(target: :mobile, name: :scss, value: 'body {background-color: $background_color; font-size: $font-size}')
|
||||
theme.set_field(target: :translations, name: :en, value: { en: { key: "value" } }.deep_stringify_keys.to_yaml)
|
||||
image = file_from_fixtures("logo.png")
|
||||
upload = UploadCreator.new(image, "logo.png").create_for(-1)
|
||||
upload = UploadCreator.new(image, "logo.png").create_for(Discourse::SYSTEM_USER_ID)
|
||||
theme.set_field(target: :common, name: :logo, upload_id: upload.id, type: :theme_upload_var)
|
||||
image = file_from_fixtures("logo.png")
|
||||
other_upload = UploadCreator.new(image, "logo.png").create_for(Discourse::SYSTEM_USER_ID)
|
||||
theme.set_field(target: :common, name: "other_logo", upload_id: upload.id, type: :theme_upload_var)
|
||||
theme.build_remote_theme(remote_url: "", about_url: "abouturl", license_url: "licenseurl",
|
||||
authors: "David Taylor", theme_version: "1.0", minimum_discourse_version: "1.0.0",
|
||||
maximum_discourse_version: "3.0.0.beta1")
|
||||
|
@ -63,7 +66,7 @@ describe ThemeStore::TgzExporter do
|
|||
expect(folders).to contain_exactly("assets", "common", "locales", "mobile")
|
||||
|
||||
files = Dir.glob("**/*").reject { |f| File.directory?(f) }
|
||||
expect(files).to contain_exactly("about.json", "assets/logo.png", "common/body_tag.html", "locales/en.yml", "mobile/mobile.scss", "settings.yml")
|
||||
expect(files).to contain_exactly("about.json", "assets/logo.png", "assets/other_logo.png", "common/body_tag.html", "locales/en.yml", "mobile/mobile.scss", "settings.yml")
|
||||
|
||||
expect(JSON.parse(File.read('about.json')).deep_symbolize_keys).to eq(
|
||||
"name": "Header Icons",
|
||||
|
@ -71,7 +74,8 @@ describe ThemeStore::TgzExporter do
|
|||
"license_url": "licenseurl",
|
||||
"component": false,
|
||||
"assets": {
|
||||
"logo": "assets/logo.png"
|
||||
"logo": "assets/logo.png",
|
||||
"other_logo": "assets/other_logo.png"
|
||||
},
|
||||
"authors": "David Taylor",
|
||||
"minimum_discourse_version": "1.0.0",
|
||||
|
|
Loading…
Reference in New Issue