Skip to content

Commit 9fc8e7b

Browse files
committed
Added nil guard in filter
1 parent 07ef409 commit 9fc8e7b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/firephp.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def firephp(obj = "", type = :log)
1515

1616
private
1717
def firephp_filter
18+
@firephp ||= []
1819
# Add headers only when browser has FirePHP-Plugin
1920
return if !(request.headers["HTTP_USER_AGENT"]=~/FirePHP\//)
2021
# Do not add headers in production mode

test/firephp_rails_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def b
1313
fb("hi")
1414
render :nothing => true
1515
end
16+
17+
def c
18+
render :nothing => true
19+
end
1620
end
1721

1822
class FirePHPControllerTest < ActionController::TestCase
@@ -44,4 +48,8 @@ class FirePHPControllerTest < ActionController::TestCase
4448
ENV["RAILS_ENV"] = "test"
4549
end
4650

51+
test "headers not sent when firephp not used" do
52+
get :c
53+
assert !@response.headers.include?(EXAMPLE_HEADER)
54+
end
4755
end

0 commit comments

Comments
 (0)