Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change middleware to support rails app in subfolders #103

Merged
merged 1 commit into from
Mar 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/better_errors/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def local_request?(env)

def better_errors_call(env)
case env["PATH_INFO"]
when %r{\A/__better_errors/(?<oid>-?\d+)/(?<method>\w+)\z}
when %r{\A.*/__better_errors/(?<oid>-?\d+)/(?<method>\w+)\z}
internal_call env, $~
when %r{\A/__better_errors/?\z}
when %r{\A.*/__better_errors/?\z}
show_error_page env
else
protected_app_call env
Expand Down
15 changes: 15 additions & 0 deletions spec/better_errors/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ module BetterErrors
app.call("PATH_INFO" => "/__better_errors/1/preform_awesomness")
end

it "should call the internal methods on any subfolder path" do
app.should_receive :internal_call
app.call("PATH_INFO" => "/any_sub/folder/path/__better_errors/1/preform_awesomness")
end

it "should show the error page" do
app.should_receive :show_error_page
app.call("PATH_INFO" => "/__better_errors/")
end

it "should show the error page on any subfolder path" do
app.should_receive :show_error_page
app.call("PATH_INFO" => "/any_sub/folder/path/__better_errors/")
end

it "should not show the error page to a non-local address" do
app.should_not_receive :better_errors_call
app.call("REMOTE_ADDR" => "1.2.3.4")
Expand All @@ -30,6 +40,11 @@ module BetterErrors
status, headers, body = app.call("PATH_INFO" => "/__better_errors")
body.join.should match /No errors have been recorded yet./
end

it "should show that no errors have been recorded on any subfolder path" do
status, headers, body = app.call("PATH_INFO" => "/any_sub/folder/path/__better_errors")
body.join.should match /No errors have been recorded yet./
end
end

context "when handling an error" do
Expand Down