actionpack 2.1.2 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +223 -7
- data/README +6 -12
- data/Rakefile +11 -11
- data/lib/action_controller.rb +9 -9
- data/lib/action_controller/assertions/response_assertions.rb +29 -78
- data/lib/action_controller/assertions/routing_assertions.rb +33 -33
- data/lib/action_controller/assertions/selector_assertions.rb +9 -5
- data/lib/action_controller/base.rb +227 -161
- data/lib/action_controller/benchmarking.rb +37 -24
- data/lib/action_controller/caching/actions.rb +53 -21
- data/lib/action_controller/caching/fragments.rb +10 -36
- data/lib/action_controller/caching/sweeping.rb +3 -3
- data/lib/action_controller/cgi_ext/session.rb +2 -22
- data/lib/action_controller/cgi_process.rb +8 -46
- data/lib/action_controller/components.rb +4 -1
- data/lib/action_controller/cookies.rb +10 -0
- data/lib/action_controller/dispatcher.rb +49 -15
- data/lib/action_controller/filters.rb +48 -10
- data/lib/action_controller/headers.rb +16 -14
- data/lib/action_controller/helpers.rb +2 -2
- data/lib/action_controller/http_authentication.rb +1 -1
- data/lib/action_controller/integration.rb +57 -60
- data/lib/action_controller/layout.rb +27 -53
- data/lib/action_controller/mime_responds.rb +5 -1
- data/lib/action_controller/mime_type.rb +64 -42
- data/lib/action_controller/mime_types.rb +2 -1
- data/lib/action_controller/performance_test.rb +16 -0
- data/lib/action_controller/polymorphic_routes.rb +16 -9
- data/lib/action_controller/rack_process.rb +303 -0
- data/lib/action_controller/request.rb +205 -97
- data/lib/action_controller/request_forgery_protection.rb +2 -2
- data/lib/action_controller/request_profiler.rb +0 -0
- data/lib/action_controller/rescue.rb +20 -115
- data/lib/action_controller/resources.rb +186 -83
- data/lib/action_controller/response.rb +140 -26
- data/lib/action_controller/routing.rb +28 -30
- data/lib/action_controller/routing/builder.rb +45 -54
- data/lib/action_controller/routing/optimisations.rb +31 -21
- data/lib/action_controller/routing/recognition_optimisation.rb +33 -27
- data/lib/action_controller/routing/route.rb +162 -147
- data/lib/action_controller/routing/route_set.rb +8 -7
- data/lib/action_controller/routing/routing_ext.rb +4 -1
- data/lib/action_controller/routing/segments.rb +50 -21
- data/lib/action_controller/session/cookie_store.rb +3 -2
- data/lib/action_controller/session/drb_server.rb +7 -7
- data/lib/action_controller/session_management.rb +6 -2
- data/lib/action_controller/streaming.rb +15 -8
- data/lib/action_controller/templates/rescues/diagnostics.erb +2 -2
- data/lib/action_controller/templates/rescues/template_error.erb +2 -2
- data/lib/action_controller/test_case.rb +66 -2
- data/lib/action_controller/test_process.rb +71 -66
- data/lib/action_controller/translation.rb +13 -0
- data/lib/action_controller/url_rewriter.rb +90 -13
- data/lib/action_controller/vendor/html-scanner/html/node.rb +9 -2
- data/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +1 -1
- data/lib/action_controller/vendor/html-scanner/html/selector.rb +2 -2
- data/lib/action_controller/verification.rb +2 -2
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view.rb +19 -11
- data/lib/action_view/base.rb +184 -150
- data/lib/action_view/helpers.rb +38 -0
- data/lib/action_view/helpers/active_record_helper.rb +56 -27
- data/lib/action_view/helpers/asset_tag_helper.rb +356 -153
- data/lib/action_view/helpers/atom_feed_helper.rb +74 -19
- data/lib/action_view/helpers/benchmark_helper.rb +3 -3
- data/lib/action_view/helpers/cache_helper.rb +1 -2
- data/lib/action_view/helpers/capture_helper.rb +19 -44
- data/lib/action_view/helpers/date_helper.rb +486 -296
- data/lib/action_view/helpers/debug_helper.rb +20 -13
- data/lib/action_view/helpers/form_helper.rb +71 -30
- data/lib/action_view/helpers/form_options_helper.rb +15 -85
- data/lib/action_view/helpers/form_tag_helper.rb +61 -38
- data/lib/action_view/helpers/javascript_helper.rb +80 -89
- data/lib/action_view/helpers/number_helper.rb +179 -74
- data/lib/action_view/helpers/prototype_helper.rb +216 -201
- data/lib/action_view/helpers/record_tag_helper.rb +4 -5
- data/lib/action_view/helpers/sanitize_helper.rb +65 -33
- data/lib/action_view/helpers/scriptaculous_helper.rb +2 -2
- data/lib/action_view/helpers/tag_helper.rb +39 -22
- data/lib/action_view/helpers/text_helper.rb +212 -118
- data/lib/action_view/helpers/translation_helper.rb +21 -0
- data/lib/action_view/helpers/url_helper.rb +100 -58
- data/lib/action_view/inline_template.rb +13 -14
- data/lib/action_view/locale/en.yml +91 -0
- data/lib/action_view/partials.rb +100 -55
- data/lib/action_view/paths.rb +125 -0
- data/lib/action_view/renderable.rb +102 -0
- data/lib/action_view/renderable_partial.rb +48 -0
- data/lib/action_view/template.rb +90 -101
- data/lib/action_view/template_error.rb +11 -21
- data/lib/action_view/template_handler.rb +8 -28
- data/lib/action_view/template_handlers.rb +45 -0
- data/lib/action_view/template_handlers/builder.rb +5 -15
- data/lib/action_view/template_handlers/erb.rb +9 -6
- data/lib/action_view/template_handlers/rjs.rb +2 -17
- data/lib/action_view/test_case.rb +7 -4
- data/test/abstract_unit.rb +4 -1
- data/test/active_record_unit.rb +28 -30
- data/test/activerecord/render_partial_with_record_identification_test.rb +25 -12
- data/test/controller/action_pack_assertions_test.rb +8 -37
- data/test/controller/addresses_render_test.rb +0 -3
- data/test/controller/assert_select_test.rb +51 -24
- data/test/controller/base_test.rb +4 -4
- data/test/controller/caching_test.rb +136 -66
- data/test/controller/capture_test.rb +1 -21
- data/test/controller/cgi_test.rb +157 -10
- data/test/controller/components_test.rb +41 -25
- data/test/controller/content_type_test.rb +49 -17
- data/test/controller/cookie_test.rb +1 -1
- data/test/controller/deprecation/deprecated_base_methods_test.rb +0 -3
- data/test/controller/dispatcher_test.rb +9 -1
- data/test/controller/filter_params_test.rb +2 -2
- data/test/controller/filters_test.rb +13 -13
- data/test/controller/html-scanner/cdata_node_test.rb +15 -0
- data/test/controller/html-scanner/node_test.rb +21 -0
- data/test/controller/html-scanner/sanitizer_test.rb +14 -0
- data/test/controller/integration_test.rb +167 -6
- data/test/controller/layout_test.rb +11 -68
- data/test/controller/logging_test.rb +46 -0
- data/test/controller/mime_responds_test.rb +61 -59
- data/test/controller/mime_type_test.rb +6 -6
- data/test/controller/polymorphic_routes_test.rb +37 -2
- data/test/controller/rack_test.rb +323 -0
- data/test/controller/redirect_test.rb +72 -71
- data/test/controller/render_test.rb +1120 -108
- data/test/controller/request_forgery_protection_test.rb +66 -52
- data/test/controller/request_test.rb +103 -146
- data/test/controller/rescue_test.rb +20 -24
- data/test/controller/resources_test.rb +408 -25
- data/test/controller/routing_test.rb +1774 -1774
- data/test/controller/send_file_test.rb +0 -4
- data/test/controller/session/cookie_store_test.rb +53 -1
- data/test/controller/test_test.rb +15 -37
- data/test/controller/translation_test.rb +26 -0
- data/test/controller/url_rewriter_test.rb +27 -28
- data/test/controller/view_paths_test.rb +48 -47
- data/test/fixtures/_top_level_partial.html.erb +1 -0
- data/test/fixtures/_top_level_partial_only.erb +1 -0
- data/test/fixtures/developers/_developer.erb +1 -0
- data/test/fixtures/fun/games/_game.erb +1 -0
- data/test/fixtures/fun/serious/games/_game.erb +1 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.html.erb +3 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +6 -0
- data/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder +5 -0
- data/test/fixtures/functional_caching/inline_fragment_cached.html.erb +2 -0
- data/test/fixtures/layouts/_column.html.erb +2 -0
- data/test/fixtures/projects/_project.erb +1 -0
- data/test/fixtures/public/javascripts/subdir/subdir.js +1 -0
- data/test/fixtures/public/stylesheets/subdir/subdir.css +1 -0
- data/test/fixtures/replies/_reply.erb +1 -0
- data/test/fixtures/test/_counter.html.erb +1 -0
- data/test/fixtures/test/_customer.erb +1 -1
- data/test/fixtures/test/_customer_with_var.erb +1 -0
- data/test/fixtures/test/_layout_for_block_with_args.html.erb +3 -0
- data/test/fixtures/test/_local_inspector.html.erb +1 -0
- data/test/fixtures/test/_partial_with_only_html_version.html.erb +1 -0
- data/test/fixtures/test/hello.builder +1 -1
- data/test/fixtures/test/hyphen-ated.erb +1 -0
- data/test/fixtures/test/implicit_content_type.atom.builder +2 -0
- data/test/fixtures/test/nested_layout.erb +3 -0
- data/test/fixtures/test/non_erb_block_content_for.builder +1 -1
- data/test/fixtures/test/sub_template_raise.html.erb +1 -0
- data/test/fixtures/test/template.erb +1 -0
- data/test/fixtures/test/using_layout_around_block_with_args.html.erb +1 -0
- data/test/template/active_record_helper_i18n_test.rb +46 -0
- data/test/template/active_record_helper_test.rb +24 -24
- data/test/template/asset_tag_helper_test.rb +161 -29
- data/test/template/atom_feed_helper_test.rb +114 -5
- data/test/template/compiled_templates_test.rb +59 -0
- data/test/template/date_helper_i18n_test.rb +113 -0
- data/test/template/date_helper_test.rb +403 -109
- data/test/template/form_helper_test.rb +213 -154
- data/test/template/form_options_helper_test.rb +249 -897
- data/test/template/form_tag_helper_test.rb +80 -32
- data/test/template/javascript_helper_test.rb +17 -18
- data/test/template/number_helper_i18n_test.rb +54 -0
- data/test/template/number_helper_test.rb +43 -13
- data/test/template/prototype_helper_test.rb +101 -84
- data/test/template/record_tag_helper_test.rb +24 -20
- data/test/template/render_test.rb +193 -0
- data/test/template/sanitize_helper_test.rb +3 -3
- data/test/template/tag_helper_test.rb +34 -14
- data/test/template/text_helper_test.rb +83 -9
- data/test/template/translation_helper_test.rb +28 -0
- data/test/template/url_helper_test.rb +55 -18
- metadata +57 -18
- data/lib/action_view/helpers/javascripts/controls.js +0 -963
- data/lib/action_view/helpers/javascripts/dragdrop.js +0 -972
- data/lib/action_view/helpers/javascripts/effects.js +0 -1120
- data/lib/action_view/helpers/javascripts/prototype.js +0 -4225
- data/lib/action_view/partial_template.rb +0 -70
- data/lib/action_view/template_finder.rb +0 -177
- data/lib/action_view/template_handlers/compilable.rb +0 -128
- data/test/controller/custom_handler_test.rb +0 -45
- data/test/controller/new_render_test.rb +0 -945
- data/test/fixtures/test/block_content_for.erb +0 -2
- data/test/fixtures/test/erb_content_for.erb +0 -2
- data/test/template/deprecated_erb_variable_test.rb +0 -9
- data/test/template/template_finder_test.rb +0 -73
- data/test/template/template_object_test.rb +0 -95
data/CHANGELOG
CHANGED
@@ -1,26 +1,242 @@
|
|
1
|
-
*2.
|
1
|
+
*2.2.2 [2.2 Final]*
|
2
2
|
|
3
|
-
*
|
3
|
+
* Deprecated the :file default for ActionView#render to prepare for 2.3's new :partial default [DHH]
|
4
|
+
|
5
|
+
|
6
|
+
*2.2.1 [RC2] (November 14th, 2008)*
|
7
|
+
|
8
|
+
* Restore backwards compatible functionality for setting relative_url_root. Include deprecation
|
9
|
+
|
10
|
+
* Switched the CSRF module to use the request content type to decide if the request is forgeable. #1145 [Jeff Cohen]
|
11
|
+
|
12
|
+
* Added :only and :except to map.resources to let people cut down on the number of redundant routes in an application. Typically only useful for huge routesets. #1215 [Tom Stuart]
|
13
|
+
|
14
|
+
map.resources :products, :only => :show do |product|
|
15
|
+
product.resources :images, :except => :destroy
|
16
|
+
end
|
17
|
+
|
18
|
+
* Added render :js for people who want to render inline JavaScript replies without using RJS [DHH]
|
19
|
+
|
20
|
+
* Fixed that polymorphic_url should compact given array #1317 [hiroshi]
|
21
|
+
|
22
|
+
* Fixed the sanitize helper to avoid double escaping already properly escaped entities #683 [antonmos/Ryan McGeary]
|
23
|
+
|
24
|
+
* Fixed that FormTagHelper generated illegal html if name contained square brackets #1238 [Vladimir Dobriakov]
|
25
|
+
|
26
|
+
* Fix regression bug that made date_select and datetime_select raise a Null Pointer Exception when a nil date/datetime was passed and only month and year were displayed #1289 [Bernardo Padua/Tor Erik]
|
27
|
+
|
28
|
+
* Simplified the logging format for parameters (don't include controller, action, and format as duplicates) [DHH]
|
29
|
+
|
30
|
+
* Remove the logging of the Session ID when the session store is CookieStore [DHH]
|
31
|
+
|
32
|
+
* Fixed regex in redirect_to to fully support URI schemes #1247 [Seth Fitzsimmons]
|
33
|
+
|
34
|
+
* Fixed bug with asset timestamping when using relative_url_root #1265 [Joe Goldwasser]
|
35
|
+
|
36
|
+
|
37
|
+
*2.2.0 [RC1] (October 24th, 2008)*
|
38
|
+
|
39
|
+
* Fix incorrect closing CDATA delimiter and that HTML::Node.parse would blow up on unclosed CDATA sections [packagethief]
|
40
|
+
|
41
|
+
* Added stale? and fresh_when methods to provide a layer of abstraction above request.fresh? and friends [DHH]. Example:
|
42
|
+
|
43
|
+
class ArticlesController < ApplicationController
|
44
|
+
def show_with_respond_to_block
|
45
|
+
@article = Article.find(params[:id])
|
46
|
+
|
47
|
+
|
48
|
+
# If the request sends headers that differs from the options provided to stale?, then
|
49
|
+
# the request is indeed stale and the respond_to block is triggered (and the options
|
50
|
+
# to the stale? call is set on the response).
|
51
|
+
#
|
52
|
+
# If the request headers match, then the request is fresh and the respond_to block is
|
53
|
+
# not triggered. Instead the default render will occur, which will check the last-modified
|
54
|
+
# and etag headers and conclude that it only needs to send a "304 Not Modified" instead
|
55
|
+
# of rendering the template.
|
56
|
+
if stale?(:last_modified => @article.published_at.utc, :etag => @article)
|
57
|
+
respond_to do |wants|
|
58
|
+
# normal response processing
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def show_with_implied_render
|
64
|
+
@article = Article.find(params[:id])
|
65
|
+
|
66
|
+
# Sets the response headers and checks them against the request, if the request is stale
|
67
|
+
# (i.e. no match of either etag or last-modified), then the default render of the template happens.
|
68
|
+
# If the request is fresh, then the default render will return a "304 Not Modified"
|
69
|
+
# instead of rendering the template.
|
70
|
+
fresh_when(:last_modified => @article.published_at.utc, :etag => @article)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
* Added inline builder yield to atom_feed_helper tags where appropriate [Sam Ruby]. Example:
|
76
|
+
|
77
|
+
entry.summary :type => 'xhtml' do |xhtml|
|
78
|
+
xhtml.p pluralize(order.line_items.count, "line item")
|
79
|
+
xhtml.p "Shipped to #{order.address}"
|
80
|
+
xhtml.p "Paid by #{order.pay_type}"
|
81
|
+
end
|
82
|
+
|
83
|
+
* Make PrototypeHelper#submit_to_remote a wrapper around PrototypeHelper#button_to_remote. [Tarmo Tänav]
|
84
|
+
|
85
|
+
* Set HttpOnly for the cookie session store's cookie. #1046
|
86
|
+
|
87
|
+
* Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton]
|
4
88
|
|
5
89
|
* Fixed FormTagHelper#submit_tag with :disable_with option wouldn't submit the button's value when was clicked #633 [Jose Fernandez]
|
6
90
|
|
91
|
+
* Stopped logging template compiles as it only clogs up the log [DHH]
|
7
92
|
|
8
|
-
*
|
93
|
+
* Changed the X-Runtime header to report in milliseconds [DHH]
|
9
94
|
|
10
|
-
*
|
95
|
+
* Changed BenchmarkHelper#benchmark to report in milliseconds [DHH]
|
96
|
+
|
97
|
+
* Changed logging format to be millisecond based and skip misleading stats [DHH]. Went from:
|
98
|
+
|
99
|
+
Completed in 0.10000 (4 reqs/sec) | Rendering: 0.04000 (40%) | DB: 0.00400 (4%) | 200 OK [http://example.com]
|
100
|
+
|
101
|
+
...to:
|
102
|
+
|
103
|
+
Completed in 100ms (View: 40, DB: 4) | 200 OK [http://example.com]
|
104
|
+
|
105
|
+
* Add support for shallow nesting of routes. #838 [S. Brent Faulkner]
|
106
|
+
|
107
|
+
Example :
|
108
|
+
|
109
|
+
map.resources :users, :shallow => true do |user|
|
110
|
+
user.resources :posts
|
111
|
+
end
|
112
|
+
|
113
|
+
- GET /users/1/posts (maps to PostsController#index action as usual)
|
114
|
+
named route "user_posts" is added as usual.
|
115
|
+
|
116
|
+
- GET /posts/2 (maps to PostsController#show action as if it were not nested)
|
117
|
+
Additionally, named route "post" is added too.
|
118
|
+
|
119
|
+
* Added button_to_remote helper. #3641 [Donald Piret, Tarmo Tänav]
|
11
120
|
|
12
|
-
* Deprecate
|
121
|
+
* Deprecate render_component. Please use render_component plugin from http://github.com/rails/render_component/tree/master [Pratik]
|
122
|
+
|
123
|
+
* Routes may be restricted to lists of HTTP methods instead of a single method or :any. #407 [Brennan Dunn, Gaius Centus Novus]
|
124
|
+
map.resource :posts, :collection => { :search => [:get, :post] }
|
125
|
+
map.session 'session', :requirements => { :method => [:get, :post, :delete] }
|
126
|
+
|
127
|
+
* Deprecated implicit local assignments when rendering partials [Josh Peek]
|
128
|
+
|
129
|
+
* Introduce current_cycle helper method to return the current value without bumping the cycle. #417 [Ken Collins]
|
130
|
+
|
131
|
+
* Allow polymorphic_url helper to take url options. #880 [Tarmo Tänav]
|
132
|
+
|
133
|
+
* Switched integration test runner to use Rack processor instead of CGI [Josh Peek]
|
134
|
+
|
135
|
+
* Made AbstractRequest.if_modified_sense return nil if the header could not be parsed [Jamis Buck]
|
136
|
+
|
137
|
+
* Added back ActionController::Base.allow_concurrency flag [Josh Peek]
|
138
|
+
|
139
|
+
* AbstractRequest.relative_url_root is no longer automatically configured by a HTTP header. It can now be set in your configuration environment with config.action_controller.relative_url_root [Josh Peek]
|
140
|
+
|
141
|
+
* Update Prototype to 1.6.0.2 #599 [Patrick Joyce]
|
142
|
+
|
143
|
+
* Conditional GET utility methods. [Jeremy Kemper]
|
144
|
+
response.last_modified = @post.updated_at
|
145
|
+
response.etag = [:admin, @post, current_user]
|
146
|
+
|
147
|
+
if request.fresh?(response)
|
148
|
+
head :not_modified
|
149
|
+
else
|
150
|
+
# render ...
|
151
|
+
end
|
152
|
+
|
153
|
+
* All 2xx requests are considered successful [Josh Peek]
|
13
154
|
|
14
155
|
* Fixed that AssetTagHelper#compute_public_path shouldn't cache the asset_host along with the source or per-request proc's won't run [DHH]
|
15
156
|
|
16
|
-
*
|
157
|
+
* Removed config.action_view.cache_template_loading, use config.cache_classes instead [Josh Peek]
|
158
|
+
|
159
|
+
* Get buffer for fragment cache from template's @output_buffer [Josh Peek]
|
160
|
+
|
161
|
+
* Set config.action_view.warn_cache_misses = true to receive a warning if you perform an action that results in an expensive disk operation that could be cached [Josh Peek]
|
162
|
+
|
163
|
+
* Refactor template preloading. New abstractions include Renderable mixins and a refactored Template class [Josh Peek]
|
164
|
+
|
165
|
+
* Changed ActionView::TemplateHandler#render API method signature to render(template, local_assigns = {}) [Josh Peek]
|
166
|
+
|
167
|
+
* Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to_remote to stay consistent with link_to_remote (submit_to_remote still works as an alias) #8994 [clemens]
|
168
|
+
|
169
|
+
* Add :recursive option to javascript_include_tag and stylesheet_link_tag to be used along with :all. #480 [Damian Janowski]
|
170
|
+
|
171
|
+
* Allow users to disable the use of the Accept header [Michael Koziarski]
|
172
|
+
|
173
|
+
The accept header is poorly implemented by browsers and causes strange
|
174
|
+
errors when used on public sites where crawlers make requests too. You
|
175
|
+
can use formatted urls (e.g. /people/1.xml) to support API clients in a
|
176
|
+
much simpler way.
|
177
|
+
|
178
|
+
To disable the header you need to set:
|
179
|
+
|
180
|
+
config.action_controller.use_accept_header = false
|
181
|
+
|
182
|
+
* Do not stat template files in production mode before rendering. You will no longer be able to modify templates in production mode without restarting the server [Josh Peek]
|
183
|
+
|
184
|
+
* Deprecated TemplateHandler line offset [Josh Peek]
|
185
|
+
|
186
|
+
* Allow caches_action to accept cache store options. #416. [José Valim]. Example:
|
187
|
+
|
188
|
+
caches_action :index, :redirected, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour
|
189
|
+
|
190
|
+
* Remove define_javascript_functions, javascript_include_tag and friends are far superior. [Michael Koziarski]
|
191
|
+
|
192
|
+
* Deprecate :use_full_path render option. The supplying the option no longer has an effect [Josh Peek]
|
193
|
+
|
194
|
+
* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]
|
195
|
+
|
196
|
+
render :partial => 'other_people', :collection => @people, :as => :person
|
197
|
+
|
198
|
+
This will let you access objects of @people as 'person' local variable inside 'other_people' partial template.
|
199
|
+
|
200
|
+
* time_zone_select: support for regexp matching of priority zones. Resolves #195 [Ernie Miller]
|
201
|
+
|
202
|
+
* Made ActionView::Base#render_file private [Josh Peek]
|
203
|
+
|
204
|
+
* Refactor and simplify the implementation of assert_redirected_to. Arguments are now normalised relative to the controller being tested, not the root of the application. [Michael Koziarski]
|
205
|
+
|
206
|
+
This could cause some erroneous test failures if you were redirecting between controllers
|
207
|
+
in different namespaces and wrote your assertions relative to the root of the application.
|
208
|
+
|
209
|
+
* Remove follow_redirect from controller functional tests.
|
210
|
+
|
211
|
+
If you want to follow redirects you can use integration tests. The functional test
|
212
|
+
version was only useful if you were using redirect_to :id=>...
|
17
213
|
|
18
214
|
* Fix polymorphic_url with singleton resources. #461 [Tammer Saleh]
|
19
215
|
|
20
|
-
*
|
216
|
+
* Replaced TemplateFinder abstraction with ViewLoadPaths [Josh Peek]
|
217
|
+
|
218
|
+
* Added block-call style to link_to [Sam Stephenson/DHH]. Example:
|
219
|
+
|
220
|
+
<% link_to(@profile) do %>
|
221
|
+
<strong><%= @profile.name %></strong> -- <span>Check it out!!</span>
|
222
|
+
<% end %>
|
223
|
+
|
224
|
+
* Performance: integration test benchmarking and profiling. [Jeremy Kemper]
|
225
|
+
|
226
|
+
* Make caching more aware of mime types. Ensure request format is not considered while expiring cache. [Jonathan del Strother]
|
227
|
+
|
228
|
+
* Drop ActionController::Base.allow_concurrency flag [Josh Peek]
|
229
|
+
|
230
|
+
* More efficient concat and capture helpers. Remove ActionView::Base.erb_variable. [Jeremy Kemper]
|
231
|
+
|
232
|
+
* Added page.reload functionality. Resolves #277. [Sean Huber]
|
21
233
|
|
22
234
|
* Fixed Request#remote_ip to only raise hell if the HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR doesn't match (not just if they're both present) [Mark Imbriaco, Bradford Folkens]
|
23
235
|
|
236
|
+
* Allow caches_action to accept a layout option [José Valim]
|
237
|
+
|
238
|
+
* Added Rack processor [Ezra Zygmuntowicz, Josh Peek]
|
239
|
+
|
24
240
|
|
25
241
|
*2.1.0 (May 31st, 2008)*
|
26
242
|
|
data/README
CHANGED
@@ -31,7 +31,7 @@ http://www.rubyonrails.org.
|
|
31
31
|
A short rundown of the major features:
|
32
32
|
|
33
33
|
* Actions grouped in controller as methods instead of separate command objects
|
34
|
-
and can therefore share helper methods
|
34
|
+
and can therefore share helper methods
|
35
35
|
|
36
36
|
BlogController < ActionController::Base
|
37
37
|
def show
|
@@ -168,7 +168,7 @@ A short rundown of the major features:
|
|
168
168
|
{Learn more}[link:classes/ActionController/Base.html]
|
169
169
|
|
170
170
|
|
171
|
-
* Javascript and Ajax integration
|
171
|
+
* Javascript and Ajax integration
|
172
172
|
|
173
173
|
link_to_function "Greeting", "alert('Hello world!')"
|
174
174
|
link_to_remote "Delete this post", :update => "posts",
|
@@ -177,7 +177,7 @@ A short rundown of the major features:
|
|
177
177
|
{Learn more}[link:classes/ActionView/Helpers/JavaScriptHelper.html]
|
178
178
|
|
179
179
|
|
180
|
-
* Pagination for navigating lists of results
|
180
|
+
* Pagination for navigating lists of results
|
181
181
|
|
182
182
|
# controller
|
183
183
|
def list
|
@@ -192,15 +192,9 @@ A short rundown of the major features:
|
|
192
192
|
{Learn more}[link:classes/ActionController/Pagination.html]
|
193
193
|
|
194
194
|
|
195
|
-
* Easy testing of both controller and template
|
196
|
-
|
197
|
-
class LoginControllerTest < Test::Unit::TestCase
|
198
|
-
def setup
|
199
|
-
@controller = LoginController.new
|
200
|
-
@request = ActionController::TestRequest.new
|
201
|
-
@response = ActionController::TestResponse.new
|
202
|
-
end
|
195
|
+
* Easy testing of both controller and rendered template through ActionController::TestCase
|
203
196
|
|
197
|
+
class LoginControllerTest < ActionController::TestCase
|
204
198
|
def test_failing_authenticate
|
205
199
|
process :authenticate, :user_name => "nop", :password => ""
|
206
200
|
assert flash.has_key?(:alert)
|
@@ -208,7 +202,7 @@ A short rundown of the major features:
|
|
208
202
|
end
|
209
203
|
end
|
210
204
|
|
211
|
-
{Learn more}[link:classes/ActionController/
|
205
|
+
{Learn more}[link:classes/ActionController/TestCase.html]
|
212
206
|
|
213
207
|
|
214
208
|
* Automated benchmarking and integrated logging
|
data/Rakefile
CHANGED
@@ -5,8 +5,6 @@ require 'rake/rdoctask'
|
|
5
5
|
require 'rake/packagetask'
|
6
6
|
require 'rake/gempackagetask'
|
7
7
|
require 'rake/contrib/sshpublisher'
|
8
|
-
require 'rake/contrib/rubyforgepublisher'
|
9
|
-
|
10
8
|
require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
|
11
9
|
|
12
10
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
@@ -27,14 +25,16 @@ task :default => [ :test ]
|
|
27
25
|
desc "Run all unit tests"
|
28
26
|
task :test => [:test_action_pack, :test_active_record_integration]
|
29
27
|
|
30
|
-
Rake::TestTask.new(:test_action_pack)
|
28
|
+
Rake::TestTask.new(:test_action_pack) do |t|
|
31
29
|
t.libs << "test"
|
32
|
-
|
33
|
-
#
|
34
|
-
|
35
|
-
|
30
|
+
|
31
|
+
# make sure we include the tests in alphabetical order as on some systems
|
32
|
+
# this will not happen automatically and the tests (as a whole) will error
|
33
|
+
t.test_files = Dir.glob( "test/[cft]*/**/*_test.rb" ).sort
|
34
|
+
|
36
35
|
t.verbose = true
|
37
|
-
|
36
|
+
#t.warning = true
|
37
|
+
end
|
38
38
|
|
39
39
|
desc 'ActiveRecord Integration Tests'
|
40
40
|
Rake::TestTask.new(:test_active_record_integration) do |t|
|
@@ -80,7 +80,7 @@ spec = Gem::Specification.new do |s|
|
|
80
80
|
s.has_rdoc = true
|
81
81
|
s.requirements << 'none'
|
82
82
|
|
83
|
-
s.add_dependency('activesupport', '= 2.
|
83
|
+
s.add_dependency('activesupport', '= 2.2.2' + PKG_BUILD)
|
84
84
|
|
85
85
|
s.require_path = 'lib'
|
86
86
|
s.autorequire = 'action_controller'
|
@@ -136,8 +136,8 @@ task :update_js => [ :update_scriptaculous ]
|
|
136
136
|
|
137
137
|
desc "Publish the API documentation"
|
138
138
|
task :pgem => [:package] do
|
139
|
-
Rake::SshFilePublisher.new("
|
140
|
-
`ssh
|
139
|
+
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
140
|
+
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
|
141
141
|
end
|
142
142
|
|
143
143
|
desc "Publish the API documentation"
|
data/lib/action_controller.rb
CHANGED
@@ -21,16 +21,13 @@
|
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
#++
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
$:.unshift
|
24
|
+
begin
|
25
|
+
require 'active_support'
|
26
|
+
rescue LoadError
|
27
|
+
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
|
28
|
+
if File.directory?(activesupport_path)
|
29
|
+
$:.unshift activesupport_path
|
30
30
|
require 'active_support'
|
31
|
-
rescue LoadError
|
32
|
-
require 'rubygems'
|
33
|
-
gem 'activesupport'
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
@@ -53,9 +50,11 @@ require 'action_controller/streaming'
|
|
53
50
|
require 'action_controller/session_management'
|
54
51
|
require 'action_controller/http_authentication'
|
55
52
|
require 'action_controller/components'
|
53
|
+
require 'action_controller/rack_process'
|
56
54
|
require 'action_controller/record_identifier'
|
57
55
|
require 'action_controller/request_forgery_protection'
|
58
56
|
require 'action_controller/headers'
|
57
|
+
require 'action_controller/translation'
|
59
58
|
|
60
59
|
require 'action_view'
|
61
60
|
|
@@ -76,4 +75,5 @@ ActionController::Base.class_eval do
|
|
76
75
|
include ActionController::Components
|
77
76
|
include ActionController::RecordIdentifier
|
78
77
|
include ActionController::RequestForgeryProtection
|
78
|
+
include ActionController::Translation
|
79
79
|
end
|
@@ -56,74 +56,24 @@ module ActionController
|
|
56
56
|
# # assert that the redirection was to the named route login_url
|
57
57
|
# assert_redirected_to login_url
|
58
58
|
#
|
59
|
+
# # assert that the redirection was to the url for @customer
|
60
|
+
# assert_redirected_to @customer
|
61
|
+
#
|
59
62
|
def assert_redirected_to(options = {}, message=nil)
|
60
63
|
clean_backtrace do
|
61
64
|
assert_response(:redirect, message)
|
62
65
|
return true if options == @response.redirected_to
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
unless value.is_a?(Hash)
|
74
|
-
request = case value
|
75
|
-
when NilClass then nil
|
76
|
-
when /^\w+:\/\// then recognized_request_for(%r{^(\w+://.*?(/|$|\?))(.*)$} =~ value ? $3 : nil)
|
77
|
-
else recognized_request_for(value)
|
78
|
-
end
|
79
|
-
value = request.path_parameters if request
|
80
|
-
end
|
81
|
-
|
82
|
-
if value.is_a?(Hash) # stringify 2 levels of hash keys
|
83
|
-
if name = value.delete(:use_route)
|
84
|
-
route = ActionController::Routing::Routes.named_routes[name]
|
85
|
-
value.update(route.parameter_shell)
|
86
|
-
end
|
87
|
-
|
88
|
-
value.stringify_keys!
|
89
|
-
value.values.select { |v| v.is_a?(Hash) }.collect { |v| v.stringify_keys! }
|
90
|
-
if key == :expected && value['controller'] == @controller.controller_name && original[:actual].is_a?(Hash)
|
91
|
-
original[:actual].stringify_keys!
|
92
|
-
value.delete('controller') if original[:actual]['controller'].nil? || original[:actual]['controller'] == value['controller']
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
if value.respond_to?(:[]) && value['controller']
|
97
|
-
value['controller'] = value['controller'].to_s
|
98
|
-
if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
|
99
|
-
new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
|
100
|
-
value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash)
|
101
|
-
end
|
102
|
-
value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash
|
103
|
-
end
|
104
|
-
url[key] = value
|
105
|
-
end
|
106
|
-
|
107
|
-
@response_diff = url[:actual].diff(url[:expected]) if url[:actual]
|
108
|
-
msg = build_message(message, "expected a redirect to <?>, found one to <?>, a difference of <?> ", url[:expected], url[:actual], @response_diff)
|
109
|
-
|
110
|
-
assert_block(msg) do
|
111
|
-
url[:expected].keys.all? do |k|
|
112
|
-
if k == :controller then url[:expected][k] == ActionController::Routing.controller_relative_to(url[:actual][k], @controller.class.controller_path)
|
113
|
-
else parameterize(url[:expected][k]) == parameterize(url[:actual][k])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
rescue ActionController::RoutingError # routing failed us, so match the strings only.
|
118
|
-
msg = build_message(message, "expected a redirect to <?>, found one to <?>", options, @response.redirect_url)
|
119
|
-
url_regexp = %r{^(\w+://.*?(/|$|\?))(.*)$}
|
120
|
-
eurl, epath, url, path = [options, @response.redirect_url].collect do |url|
|
121
|
-
u, p = (url_regexp =~ url) ? [$1, $3] : [nil, url]
|
122
|
-
[u, (p.first == '/') ? p : '/' + p]
|
123
|
-
end.flatten
|
66
|
+
|
67
|
+
# Support partial arguments for hash redirections
|
68
|
+
if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
|
69
|
+
return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
|
70
|
+
end
|
71
|
+
|
72
|
+
redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
|
73
|
+
options_after_normalisation = normalize_argument_to_redirection(options)
|
124
74
|
|
125
|
-
|
126
|
-
|
75
|
+
if redirected_to_after_normalisation != options_after_normalisation
|
76
|
+
flunk "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
|
127
77
|
end
|
128
78
|
end
|
129
79
|
end
|
@@ -137,36 +87,37 @@ module ActionController
|
|
137
87
|
#
|
138
88
|
def assert_template(expected = nil, message=nil)
|
139
89
|
clean_backtrace do
|
140
|
-
rendered =
|
90
|
+
rendered = @response.rendered_template.to_s
|
141
91
|
msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
|
142
92
|
assert_block(msg) do
|
143
93
|
if expected.nil?
|
144
|
-
|
94
|
+
@response.rendered_template.blank?
|
145
95
|
else
|
146
|
-
expected
|
96
|
+
rendered.to_s.match(expected)
|
147
97
|
end
|
148
98
|
end
|
149
99
|
end
|
150
100
|
end
|
151
101
|
|
152
102
|
private
|
153
|
-
# Recognizes the route for a given path.
|
154
|
-
def recognized_request_for(path, request_method = nil)
|
155
|
-
path = "/#{path}" unless path.first == '/'
|
156
|
-
|
157
|
-
# Assume given controller
|
158
|
-
request = ActionController::TestRequest.new({}, {}, nil)
|
159
|
-
request.env["REQUEST_METHOD"] = request_method.to_s.upcase if request_method
|
160
|
-
request.path = path
|
161
|
-
|
162
|
-
ActionController::Routing::Routes.recognize(request)
|
163
|
-
request
|
164
|
-
end
|
165
103
|
|
166
104
|
# Proxy to to_param if the object will respond to it.
|
167
105
|
def parameterize(value)
|
168
106
|
value.respond_to?(:to_param) ? value.to_param : value
|
169
107
|
end
|
108
|
+
|
109
|
+
def normalize_argument_to_redirection(fragment)
|
110
|
+
after_routing = @controller.url_for(fragment)
|
111
|
+
if after_routing =~ %r{^\w+://.*}
|
112
|
+
after_routing
|
113
|
+
else
|
114
|
+
# FIXME - this should probably get removed.
|
115
|
+
if after_routing.first != '/'
|
116
|
+
after_routing = '/' + after_routing
|
117
|
+
end
|
118
|
+
@request.protocol + @request.host_with_port + after_routing
|
119
|
+
end
|
120
|
+
end
|
170
121
|
end
|
171
122
|
end
|
172
123
|
end
|