redirect 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redirect/app.rb +3 -3
- data/lib/redirect/version.rb +1 -1
- data/spec/rack_spec.rb +12 -2
- metadata +1 -1
data/lib/redirect/app.rb
CHANGED
@@ -68,11 +68,11 @@ module Redirect
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def index_file
|
71
|
-
@index_file
|
71
|
+
@index_file = StaticFile.new(File.join(public_dir_path, 'index.html'))
|
72
72
|
end
|
73
73
|
|
74
74
|
def public_dir_path
|
75
|
-
@public_dir_path
|
75
|
+
@public_dir_path = File.expand_path(public_dir)
|
76
76
|
end
|
77
77
|
|
78
78
|
def not_found_response
|
@@ -112,7 +112,7 @@ module Redirect
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def static_file
|
115
|
-
@static_file
|
115
|
+
@static_file = StaticFile.new(public_dir_path + URI.unescape(request.path_info))
|
116
116
|
end
|
117
117
|
|
118
118
|
def static_response
|
data/lib/redirect/version.rb
CHANGED
data/spec/rack_spec.rb
CHANGED
@@ -98,7 +98,7 @@ describe "Redirect::App" do
|
|
98
98
|
context "basic redirect" do
|
99
99
|
let(:res) do
|
100
100
|
@app = Redirect::App.new(['/old/2008', '/index.html'])
|
101
|
-
get
|
101
|
+
get '/old/2008'
|
102
102
|
end
|
103
103
|
|
104
104
|
it "sets the content-type header to text/html" do
|
@@ -114,11 +114,21 @@ describe "Redirect::App" do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
it "can handle the redirected response" do
|
118
|
+
@app = Redirect::App.new(['/old/2008', '/index.html'])
|
119
|
+
@app.public_dir = 'spec/fixtures/public'
|
120
|
+
get '/old/2008'
|
121
|
+
status.should == 301
|
122
|
+
get '/index.html'
|
123
|
+
status.should == 200
|
124
|
+
body.should == File.read('spec/fixtures/public/index.html')
|
125
|
+
end
|
126
|
+
|
117
127
|
it "renders the redirect if available" do
|
118
128
|
@app = Redirect::App.new(['/old/2008', '/index.html'])
|
119
129
|
@app.public_dir = 'spec/fixtures/public'
|
120
130
|
get '/index.html'
|
121
|
-
|
131
|
+
status.should == 200
|
122
132
|
body.should == File.read('spec/fixtures/public/index.html')
|
123
133
|
end
|
124
134
|
|