Commit afc4a75499b6678a643e6b62f703f8e7e1eb0f0a

Authored by Robert Speicher
1 parent 82c3f626

Use Rails.root.join where appropriate

app/controllers/application_controller.rb
... ... @@ -105,7 +105,7 @@ class ApplicationController < ActionController::Base
105 105 end
106 106  
107 107 def render_404
108   - render file: File.join(Rails.root, "public", "404"), layout: false, status: "404"
  108 + render file: Rails.root.join("public", "404"), layout: false, status: "404"
109 109 end
110 110  
111 111 def require_non_empty_project
... ...
app/models/merge_request.rb
1   -require File.join(Rails.root, "app/models/commit")
  1 +require Rails.root.join("app/models/commit")
2 2  
3 3 class MergeRequest < ActiveRecord::Base
4 4 include IssueCommonality
... ...
app/roles/repository.rb
... ... @@ -155,7 +155,7 @@ module Repository
155 155  
156 156 # Build file path
157 157 file_name = self.code + "-" + commit.id.to_s + ".tar.gz"
158   - storage_path = File.join(Rails.root, "tmp", "repositories", self.code)
  158 + storage_path = Rails.root.join("tmp", "repositories", self.code)
159 159 file_path = File.join(storage_path, file_name)
160 160  
161 161 # Put files into a directory before archiving
... ...
config/initializers/1_settings.rb
... ... @@ -112,7 +112,7 @@ class Settings &lt; Settingslogic
112 112  
113 113 def backup_path
114 114 t = app['backup_path'] || "backups/"
115   - t = /^\//.match(t) ? t : File.join(Rails.root + t)
  115 + t = /^\//.match(t) ? t : Rails.root .join(t)
116 116 t
117 117 end
118 118  
... ...
db/fixtures/test/001_repo.rb
... ... @@ -3,13 +3,13 @@ require &#39;fileutils&#39;
3 3 print "Unpacking seed repository..."
4 4  
5 5 SEED_REPO = 'seed_project.tar.gz'
6   -REPO_PATH = File.join(Rails.root, 'tmp', 'repositories')
  6 +REPO_PATH = Rails.root.join('tmp', 'repositories')
7 7  
8 8 # Make whatever directories we need to make
9 9 FileUtils.mkdir_p(REPO_PATH)
10 10  
11 11 # Copy the archive to the repo path
12   -FileUtils.cp(File.join(Rails.root, 'spec', SEED_REPO), REPO_PATH)
  12 +FileUtils.cp(Rails.root.join('spec', SEED_REPO), REPO_PATH)
13 13  
14 14 # chdir to the repo path
15 15 FileUtils.cd(REPO_PATH) do
... ...
lib/gitlab/backend/gitolite_config.rb
... ... @@ -10,7 +10,7 @@ module Gitlab
10 10 attr_reader :config_tmp_dir, :ga_repo, :conf
11 11  
12 12 def config_tmp_dir
13   - @config_tmp_dir ||= File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}")
  13 + @config_tmp_dir ||= Rails.root.join('tmp',"gitlabhq-gitolite-#{Time.now.to_i}")
14 14 end
15 15  
16 16 def ga_repo
... ... @@ -19,7 +19,7 @@ module Gitlab
19 19  
20 20 def apply
21 21 Timeout::timeout(30) do
22   - File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f|
  22 + File.open(Rails.root.join('tmp', "gitlabhq-gitolite.lock"), "w+") do |f|
23 23 begin
24 24 # Set exclusive lock
25 25 # to prevent race condition
... ...
lib/gitlab/logger.rb
... ... @@ -15,7 +15,7 @@ module Gitlab
15 15 end
16 16  
17 17 def self.build
18   - new(File.join(Rails.root, "log", file_name))
  18 + new(Rails.root.join("log", file_name))
19 19 end
20 20 end
21 21 end
... ...
lib/gitlab/merge.rb
... ... @@ -28,7 +28,7 @@ module Gitlab
28 28  
29 29 def process
30 30 Grit::Git.with_timeout(30.seconds) do
31   - lock_file = File.join(Rails.root, "tmp", "merge_repo_#{project.path}.lock")
  31 + lock_file = Rails.root.join("tmp", "merge_repo_#{project.path}.lock")
32 32  
33 33 File.open(lock_file, "w+") do |f|
34 34 f.flock(File::LOCK_EX)
... ... @@ -36,7 +36,7 @@ module Gitlab
36 36 unless project.satellite.exists?
37 37 raise "You should run: rake gitlab:app:enable_automerge"
38 38 end
39   -
  39 +
40 40 project.satellite.clear
41 41  
42 42 Dir.chdir(project.satellite.path) do
... ...
lib/gitlab/satellite.rb
1 1 module Gitlab
2 2 class Satellite
3   -
  3 +
4 4 PARKING_BRANCH = "__parking_branch"
5 5  
6 6 attr_accessor :project
... ... @@ -14,7 +14,7 @@ module Gitlab
14 14 end
15 15  
16 16 def path
17   - File.join(Rails.root, "tmp", "repo_satellites", project.path)
  17 + Rails.root.join("tmp", "repo_satellites", project.path)
18 18 end
19 19  
20 20 def exists?
... ... @@ -36,6 +36,6 @@ module Gitlab
36 36 end
37 37 end
38 38 end
39   -
  39 +
40 40 end
41 41 end
... ...
spec/models/project_spec.rb
... ... @@ -125,7 +125,7 @@ describe Project do
125 125  
126 126 it "should return path to repo" do
127 127 project = Project.new(path: "somewhere")
128   - project.path_to_repo.should == File.join(Rails.root, "tmp", "repositories", "somewhere")
  128 + project.path_to_repo.should == Rails.root.join("tmp", "repositories", "somewhere")
129 129 end
130 130  
131 131 it "returns the full web URL for this repo" do
... ...
spec/support/stubbed_repository.rb
... ... @@ -5,11 +5,11 @@ module StubbedRepository
5 5 if new_record? || path == 'newproject'
6 6 # There are a couple Project specs and features that expect the Project's
7 7 # path to be in the returned path, so let's patronize them.
8   - File.join(Rails.root, 'tmp', 'repositories', path)
  8 + Rails.root.join('tmp', 'repositories', path)
9 9 else
10 10 # For everything else, just give it the path to one of our real seeded
11 11 # repos.
12   - File.join(Rails.root, 'tmp', 'repositories', 'gitlabhq')
  12 + Rails.root.join('tmp', 'repositories', 'gitlabhq')
13 13 end
14 14 end
15 15  
... ...