diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 0d4a28c2..e0587fb0 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -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 diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index f1ffb014..dc1a1a88 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -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