A platform for community discussion. Free, open, simple.
FIX: Allow importing themes with subdirectories in extra_js
David Taylord095c2cee79f
diff --git a/lib/theme_store/git_importer.rb b/lib/theme_store/git_importer.rbindex 2eebf58370e..0fccf3886c4 100644--- a/lib/theme_store/git_importer.rb+++ b/lib/theme_store/git_importer.rb@@ -80,7 +80,7 @@ class ThemeStore::GitImporterenddef all_files- Dir.glob("**/*", base: @temp_folder).reject { |f| File.directory?(f) }+ Dir.glob("**/*", base: @temp_folder).reject { |f| File.directory?(File.join(@temp_folder, f)) }enddef [](value)diff --git a/lib/theme_store/zip_importer.rb b/lib/theme_store/zip_importer.rbindex 81ce6222aa0..deff98d3dfd 100644--- a/lib/theme_store/zip_importer.rb+++ b/lib/theme_store/zip_importer.rb@@ -51,7 +51,7 @@ class ThemeStore::ZipImporterenddef all_files- Dir.glob("**/**", base: @temp_folder).reject { |f| File.directory?(f) }+ Dir.glob("**/**", base: @temp_folder).reject { |f| File.directory?(File.join(@temp_folder, f)) }enddef [](value)diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rbindex e1e8af9fb46..0c467e962ed 100644--- a/spec/models/remote_theme_spec.rb+++ b/spec/models/remote_theme_spec.rb@@ -11,8 +11,8 @@ describe RemoteTheme do`cd #{repo_dir} && git init . ``cd #{repo_dir} && git config user.email '[email protected]'``cd #{repo_dir} && git config user.name 'The Cool One'`- `cd #{repo_dir} && mkdir desktop mobile common assets locales scss stylesheets`files.each do |name, data|+ FileUtils.mkdir_p(Pathname.new("#{repo_dir}/#{name}").dirname)File.write("#{repo_dir}/#{name}", data)`cd #{repo_dir} && git add #{name}`end@@ -52,6 +52,7 @@ describe RemoteTheme do"scss/oldpath.scss" => ".class2{color:blue}","stylesheets/file.scss" => ".class1{color:red}","stylesheets/empty.scss" => "",+ "javascripts/discourse/controllers/test.js.es6" => "console.log('test');","common/header.html" => "I AM HEADER","common/random.html" => "I AM SILLY","common/embedded.scss" => "EMBED",@@ -83,7 +84,7 @@ describe RemoteTheme doexpect(remote.theme_version).to eq("1.0")expect(remote.minimum_discourse_version).to eq("1.0.0")- expect(@theme.theme_fields.length).to eq(8)+ expect(@theme.theme_fields.length).to eq(9)mapped = Hash[*@theme.theme_fields.map { |f| ["#{f.target_id}-#{f.name}", f.value] }.flatten]expect(mapped["0-header"]).to eq("I AM HEADER")@@ -96,7 +97,7 @@ describe RemoteTheme doexpect(mapped["4-en"]).to eq("sometranslations")- expect(mapped.length).to eq(8)+ expect(mapped.length).to eq(9)expect(@theme.settings.length).to eq(1)expect(@theme.settings.first.value).to eq(true)diff --git a/spec/requests/admin/themes_controller_spec.rb b/spec/requests/admin/themes_controller_spec.rbindex 8e6f83a276d..17cdf9ea9fc 100644--- a/spec/requests/admin/themes_controller_spec.rb+++ b/spec/requests/admin/themes_controller_spec.rb@@ -44,6 +44,7 @@ describe Admin::ThemesController dotheme = Fabricate(:theme, name: "Awesome Theme")theme.set_field(target: :common, name: :scss, value: '.body{color: black;}')theme.set_field(target: :desktop, name: :after_header, value: '<b>test</b>')+ theme.set_field(target: :extra_js, name: "discourse/controller/blah", value: 'console.log("test");')theme.save!get "/admin/customize/themes/#{theme.id}/export"@@ -64,7 +65,7 @@ describe Admin::ThemesController dojson = ::JSON.parse(response.body)expect(json["theme"]["name"]).to eq("Awesome Theme")- expect(json["theme"]["theme_fields"].length).to eq(2)+ expect(json["theme"]["theme_fields"].length).to eq(3)endend