File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ def public_uri
7676 end
7777
7878 def expand_path ( path )
79+ return nil if path . nil?
7980 if path . start_with? ( app_uri ) # gem_path = '/WEB-INF/gems'
8081 path = path . dup ; path [ 0 , app_uri . size ] = app_path ; path # '[app_path]/gems'
8182 path
@@ -90,7 +91,7 @@ def expand_path(path)
9091
9192 RailsWebInfLayout = WebInfLayout
9293
93- # # deprecated will be removed (with Merb support)
94+ # @ deprecated will be removed (with Merb support)
9495 class MerbWebInfLayout < WebInfLayout
9596
9697 def app_uri
@@ -120,7 +121,7 @@ def public_uri
120121 end
121122
122123 def real_path ( path )
123- expand_path ( super )
124+ path . nil? ? nil : expand_path ( super )
124125 end
125126
126127 def expand_path ( path )
Original file line number Diff line number Diff line change 6565 expect ( layout . gem_path ) . to eq "/var/local/app/gem"
6666 end
6767
68+ it "expands path app_uri relatively" do
69+ layout . instance_variable_set :@app_uri , "/WEB-INF/"
70+ layout . instance_variable_set :@app_path , "/home/deploy/current/WEB-INF/"
71+
72+ expect ( layout . expand_path ( "app/gem" ) ) . to eq "/home/deploy/current/WEB-INF/app/gem"
73+ end
74+
75+ it "expands paths starting with app path" do
76+ layout . instance_variable_set :@app_uri , "/WEB-INF"
77+ layout . instance_variable_set :@app_path , "/home/deploy/current/WEB-INF"
78+
79+ expect ( layout . expand_path ( "/WEB-INF/app/gem" ) ) . to eq "/home/deploy/current/WEB-INF/app/gem"
80+ end
81+
82+ it "expands nil path as nil" do
83+ layout . instance_variable_set :@app_uri , "/WEB-INF/"
84+
85+ expect ( layout . expand_path ( nil ) ) . to eq nil
86+ end
87+
6888end
6989
7090shared_examples "FileSystemLayout" do
114134 expect ( layout . public_path ) . to eq "/home/public/root"
115135 end
116136
137+ it "expands nil path as nil" do
138+ expect ( layout . expand_path ( nil ) ) . to eq nil
139+ end
140+
141+ it "handles nil real path as nil" do
142+ expect ( layout . real_path ( nil ) ) . to eq nil
143+ end
144+
117145end
118146
119147describe JRuby ::Rack ::FileSystemLayout do
You can’t perform that action at this time.
0 commit comments