diff options
-rw-r--r-- | actionpack/lib/action_controller/metal/request_forgery_protection.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/response.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tags/label.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/force_ssl_test.rb | 23 | ||||
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 14 | ||||
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 1 | ||||
-rw-r--r-- | guides/assets/stylesheets/main.css | 6 | ||||
-rw-r--r-- | guides/code/getting_started/config/environments/production.rb | 2 | ||||
-rw-r--r-- | guides/source/asset_pipeline.textile | 2 | ||||
-rw-r--r-- | guides/source/engines.textile | 6 | ||||
-rw-r--r-- | guides/source/layouts_and_rendering.textile | 14 | ||||
-rw-r--r-- | guides/source/routing.textile | 11 | ||||
-rw-r--r-- | guides/source/testing.textile | 2 | ||||
-rw-r--r-- | railties/lib/rails/paths.rb | 2 |
15 files changed, 70 insertions, 24 deletions
diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb index 3081c14c09..0bff1825d9 100644 --- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb @@ -17,7 +17,6 @@ module ActionController #:nodoc: # CSRF protection is turned on with the <tt>protect_from_forgery</tt> method, # which checks the token and resets the session if it doesn't match what was expected. # A call to this method is generated for new \Rails applications by default. - # You can customize the error message by editing public/422.html. # # The token parameter is named <tt>authenticity_token</tt> by default. The name and # value of this token must be added to every layout that renders forms by including diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index a5e7a8c715..bea54f9778 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -8,7 +8,7 @@ module ActionDispatch # Asserts that the response is one of the following types: # - # * <tt>:success</tt> - Status code was 200 + # * <tt>:success</tt> - Status code was in the 200-299 range # * <tt>:redirect</tt> - Status code was in the 300-399 range # * <tt>:missing</tt> - Status code was 404 # * <tt>:error</tt> - Status code was in the 500-599 range diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index fb6dfff9b8..e403d6cf5e 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -101,7 +101,7 @@ module ActionView # # => <select id="colors" multiple="multiple" name="colors[]"><option>Red</option> # # <option>Green</option><option>Blue</option></select> # - # select_tag "locations", "<option>Home</option><option selected="selected">Work</option><option>Out</option>".html_safe + # select_tag "locations", "<option>Home</option><option selected='selected'>Work</option><option>Out</option>".html_safe # # => <select id="locations" name="locations"><option>Home</option><option selected='selected'>Work</option> # # <option>Out</option></select> # diff --git a/actionpack/lib/action_view/helpers/tags/label.rb b/actionpack/lib/action_view/helpers/tags/label.rb index 1c8bf063ea..16135fcd5a 100644 --- a/actionpack/lib/action_view/helpers/tags/label.rb +++ b/actionpack/lib/action_view/helpers/tags/label.rb @@ -33,7 +33,7 @@ module ActionView options["for"] = name_and_id["id"] unless options.key?("for") if block_given? - @template_object.label_tag(name_and_id["id"], options, &block) + content = @template_object.capture(&block) else content = if @content.blank? @object_name.gsub!(/\[(.*)_attributes\]\[\d\]/, '.\1') @@ -55,9 +55,9 @@ module ActionView end content ||= @method_name.humanize - - label_tag(name_and_id["id"], content, options) end + + label_tag(name_and_id["id"], content, options) end end end diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb index 7feeda25b3..5b423c8151 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -26,6 +26,14 @@ class ForceSSLExceptAction < ForceSSLController force_ssl :except => :banana end +class ForceSSLIfCondition < ForceSSLController + force_ssl :if => :use_force_ssl? + + def use_force_ssl? + action_name == 'cheeseburger' + end +end + class ForceSSLFlash < ForceSSLController force_ssl :except => [:banana, :set_flash, :use_flash] @@ -109,6 +117,21 @@ class ForceSSLExceptActionTest < ActionController::TestCase end end +class ForceSSLIfConditionTest < ActionController::TestCase + tests ForceSSLIfCondition + + def test_banana_not_redirects_to_https + get :banana + assert_response 200 + end + + def test_cheeseburger_redirects_to_https + get :cheeseburger + assert_response 301 + assert_equal "https://test.host/force_ssl_if_condition/cheeseburger", redirect_to_url + end +end + class ForceSSLFlashTest < ActionController::TestCase tests ForceSSLFlash diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 7b684822fc..f13296a175 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1080,6 +1080,20 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_label_error_wrapping_block_and_non_block_versions + form_for(@post) do |f| + concat f.label(:author_name, 'Name', :class => 'label') + concat f.label(:author_name, :class => 'label') { 'Name' } + end + + expected = whole_form('/posts/123', 'edit_post_123' , 'edit_post', 'patch') do + "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>" + + "<div class='field_with_errors'><label for='post_author_name' class='label'>Name</label></div>" + end + + assert_dom_equal expected, output_buffer + end + def test_form_for_with_namespace form_for(@post, :namespace => 'namespace') do |f| concat f.text_field(:title) diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index adf000e53c..5665e10002 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -1,7 +1,6 @@ require 'active_support/inflector' require 'active_support/core_ext/hash/except' require 'active_support/core_ext/module/introspection' -require 'active_support/core_ext/module/deprecation' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/blank' diff --git a/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css index 90723cc8e1..42b85fefa3 100644 --- a/guides/assets/stylesheets/main.css +++ b/guides/assets/stylesheets/main.css @@ -80,7 +80,7 @@ body { font-family: Helvetica, Arial, sans-serif; font-size: 87.5%; line-height: 1.5em; - background: #222; + background: #fff; min-width: 69em; color: #999; } @@ -94,6 +94,7 @@ body { #topNav { padding: 1em 0; color: #565656; + background: #222; } #header { @@ -111,7 +112,6 @@ body { } #container { - background: #FFF; color: #333; padding: 0.5em 0 1.5em 0; } @@ -137,7 +137,7 @@ body { #footer { padding: 2em 0; - background: url(../images/footer_tile.gif) repeat-x; + background: #222 url(../images/footer_tile.gif) repeat-x; } #footer .wrapper { padding-left: 2em; diff --git a/guides/code/getting_started/config/environments/production.rb b/guides/code/getting_started/config/environments/production.rb index cfb8c960d6..ecc35b030b 100644 --- a/guides/code/getting_started/config/environments/production.rb +++ b/guides/code/getting_started/config/environments/production.rb @@ -20,7 +20,7 @@ Blog::Application.configure do # Generate digests for assets URLs. config.assets.digest = true - # Defaults to Rails.root.join("public/assets"). + # Defaults to nil # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files. diff --git a/guides/source/asset_pipeline.textile b/guides/source/asset_pipeline.textile index a1b7a42d66..464788f30f 100644 --- a/guides/source/asset_pipeline.textile +++ b/guides/source/asset_pipeline.textile @@ -673,7 +673,7 @@ config.assets.compile = false # Generate digests for assets URLs. config.assets.digest = true -# Defaults to Rails.root.join("public/assets") +# Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) diff --git a/guides/source/engines.textile b/guides/source/engines.textile index 047f9afd76..20df254950 100644 --- a/guides/source/engines.textile +++ b/guides/source/engines.textile @@ -77,7 +77,7 @@ end By inheriting from the +Rails::Engine+ class, this gem notifies Rails that there's an engine at the specified path, and will correctly mount the engine inside the application, performing tasks such as adding the +app+ directory of the engine to the load path for models, mailers, controllers and views. -The +isolate_namespace+ method here deserves special notice. This call is responsible for isolating the controllers, models, routes and other things into their own namespace, away from similar components inside hte application. Without this, there is a possibility that the engine's components could "leak" into the application, causing unwanted disruption, or that important engine components could be overriden by similarly named things within the application. One of the examples of such conflicts are helpers. Without calling +isolate_namespace+, engine's helpers would be included in application's controllers. +The +isolate_namespace+ method here deserves special notice. This call is responsible for isolating the controllers, models, routes and other things into their own namespace, away from similar components inside the application. Without this, there is a possibility that the engine's components could "leak" into the application, causing unwanted disruption, or that important engine components could be overridden by similarly named things within the application. One of the examples of such conflicts are helpers. Without calling +isolate_namespace+, engine's helpers would be included in application's controllers. NOTE: It is *highly* recommended that the +isolate_namespace+ line be left within the +Engine+ class definition. Without it, classes generated in an engine *may* conflict with an application. @@ -665,7 +665,7 @@ Try this now by creating a new file at +app/views/blorgh/posts/index.html.erb+ a Rather than looking like the default scaffold, the page will now look like this: -!images/engines_post_override.png(Engine scaffold overriden)! +!images/engines_post_override.png(Engine scaffold overridden)! h4. Routes @@ -736,7 +736,7 @@ You can define assets for precompilation in +engine.rb+ initializer do |app| app.config.assets.precompile += %w(admin.css admin.js) end -</ruby +</ruby> For more information, read the "Asset Pipeline guide":http://guides.rubyonrails.org/asset_pipeline.html diff --git a/guides/source/layouts_and_rendering.textile b/guides/source/layouts_and_rendering.textile index 4b4f9f3745..7c7fc7044c 100644 --- a/guides/source/layouts_and_rendering.textile +++ b/guides/source/layouts_and_rendering.textile @@ -1134,13 +1134,6 @@ In Rails 3.0, there is also a shorthand for this. Assuming +@products+ is a coll Rails determines the name of the partial to use by looking at the model name in the collection. In fact, you can even create a heterogeneous collection and render it this way, and Rails will choose the proper partial for each member of the collection: -In the event that the collection is empty, +render+ will return nil, so it should be fairly simple to provide alternative content. - -<erb> -<h1>Products</h1> -<%= render(@products) || 'There are no products available.' %> -</erb> - * +index.html.erb+ <erb> @@ -1162,6 +1155,13 @@ In the event that the collection is empty, +render+ will return nil, so it shoul In this case, Rails will use the customer or employee partials as appropriate for each member of the collection. +In the event that the collection is empty, +render+ will return nil, so it should be fairly simple to provide alternative content. + +<erb> +<h1>Products</h1> +<%= render(@products) || 'There are no products available.' %> +</erb> + h5. Local Variables To use a custom local variable name within the partial, specify the +:as+ option in the call to the partial: diff --git a/guides/source/routing.textile b/guides/source/routing.textile index e93b1280e0..75f4e82918 100644 --- a/guides/source/routing.textile +++ b/guides/source/routing.textile @@ -535,6 +535,17 @@ TwitterClone::Application.routes.draw do end </ruby> +You can also specify constraints as a lambda: + +<ruby> +TwitterClone::Application.routes.draw do + match "*path" => "blacklist#index", + :constraints => lambda { |request| Blacklist.retrieve_ips.include?(request.remote_ip) } +end +</ruby> + +Both the +matches?+ method and the lambda gets the +request+ object as an argument. + h4. Route Globbing Route globbing is a way to specify that a particular parameter should be matched to all the remaining parts of a route. For example diff --git a/guides/source/testing.textile b/guides/source/testing.textile index 60b0aa89b9..d35be6a70e 100644 --- a/guides/source/testing.textile +++ b/guides/source/testing.textile @@ -412,7 +412,7 @@ NOTE: +assert_valid(record)+ has been deprecated. Please use +assert(record.vali |+assert_no_difference(expressions, message = nil, &block)+ |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.| |+assert_recognizes(expected_options, path, extras={}, message=nil)+ |Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.| |+assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)+ |Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.| -|+assert_response(type, message = nil)+ |Asserts that the response comes with a specific status code. You can specify +:success+ to indicate 200, +:redirect+ to indicate 300-399, +:missing+ to indicate 404, or +:error+ to match the 500-599 range| +|+assert_response(type, message = nil)+ |Asserts that the response comes with a specific status code. You can specify +:success+ to indicate 200-299, +:redirect+ to indicate 300-399, +:missing+ to indicate 404, or +:error+ to match the 500-599 range| |+assert_redirected_to(options = {}, message=nil)+ |Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that +assert_redirected_to(:controller => "weblog")+ will also match the redirection of +redirect_to(:controller => "weblog", :action => "show")+ and so on.| |+assert_template(expected = nil, message=nil)+ |Asserts that the request was rendered with the appropriate template file.| diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index e9bd0f181e..dd1790299d 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -160,7 +160,7 @@ module Rails end def each(&block) - @paths.each &block + @paths.each(&block) end def <<(path) |