mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:24:05 -06:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
|
|
# encoding: utf-8
|
|
# frozen_string_literal: true
|
|
|
|
require 'theme_store/zip_importer'
|
|
|
|
RSpec.describe ThemeStore::ZipImporter do
|
|
before do
|
|
@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"
|
|
|
|
FileUtils.mkdir(@temp_folder)
|
|
Dir.chdir(@temp_folder) do
|
|
FileUtils.mkdir_p('test/a')
|
|
File.write("test/hello.txt", "hello world")
|
|
File.write("test/a/inner", "hello world inner")
|
|
end
|
|
end
|
|
|
|
after do
|
|
FileUtils.rm_rf @temp_folder
|
|
end
|
|
|
|
it "can import a simple zipped theme" do
|
|
Dir.chdir(@temp_folder) do
|
|
Compression::Zip.new.compress(@temp_folder, 'test')
|
|
FileUtils.rm_rf('test/')
|
|
end
|
|
|
|
file_name = 'test.zip'
|
|
importer = ThemeStore::ZipImporter.new("#{@temp_folder}/#{file_name}", file_name)
|
|
importer.import!
|
|
|
|
expect(importer["hello.txt"]).to eq("hello world")
|
|
expect(importer["a/inner"]).to eq("hello world inner")
|
|
|
|
importer.cleanup!
|
|
end
|
|
|
|
it "can import a simple gzipped theme" do
|
|
Dir.chdir(@temp_folder) do
|
|
`tar -cvzf test.tar.gz test/* 2> /dev/null`
|
|
end
|
|
|
|
file_name = 'test.tar.gz'
|
|
importer = ThemeStore::ZipImporter.new("#{@temp_folder}/#{file_name}", file_name)
|
|
importer.import!
|
|
|
|
expect(importer["hello.txt"]).to eq("hello world")
|
|
expect(importer["a/inner"]).to eq("hello world inner")
|
|
|
|
importer.cleanup!
|
|
end
|
|
end
|