Commit afc4a754 authored by Robert Speicher's avatar Robert Speicher

Use Rails.root.join where appropriate

parent 82c3f626
...@@ -105,7 +105,7 @@ class ApplicationController < ActionController::Base ...@@ -105,7 +105,7 @@ class ApplicationController < ActionController::Base
end end
def render_404 def render_404
render file: File.join(Rails.root, "public", "404"), layout: false, status: "404" render file: Rails.root.join("public", "404"), layout: false, status: "404"
end end
def require_non_empty_project def require_non_empty_project
......
require File.join(Rails.root, "app/models/commit") require Rails.root.join("app/models/commit")
class MergeRequest < ActiveRecord::Base class MergeRequest < ActiveRecord::Base
include IssueCommonality include IssueCommonality
......
...@@ -155,7 +155,7 @@ module Repository ...@@ -155,7 +155,7 @@ module Repository
# Build file path # Build file path
file_name = self.code + "-" + commit.id.to_s + ".tar.gz" file_name = self.code + "-" + commit.id.to_s + ".tar.gz"
storage_path = File.join(Rails.root, "tmp", "repositories", self.code) storage_path = Rails.root.join("tmp", "repositories", self.code)
file_path = File.join(storage_path, file_name) file_path = File.join(storage_path, file_name)
# Put files into a directory before archiving # Put files into a directory before archiving
......
...@@ -112,7 +112,7 @@ class Settings < Settingslogic ...@@ -112,7 +112,7 @@ class Settings < Settingslogic
def backup_path def backup_path
t = app['backup_path'] || "backups/" t = app['backup_path'] || "backups/"
t = /^\//.match(t) ? t : File.join(Rails.root + t) t = /^\//.match(t) ? t : Rails.root .join(t)
t t
end end
......
...@@ -3,13 +3,13 @@ require 'fileutils' ...@@ -3,13 +3,13 @@ require 'fileutils'
print "Unpacking seed repository..." print "Unpacking seed repository..."
SEED_REPO = 'seed_project.tar.gz' SEED_REPO = 'seed_project.tar.gz'
REPO_PATH = File.join(Rails.root, 'tmp', 'repositories') REPO_PATH = Rails.root.join('tmp', 'repositories')
# Make whatever directories we need to make # Make whatever directories we need to make
FileUtils.mkdir_p(REPO_PATH) FileUtils.mkdir_p(REPO_PATH)
# Copy the archive to the repo path # Copy the archive to the repo path
FileUtils.cp(File.join(Rails.root, 'spec', SEED_REPO), REPO_PATH) FileUtils.cp(Rails.root.join('spec', SEED_REPO), REPO_PATH)
# chdir to the repo path # chdir to the repo path
FileUtils.cd(REPO_PATH) do FileUtils.cd(REPO_PATH) do
......
...@@ -10,7 +10,7 @@ module Gitlab ...@@ -10,7 +10,7 @@ module Gitlab
attr_reader :config_tmp_dir, :ga_repo, :conf attr_reader :config_tmp_dir, :ga_repo, :conf
def config_tmp_dir def config_tmp_dir
@config_tmp_dir ||= File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}") @config_tmp_dir ||= Rails.root.join('tmp',"gitlabhq-gitolite-#{Time.now.to_i}")
end end
def ga_repo def ga_repo
...@@ -19,7 +19,7 @@ module Gitlab ...@@ -19,7 +19,7 @@ module Gitlab
def apply def apply
Timeout::timeout(30) do Timeout::timeout(30) do
File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| File.open(Rails.root.join('tmp', "gitlabhq-gitolite.lock"), "w+") do |f|
begin begin
# Set exclusive lock # Set exclusive lock
# to prevent race condition # to prevent race condition
......
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
end end
def self.build def self.build
new(File.join(Rails.root, "log", file_name)) new(Rails.root.join("log", file_name))
end end
end end
end end
...@@ -28,7 +28,7 @@ module Gitlab ...@@ -28,7 +28,7 @@ module Gitlab
def process def process
Grit::Git.with_timeout(30.seconds) do Grit::Git.with_timeout(30.seconds) do
lock_file = File.join(Rails.root, "tmp", "merge_repo_#{project.path}.lock") lock_file = Rails.root.join("tmp", "merge_repo_#{project.path}.lock")
File.open(lock_file, "w+") do |f| File.open(lock_file, "w+") do |f|
f.flock(File::LOCK_EX) f.flock(File::LOCK_EX)
......
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
end end
def path def path
File.join(Rails.root, "tmp", "repo_satellites", project.path) Rails.root.join("tmp", "repo_satellites", project.path)
end end
def exists? def exists?
......
...@@ -125,7 +125,7 @@ describe Project do ...@@ -125,7 +125,7 @@ describe Project do
it "should return path to repo" do it "should return path to repo" do
project = Project.new(path: "somewhere") project = Project.new(path: "somewhere")
project.path_to_repo.should == File.join(Rails.root, "tmp", "repositories", "somewhere") project.path_to_repo.should == Rails.root.join("tmp", "repositories", "somewhere")
end end
it "returns the full web URL for this repo" do it "returns the full web URL for this repo" do
......
...@@ -5,11 +5,11 @@ module StubbedRepository ...@@ -5,11 +5,11 @@ module StubbedRepository
if new_record? || path == 'newproject' if new_record? || path == 'newproject'
# There are a couple Project specs and features that expect the Project's # There are a couple Project specs and features that expect the Project's
# path to be in the returned path, so let's patronize them. # path to be in the returned path, so let's patronize them.
File.join(Rails.root, 'tmp', 'repositories', path) Rails.root.join('tmp', 'repositories', path)
else else
# For everything else, just give it the path to one of our real seeded # For everything else, just give it the path to one of our real seeded
# repos. # repos.
File.join(Rails.root, 'tmp', 'repositories', 'gitlabhq') Rails.root.join('tmp', 'repositories', 'gitlabhq')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment