Correct the Rails.root call

This commit is contained in:
Eric Schultz 2018-06-07 15:50:09 -05:00
parent 42376af35e
commit 28f5ae838a
2 changed files with 3 additions and 3 deletions

View file

@ -9,7 +9,7 @@ class StaticController < ApplicationController
def ccs
ccs_method = !Settings.ccs ? 'local_tar_gz' : Settings.ccs.ccs_method
if (ccs_method == 'local_tar_gz')
temp_file = "#{$RAILS_ROOT}/tmp/#{Time.current.to_i}.tar.gz"
temp_file = "#{Rails.root}/tmp/#{Time.current.to_i}.tar.gz"
result = Kernel.system("git archive --format=tar.gz -o #{temp_file} HEAD")
if result
send_file(temp_file, :type => "application/gzip")
@ -17,7 +17,7 @@ class StaticController < ApplicationController
render :nothing => true, :status => 500
end
elsif (ccs_method == 'github')
git_hash = File.read("#{$RAILS_ROOT}/CCS_HASH")
git_hash = File.read("#{Rails.root}/CCS_HASH")
redirect_to "https://github.com/#{Settings.ccs.options.account}/#{Settings.ccs.options.repo}/tree/#{git_hash}"
end

View file

@ -38,7 +38,7 @@ RSpec.describe StaticController, :type => :controller do
}
}
})
expect(File).to receive(:read).with("#{$RAILS_ROOT}/CCS_HASH").and_return("hash\n")
expect(File).to receive(:read).with("#{Rails.root}/CCS_HASH").and_return("hash\n")
get('ccs')
expect(response).to redirect_to "https://github.com/account/repo/tree/hash"
end