aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2015-12-01 14:37:20 -0500
committereileencodes <eileencodes@gmail.com>2015-12-06 15:32:47 -0500
commit8350925bec434168f56b4fae22b5298cb4a83c41 (patch)
tree660994ee5d8017b18f418105022fbcf0231176e9 /actionpack
parent492b134433653cbbea1b30c459d41054f0da5ad7 (diff)
downloadrails-8350925bec434168f56b4fae22b5298cb4a83c41.tar.gz
rails-8350925bec434168f56b4fae22b5298cb4a83c41.tar.bz2
rails-8350925bec434168f56b4fae22b5298cb4a83c41.zip
Stop violating law of demeter in response cookie_jar
This adds a new method to request and response so we don't need to violate the law of demeter. We are changing `Request` and `Response` so that they always have a `cookie_jar` This is a continuation on work to combine integration and controller test code bases in Rails.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb3
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb6
3 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 482917d71b..29cf821090 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -63,6 +63,9 @@ module ActionDispatch
@ip = nil
end
+ def commit_cookie_jar! # :nodoc:
+ end
+
def check_path_parameters!
# If any of the path parameters has an invalid encoding then
# raise since it's likely to trigger errors further on.
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index a4852d7031..9a10dc73d9 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -413,7 +413,7 @@ module ActionDispatch # :nodoc:
def before_sending
headers.freeze
- request.cookie_jar.commit!
+ request.commit_cookie_jar!
end
def build_buffer(response, body)
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 65baf117ba..3477aa8b29 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -12,6 +12,12 @@ module ActionDispatch
end
# :stopdoc:
+ prepend Module.new {
+ def commit_cookie_jar!
+ cookie_jar.commit!
+ end
+ }
+
def have_cookie_jar?
has_header? 'action_dispatch.cookies'.freeze
end