diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2013-03-06 12:45:01 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2013-03-06 12:45:01 +1100 |
commit | 1e958d20f674dabde9e8fc6606edc704d4f93b66 (patch) | |
tree | 764f0228c7e4bc2bf541cb45a1e7603ce10b39e8 | |
parent | 79d63b1d8f2e5af49099563dfc027c6eab62a56d (diff) |
Fix bug in rails 2 cookiestore that only shows up when using integration tests
-rw-r--r-- | config/environment.rb | 1 | ||||
-rw-r--r-- | lib/cookie_store_with_line_break_fix.rb | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/config/environment.rb b/config/environment.rb index 7ffbe8701..929ed4dc1 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -155,6 +155,7 @@ require 'world_foi_websites.rb' require 'alaveteli_external_command.rb' require 'quiet_opener.rb' require 'mail_handler' +require "cookie_store_with_line_break_fix" if !Configuration.exception_notifications_from.blank? && !Configuration.exception_notifications_to.blank? ExceptionNotification::Notifier.sender_address = Configuration::exception_notifications_from diff --git a/lib/cookie_store_with_line_break_fix.rb b/lib/cookie_store_with_line_break_fix.rb new file mode 100644 index 000000000..dc623fbd0 --- /dev/null +++ b/lib/cookie_store_with_line_break_fix.rb @@ -0,0 +1,19 @@ +# See https://makandracards.com/makandra/9443-rails-2-s-cookiestore-produces-invalid-cookie-data-causing-tests-to-break + +# Should be able to remove this when we upgrade to Rails 3 + +module ActionController + module Session + CookieStore.class_eval do + + def call_with_line_break_fix(*args) + status, headers, body = call_without_line_break_fix(*args) + headers['Set-Cookie'].gsub! "\n\n", "\n" if headers['Set-Cookie'].present? + [ status, headers, body ] + end + + alias_method_chain :call, :line_break_fix + + end + end +end
\ No newline at end of file |