mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 13:41:31 +08:00
FIX: Allow importing themes with subdirectories in extra_js
The folder/file detection was broken by 9fea43e46a
. This commit fixes and adds relevant specs
This commit is contained in:
parent
0ba0aa00e7
commit
d095c2cee7
|
@ -80,7 +80,7 @@ class ThemeStore::GitImporter
|
|||
end
|
||||
|
||||
def 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)) }
|
||||
end
|
||||
|
||||
def [](value)
|
||||
|
|
|
@ -51,7 +51,7 @@ class ThemeStore::ZipImporter
|
|||
end
|
||||
|
||||
def 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)) }
|
||||
end
|
||||
|
||||
def [](value)
|
||||
|
|
|
@ -11,8 +11,8 @@ describe RemoteTheme do
|
|||
`cd #{repo_dir} && git init . `
|
||||
`cd #{repo_dir} && git config user.email 'someone@cool.com'`
|
||||
`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 do
|
|||
expect(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 do
|
|||
|
||||
expect(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)
|
||||
|
|
|
@ -44,6 +44,7 @@ describe Admin::ThemesController do
|
|||
theme = 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 do
|
|||
json = ::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)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user