Use `Rails.public_path.join`
This commit is contained in:
parent
5b29c78496
commit
854b2fd5c6
|
@ -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
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Reference in New Issue