From 48bd2f5bc7cdcd3dff1e6de6febc044790f81bae Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 10 Jul 2022 20:29:25 +0200 Subject: [PATCH] Add missing file extension to export URL --- lib/exporter.rb | 6 +++--- spec/lib/exporter_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/exporter.rb b/lib/exporter.rb index 0a22a334..999b510d 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -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 diff --git a/spec/lib/exporter_spec.rb b/spec/lib/exporter_spec.rb index d15051c0..fb8bc0a2 100644 --- a/spec/lib/exporter_spec.rb +++ b/spec/lib/exporter_spec.rb @@ -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