From 854b2fd5c6699fe1e0d3ae3ad110c4f6aa752c6a Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 4 Dec 2022 22:40:36 +0100 Subject: [PATCH] Use `Rails.public_path.join` --- lib/exporter.rb | 2 +- spec/lib/exporter_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/exporter.rb b/lib/exporter.rb index 8ee43e8f..e08abd78 100644 --- a/lib/exporter.rb +++ b/lib/exporter.rb @@ -133,7 +133,7 @@ class Exporter end def publish - `tar czvf #{Rails.root.join "public", "export", "#{@export_filename}.tar.gz"} #{@export_dirname}` + `tar czvf #{Rails.public_path.join "export", "#{@export_filename}.tar.gz"} #{@export_dirname}` url = "#{APP_CONFIG['https'] ? 'https' : 'http'}://#{APP_CONFIG['hostname']}/export/#{@export_filename}.tar.gz" @user.export_processing = false @user.export_url = url diff --git a/spec/lib/exporter_spec.rb b/spec/lib/exporter_spec.rb index 65f0dccb..526b2978 100644 --- a/spec/lib/exporter_spec.rb +++ b/spec/lib/exporter_spec.rb @@ -296,11 +296,13 @@ RSpec.describe Exporter do describe "#publish" do let(:fake_rails_root) { Pathname(Dir.mktmpdir) } + let(:fake_rails_public_path) { fake_rails_root.join('public') } let(:name) { instance.instance_variable_get(:@export_filename) } before do FileUtils.mkdir_p("#{fake_rails_root}/public/export") allow(Rails).to receive(:root).and_return(fake_rails_root) + allow(Rails).to receive(:public_path).and_return(fake_rails_public_path) user.export_processing = true user.save!