Add missing file extension to export URL

This commit is contained in:
Karina Kwiatek 2022-07-10 20:29:25 +02:00 committed by Karina Kwiatek
parent 428db25c71
commit 48bd2f5bc7
2 changed files with 5 additions and 5 deletions

View File

@ -11,7 +11,7 @@ class Exporter
@user = user
@obj = {}
@export_dirname = Dir.mktmpdir("rs-export-")
@export_filename = "#{File.basename(@export_dirname)}.tar.gz"
@export_filename = "#{File.basename(@export_dirname)}"
end
def export
@ -133,8 +133,8 @@ class Exporter
end
def publish
`tar czvf #{Rails.root.join "public", "export", @export_filename} -C /tmp/rs_export #{@export_dirname}`
url = "#{APP_CONFIG['https'] ? 'https' : 'http'}://#{APP_CONFIG['hostname']}/export/#{@export_filename}"
`tar czvf #{Rails.root.join "public", "export", "#{@export_filename}.tar.gz"} -C /tmp/rs_export #{@export_dirname}`
url = "#{APP_CONFIG['https'] ? 'https' : 'http'}://#{APP_CONFIG['hostname']}/export/#{@export_filename}.tar.gz"
@user.export_processing = false
@user.export_url = url
@user.export_created_at = Time.now.utc

View File

@ -313,8 +313,8 @@ RSpec.describe Exporter do
it "publishes an archive" do
Timecop.freeze do
expect { subject }.to change { user.export_processing }.from(true).to(false)
expect(File.exist?("#{fake_rails_root}/public/export/#{name}")).to eq(true)
expect(user.export_url).to eq("https://example.com/export/#{name}")
expect(File.exist?("#{fake_rails_root}/public/export/#{name}.tar.gz")).to eq(true)
expect(user.export_url).to eq("https://example.com/export/#{name}.tar.gz")
expect(user.export_created_at).to eq(Time.now.utc)
expect(user).to be_persisted
end