diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-28 18:06:01 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-10-28 18:06:01 +0100 |
commit | fc276e5635821e65c04b8961170cc6bd3c11b923 (patch) | |
tree | 9bd4ed018858611248e9b6aa7392dced92bc814a /actionpack | |
parent | 8e53e058acea471eab7a1609dc150aa9fdbfa833 (diff) | |
parent | 6a3d6b7f1352efd3e7b931533740252b04850e27 (diff) | |
download | rails-fc276e5635821e65c04b8961170cc6bd3c11b923.tar.gz rails-fc276e5635821e65c04b8961170cc6bd3c11b923.tar.bz2 rails-fc276e5635821e65c04b8961170cc6bd3c11b923.zip |
Merge branch 'master' into nested_has_many_through
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/associations.rb
activerecord/test/schema/schema.rb
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/actionpack.gemspec | 3 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller/rendering.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/rack_cache.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/performance_test.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 11 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 9 | ||||
-rw-r--r-- | actionpack/test/abstract_unit.rb | 5 | ||||
-rw-r--r-- | actionpack/test/dispatch/cookies_test.rb | 23 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 18 |
11 files changed, 69 insertions, 41 deletions
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index 40eafd1a2f..c2af3dfaf5 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -22,9 +22,8 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', version) s.add_dependency('activemodel', version) s.add_dependency('rack-cache', '~> 0.5.3') - s.add_dependency('rack-cache-purge', '~> 0.0.1') s.add_dependency('builder', '~> 2.1.2') - s.add_dependency('i18n', '~> 0.4.1') + s.add_dependency('i18n', '~> 0.4.2') s.add_dependency('rack', '~> 1.2.1') s.add_dependency('rack-test', '~> 0.5.6') s.add_dependency('rack-mount', '~> 0.6.13') diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 1c63fb2d14..475785a4b4 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -46,14 +46,14 @@ module AbstractController @view_context_class ||= begin controller = self Class.new(ActionView::Base) do + if controller.respond_to?(:_routes) && controller._routes + include controller._routes.url_helpers + include controller._routes.mounted_helpers + end + if controller.respond_to?(:_helpers) include controller._helpers - if controller.respond_to?(:_routes) && controller._routes - include controller._routes.url_helpers - include controller._routes.mounted_helpers - end - # TODO: Fix RJS to not require this self.helpers = controller._helpers end diff --git a/actionpack/lib/action_dispatch/http/rack_cache.rb b/actionpack/lib/action_dispatch/http/rack_cache.rb index e5914abc81..b5c1435903 100644 --- a/actionpack/lib/action_dispatch/http/rack_cache.rb +++ b/actionpack/lib/action_dispatch/http/rack_cache.rb @@ -21,11 +21,6 @@ module ActionDispatch @store.write(key, value) end - def purge(key) - @store.delete(key) - nil - end - ::Rack::Cache::MetaStore::RAILS = self end @@ -58,10 +53,6 @@ module ActionDispatch [key, size] end - def purge(key) - @store.delete(key) - end - ::Rack::Cache::EntityStore::RAILS = self end end diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index cfee95eb4b..4da82f958a 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -8,11 +8,6 @@ module ActionDispatch protocol + host_with_port + fullpath end - # Returns 'https' if this is an SSL request and 'http' otherwise. - def scheme - ssl? ? 'https' : 'http' - end - # Returns 'https://' if this is an SSL request and 'http://' otherwise. def protocol @protocol ||= ssl? ? 'https://' : 'http://' @@ -99,4 +94,4 @@ module ActionDispatch end end end -end
\ No newline at end of file +end diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index 75c8cc3dd0..c4c2e1acd7 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -98,17 +98,19 @@ module ActionDispatch def self.build(request) secret = request.env[TOKEN_KEY] host = request.host + secure = request.ssl? - new(secret, host).tap do |hash| + new(secret, host, secure).tap do |hash| hash.update(request.cookies) end end - def initialize(secret = nil, host = nil) + def initialize(secret = nil, host = nil, secure = false) @secret = secret @set_cookies = {} @delete_cookies = {} @host = host + @secure = secure super() end @@ -193,9 +195,15 @@ module ActionDispatch end def write(headers) - @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) } + @set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) if write_cookie?(v) } @delete_cookies.each { |k, v| ::Rack::Utils.delete_cookie_header!(headers, k, v) } end + + private + + def write_cookie?(cookie) + @secure || !cookie[:secure] || defined?(Rails.env) && Rails.env.development? + end end class PermanentCookieJar < CookieJar #:nodoc: diff --git a/actionpack/lib/action_dispatch/testing/performance_test.rb b/actionpack/lib/action_dispatch/testing/performance_test.rb index d6c98b4db7..e7aeb45fb3 100644 --- a/actionpack/lib/action_dispatch/testing/performance_test.rb +++ b/actionpack/lib/action_dispatch/testing/performance_test.rb @@ -1,5 +1,4 @@ require 'active_support/testing/performance' -require 'active_support/testing/default' begin module ActionDispatch diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 3aee4fb773..c1214bc44e 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -215,21 +215,10 @@ module ActionView # # Creates a time select tag that, when POSTed, will be stored in the post variable in the sunrise attribute # time_select("post", "sunrise") # - # # Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted - # # attribute - # time_select("order", "submitted") - # - # # Creates a time select tag that, when POSTed, will be stored in the mail variable in the sent_at attribute - # time_select("mail", "sent_at") - # # # Creates a time select tag with a seconds field that, when POSTed, will be stored in the post variables in # # the sunrise attribute. # time_select("post", "start_time", :include_seconds => true) # - # # Creates a time select tag with a seconds field that, when POSTed, will be stored in the entry variables in - # # the submission_time attribute. - # time_select("entry", "submission_time", :include_seconds => true) - # # # You can set the :minute_step to 15 which will give you: 00, 15, 30 and 45. # time_select 'game', 'game_time', {:minute_step => 15} # diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 2f29c8f0e6..ee51617a2b 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -24,16 +24,17 @@ module ActionView # escaping. # # ==== Options + # You can use symbols or strings for the attribute names. + # # Use +true+ with boolean attributes that can render with no value, like # +disabled+ and +readonly+. # # HTML5 <tt>data-*</tt> attributes can be set with a single +data+ key # pointing to a hash of sub-attributes. # - # Sub-attribute keys may be strings or symbols. To play nicely with - # JavaScript conventions +dataset+ they will be dasherized so that a key - # +user_id+ would render as <tt>data-user-id</tt> and thus accessed as - # <tt>dataset.userId</tt>. + # To play nicely with JavaScript conventions sub-attributes are dasherized. + # For example, a key +user_id+ would render as <tt>data-user-id</tt> and + # thus accessed as <tt>dataset.userId</tt>. # # Values are encoded to JSON, with the exception of strings and symbols. # This may come in handy when using jQuery's HTML5-aware <tt>.data()<tt> diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 470b36dbe2..92597e40ff 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -47,6 +47,11 @@ end require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late module Rails + class << self + def env + @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test") + end + end end ActiveSupport::Dependencies.hook! diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb index efdc1f5d93..faeae91f6b 100644 --- a/actionpack/test/dispatch/cookies_test.rb +++ b/actionpack/test/dispatch/cookies_test.rb @@ -135,11 +135,25 @@ class CookiesTest < ActionController::TestCase end def test_setting_cookie_with_secure + @request.env["HTTPS"] = "on" get :authenticate_with_secure assert_cookie_header "user_name=david; path=/; secure" assert_equal({"user_name" => "david"}, @response.cookies) end + def test_setting_cookie_with_secure_in_development + Rails.env.stubs(:development?).returns(true) + get :authenticate_with_secure + assert_cookie_header "user_name=david; path=/; secure" + assert_equal({"user_name" => "david"}, @response.cookies) + end + + def test_not_setting_cookie_with_secure + get :authenticate_with_secure + assert_not_cookie_header "user_name=david; path=/; secure" + assert_not_equal({"user_name" => "david"}, @response.cookies) + end + def test_multiple_cookies get :set_multiple_cookies assert_equal 2, @response.cookies.size @@ -286,4 +300,13 @@ class CookiesTest < ActionController::TestCase assert_equal expected.split("\n"), header end end + + def assert_not_cookie_header(expected) + header = @response.headers["Set-Cookie"] + if header.respond_to?(:to_str) + assert_not_equal expected.split("\n").sort, header.split("\n").sort + else + assert_not_equal expected.split("\n"), header + end + end end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index a6fdf806a4..bc2548e06c 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -433,6 +433,10 @@ class UrlHelperControllerTest < ActionController::TestCase match 'url_helper_controller_test/url_helper/normalize_recall_params', :to => UrlHelperController.action(:normalize_recall), :as => :normalize_recall_params + + match '/url_helper_controller_test/url_helper/override_url_helper/default', + :to => 'url_helper_controller_test/url_helper#override_url_helper', + :as => :override_url_helper end def show @@ -468,6 +472,15 @@ class UrlHelperControllerTest < ActionController::TestCase end def rescue_action(e) raise e end + + def override_url_helper + render :inline => '<%= override_url_helper_path %>' + end + + def override_url_helper_path + '/url_helper_controller_test/url_helper/override_url_helper/override' + end + helper_method :override_url_helper_path end tests UrlHelperController @@ -527,6 +540,11 @@ class UrlHelperControllerTest < ActionController::TestCase get :show, :name => '123' assert_equal 'ok', @response.body end + + def test_url_helper_can_be_overriden + get :override_url_helper + assert_equal '/url_helper_controller_test/url_helper/override_url_helper/override', @response.body + end end class TasksController < ActionController::Base |