From 2ebea1c02d10e0fea26bd98d297a8f4d41dc1aff Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 31 Jan 2010 16:27:24 +1100 Subject: deOMGifying Railties, Active Support, and Action Pack --- actionpack/lib/action_controller/metal/testing.rb | 2 +- actionpack/lib/action_view/template/resolver.rb | 3 +-- actionpack/test/abstract/layouts_test.rb | 18 +++++++------- actionpack/test/controller/filters_test.rb | 6 ++--- .../test/controller/new_base/render_action_test.rb | 28 +++++++++++----------- .../test/controller/new_base/render_layout_test.rb | 20 ++++++++-------- .../controller/new_base/render_partial_test.rb | 4 ++-- actionpack/test/controller/subscriber_test.rb | 4 ++-- actionpack/test/dispatch/mime_type_test.rb | 4 ++-- .../test/template/html-scanner/sanitizer_test.rb | 4 ++-- actionpack/test/template/subscriber_test.rb | 4 ++-- activesupport/test/callbacks_test.rb | 8 +++---- activesupport/test/fixtures/custom.rb | 2 ++ activesupport/test/fixtures/omgomg.rb | 2 -- activesupport/test/isolation_test.rb | 12 +++++----- activesupport/test/notifications_test.rb | 6 ++--- .../source/rails_application_templates.textile | 2 +- railties/test/initializable_test.rb | 2 +- 18 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 activesupport/test/fixtures/custom.rb delete mode 100644 activesupport/test/fixtures/omgomg.rb diff --git a/actionpack/lib/action_controller/metal/testing.rb b/actionpack/lib/action_controller/metal/testing.rb index d62269b9af..707ad968f4 100644 --- a/actionpack/lib/action_controller/metal/testing.rb +++ b/actionpack/lib/action_controller/metal/testing.rb @@ -4,7 +4,7 @@ module ActionController include RackDelegation - # OMG MEGA HAX + # TODO: Clean this up def process_with_new_base_test(request, response) @_request = request @_response = response diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 340a6afe5e..af5d6f6d18 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -141,8 +141,7 @@ module ActionView end end - # OMG HAX - # TODO: remove hax + # TODO: remove hack class FileSystemResolverWithFallback < Resolver def initialize(path, options = {}) super(options) diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb index bf02e5a864..b6d89ea489 100644 --- a/actionpack/test/abstract/layouts_test.rb +++ b/actionpack/test/abstract/layouts_test.rb @@ -13,7 +13,7 @@ module AbstractControllerTests "layouts/hello_override.erb" => "With Override <%= yield %>", "layouts/abstract_controller_tests/layouts/with_string_implied_child.erb" => "With Implied <%= yield %>", - "layouts/omg.erb" => "OMGHI2U <%= yield %>", + "layouts/overwrite.erb" => "Overwrite <%= yield %>", "layouts/with_false_layout.erb" => "False Layout <%= yield %>" )] end @@ -42,7 +42,7 @@ module AbstractControllerTests end def overwrite_string - render :_template => ActionView::Template::Text.new("Hello string!"), :layout => "omg" + render :_template => ActionView::Template::Text.new("Hello string!"), :layout => "overwrite" end def overwrite_skip @@ -68,7 +68,7 @@ module AbstractControllerTests end class WithProc < Base - layout proc { |c| "omg" } + layout proc { |c| "overwrite" } def index render :_template => ActionView::Template::Text.new("Hello proc!") @@ -83,7 +83,7 @@ module AbstractControllerTests end private def hello - "omg" + "overwrite" end end @@ -122,7 +122,7 @@ module AbstractControllerTests end class WithSymbolAndNoMethod < Base - layout :omg_no_method + layout :no_method def index render :_template => ActionView::Template::Text.new("Hello boom!") @@ -175,7 +175,7 @@ module AbstractControllerTests test "when layout is overwriten by string in render, render new layout" do controller = WithString.new controller.process(:overwrite_string) - assert_equal "OMGHI2U Hello string!", controller.response_body + assert_equal "Overwrite Hello string!", controller.response_body end test "when layout is overwriten by false in render, render no layout" do @@ -209,13 +209,13 @@ module AbstractControllerTests test "when layout is specified as a proc, call it and use the layout returned" do controller = WithProc.new controller.process(:index) - assert_equal "OMGHI2U Hello proc!", controller.response_body + assert_equal "Overwrite Hello proc!", controller.response_body end test "when layout is specified as a symbol, call the requested method and use the layout returned" do controller = WithSymbol.new controller.process(:index) - assert_equal "OMGHI2U Hello symbol!", controller.response_body + assert_equal "Overwrite Hello symbol!", controller.response_body end test "when layout is specified as a symbol and the method returns nil, don't use a layout" do @@ -266,7 +266,7 @@ module AbstractControllerTests test "raises an exception when specifying layout true" do assert_raises ArgumentError do Object.class_eval do - class ::BadOmgFailLolLayout < AbstractControllerTests::Layouts::Base + class ::BadFailLayout < AbstractControllerTests::Layouts::Base layout true end end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index 8445428e8f..004e1369d3 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -435,7 +435,7 @@ class FilterTest < ActionController::TestCase end def non_yielding_filter - @filters << "zomg it didn't yield" + @filters << "it didn't yield" @filter_return_value end @@ -465,14 +465,14 @@ class FilterTest < ActionController::TestCase controller = NonYieldingAroundFilterController.new controller.instance_variable_set "@filter_return_value", false test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] + assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters'] end def test_after_filters_are_not_run_if_around_filter_does_not_yield controller = NonYieldingAroundFilterController.new controller.instance_variable_set "@filter_return_value", true test_process(controller, "index") - assert_equal ["filter_one", "zomg it didn't yield"], controller.assigns['filters'] + assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters'] end def test_added_filter_to_inheritance_graph diff --git a/actionpack/test/controller/new_base/render_action_test.rb b/actionpack/test/controller/new_base/render_action_test.rb index 239f68659c..0804d7b09d 100644 --- a/actionpack/test/controller/new_base/render_action_test.rb +++ b/actionpack/test/controller/new_base/render_action_test.rb @@ -119,9 +119,9 @@ module RenderActionWithApplicationLayout # Set the view path to an application view structure with layouts self.view_paths = self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_application_layout/basic/hello_world.html.erb" => "Hello World!", - "render_action_with_application_layout/basic/hello.html.builder" => "xml.p 'Omg'", - "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI", - "layouts/greetings.html.erb" => "Greetings <%= yield %> Bai", + "render_action_with_application_layout/basic/hello.html.builder" => "xml.p 'Hello'", + "layouts/application.html.erb" => "Hi <%= yield %> OK, Bye", + "layouts/greetings.html.erb" => "Greetings <%= yield %> Bye", "layouts/builder.html.builder" => "xml.html do\n xml << yield\nend" )] @@ -156,14 +156,14 @@ module RenderActionWithApplicationLayout test "rendering implicit application.html.erb as layout" do get "/render_action_with_application_layout/basic/hello_world" - assert_body "OHAI Hello World! KTHXBAI" + assert_body "Hi Hello World! OK, Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_application_layout/basic/hello_world_with_layout" - assert_body "OHAI Hello World! KTHXBAI" + assert_body "Hi Hello World! OK, Bye" assert_status 200 end @@ -184,7 +184,7 @@ module RenderActionWithApplicationLayout test "rendering with layout => 'greetings'" do get "/render_action_with_application_layout/basic/hello_world_with_custom_layout" - assert_body "Greetings Hello World! Bai" + assert_body "Greetings Hello World! Bye" assert_status 200 end end @@ -194,7 +194,7 @@ module RenderActionWithApplicationLayout test "builder works with layouts" do get :with_builder_and_layout - assert_response "\n

Omg

\n\n" + assert_response "\n

Hello

\n\n" end end @@ -204,7 +204,7 @@ module RenderActionWithControllerLayout class BasicController < ActionController::Base self.view_paths = self.view_paths = [ActionView::FixtureResolver.new( "render_action_with_controller_layout/basic/hello_world.html.erb" => "Hello World!", - "layouts/render_action_with_controller_layout/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI" + "layouts/render_action_with_controller_layout/basic.html.erb" => "With Controller Layout! <%= yield %> Bye" )] def hello_world @@ -234,14 +234,14 @@ module RenderActionWithControllerLayout test "render hello_world and implicitly use .html.erb as a layout." do get "/render_action_with_controller_layout/basic/hello_world" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_controller_layout/basic/hello_world_with_layout" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end @@ -265,8 +265,8 @@ module RenderActionWithBothLayouts class BasicController < ActionController::Base self.view_paths = [ActionView::FixtureResolver.new({ "render_action_with_both_layouts/basic/hello_world.html.erb" => "Hello World!", - "layouts/application.html.erb" => "OHAI <%= yield %> KTHXBAI", - "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> KTHXBAI" + "layouts/application.html.erb" => "Oh Hi <%= yield %> Bye", + "layouts/render_action_with_both_layouts/basic.html.erb" => "With Controller Layout! <%= yield %> Bye" })] def hello_world @@ -292,14 +292,14 @@ module RenderActionWithBothLayouts test "rendering implicitly use .html.erb over application.html.erb as a layout" do get "/render_action_with_both_layouts/basic/hello_world" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end test "rendering with layout => true" do get "/render_action_with_both_layouts/basic/hello_world_with_layout" - assert_body "With Controller Layout! Hello World! KTHXBAI" + assert_body "With Controller Layout! Hello World! Bye" assert_status 200 end diff --git a/actionpack/test/controller/new_base/render_layout_test.rb b/actionpack/test/controller/new_base/render_layout_test.rb index 6a9668b81a..372fb66b88 100644 --- a/actionpack/test/controller/new_base/render_layout_test.rb +++ b/actionpack/test/controller/new_base/render_layout_test.rb @@ -3,10 +3,10 @@ require 'abstract_unit' module ControllerLayouts class ImplicitController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( - "layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI", + "layouts/application.html.erb" => "Main <%= yield %> Layout", "layouts/override.html.erb" => "Override! <%= yield %>", "basic.html.erb" => "Hello world!", - "controller_layouts/implicit/layout_false.html.erb" => "hai(layout_false.html.erb)" + "controller_layouts/implicit/layout_false.html.erb" => "hi(layout_false.html.erb)" )] def index @@ -27,7 +27,7 @@ module ControllerLayouts class ImplicitNameController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( - "layouts/controller_layouts/implicit_name.html.erb" => "OMGIMPLICIT <%= yield %> KTHXBAI", + "layouts/controller_layouts/implicit_name.html.erb" => "Implicit <%= yield %> Layout", "basic.html.erb" => "Hello world!" )] @@ -40,14 +40,14 @@ module ControllerLayouts test "rendering a normal template, but using the implicit layout" do get "/controller_layouts/implicit/index" - assert_body "OMG Hello world! KTHXBAI" + assert_body "Main Hello world! Layout" assert_status 200 end test "rendering a normal template, but using an implicit NAMED layout" do get "/controller_layouts/implicit_name/index" - assert_body "OMGIMPLICIT Hello world! KTHXBAI" + assert_body "Implicit Hello world! Layout" assert_status 200 end @@ -63,15 +63,15 @@ module ControllerLayouts test "rendering with :layout => false leaves out the implicit layout" do get :layout_false - assert_response "hai(layout_false.html.erb)" + assert_response "hi(layout_false.html.erb)" end end class MismatchFormatController < ::ApplicationController self.view_paths = [ActionView::FixtureResolver.new( "layouts/application.html.erb" => "<%= yield %>", - "controller_layouts/mismatch_format/index.js.rjs" => "page[:test].omg", - "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].omg" + "controller_layouts/mismatch_format/index.js.rjs" => "page[:test].ext", + "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].ext" )] def explicit @@ -84,12 +84,12 @@ module ControllerLayouts test "if JS is selected, an HTML template is not also selected" do get :index, "format" => "js" - assert_response "$(\"test\").omg();" + assert_response "$(\"test\").ext();" end test "if JS is implicitly selected, an HTML template is not also selected" do get :implicit - assert_response "$(\"test\").omg();" + assert_response "$(\"test\").ext();" end test "if an HTML template is explicitly provides for a JS template, an error is raised" do diff --git a/actionpack/test/controller/new_base/render_partial_test.rb b/actionpack/test/controller/new_base/render_partial_test.rb index 8fddcbcd57..1a1b36a65e 100644 --- a/actionpack/test/controller/new_base/render_partial_test.rb +++ b/actionpack/test/controller/new_base/render_partial_test.rb @@ -5,7 +5,7 @@ module RenderPartial class BasicController < ActionController::Base self.view_paths = [ActionView::FixtureResolver.new( - "render_partial/basic/_basic.html.erb" => "OMG!", + "render_partial/basic/_basic.html.erb" => "BasicPartial!", "render_partial/basic/basic.html.erb" => "<%= @test_unchanged = 'goodbye' %><%= render :partial => 'basic' %><%= @test_unchanged %>" )] @@ -20,7 +20,7 @@ module RenderPartial test "rendering a partial in ActionView doesn't pull the ivars again from the controller" do get :changing - assert_response("goodbyeOMG!goodbye") + assert_response("goodbyeBasicPartial!goodbye") end end diff --git a/actionpack/test/controller/subscriber_test.rb b/actionpack/test/controller/subscriber_test.rb index 152a0d0c04..119a18ebc5 100644 --- a/actionpack/test/controller/subscriber_test.rb +++ b/actionpack/test/controller/subscriber_test.rb @@ -13,7 +13,7 @@ module Another end def data_sender - send_data "cool data", :filename => "omg.txt" + send_data "cool data", :filename => "file.txt" end def xfile_sender @@ -121,7 +121,7 @@ class ACSubscriberTest < ActionController::TestCase wait assert_equal 3, logs.size - assert_match /Sent data omg\.txt/, logs[1] + assert_match /Sent data file\.txt/, logs[1] end def test_send_file diff --git a/actionpack/test/dispatch/mime_type_test.rb b/actionpack/test/dispatch/mime_type_test.rb index 0832943d4c..369212e2d0 100644 --- a/actionpack/test/dispatch/mime_type_test.rb +++ b/actionpack/test/dispatch/mime_type_test.rb @@ -23,7 +23,7 @@ class MimeTypeTest < ActiveSupport::TestCase end # Accept header send with user HTTP_USER_AGENT: Sunrise/0.42j (Windows XP) - test "parse crappy broken acceptlines" do + test "parse broken acceptlines" do accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/*,,*/*;q=0.5" expect = [Mime::HTML, Mime::XML, "image/*", Mime::TEXT, Mime::ALL] assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } @@ -31,7 +31,7 @@ class MimeTypeTest < ActiveSupport::TestCase # Accept header send with user HTTP_USER_AGENT: Mozilla/4.0 # (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1) - test "parse crappy broken acceptlines2" do + test "parse other broken acceptlines" do accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" expect = ['image/gif', 'image/x-xbitmap', 'image/jpeg','image/pjpeg', 'application/x-shockwave-flash', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/msword', 'pronto/1.00.00', 'sslvpn/1.00.00.00', Mime::ALL ] assert_equal expect, Mime::Type.parse(accept).collect { |c| c.to_s } diff --git a/actionpack/test/template/html-scanner/sanitizer_test.rb b/actionpack/test/template/html-scanner/sanitizer_test.rb index e85a5c7abf..a6e760b0b6 100644 --- a/actionpack/test/template/html-scanner/sanitizer_test.rb +++ b/actionpack/test/template/html-scanner/sanitizer_test.rb @@ -48,7 +48,7 @@ class SanitizerTest < ActionController::TestCase assert_sanitized "a b cd e f", "a b cd e f" end - # fucked + # TODO: Clean up def test_sanitize_js_handlers raw = %{onthis="do that" hello} assert_sanitized raw, %{onthis="do that" hello} @@ -193,7 +193,7 @@ class SanitizerTest < ActionController::TestCase assert_sanitized img_hack, "" end - # fucked + # TODO: Clean up def test_should_sanitize_attributes assert_sanitized %(blah), %(blah) end diff --git a/actionpack/test/template/subscriber_test.rb b/actionpack/test/template/subscriber_test.rb index 5db2b16ac1..8bacab7088 100644 --- a/actionpack/test/template/subscriber_test.rb +++ b/actionpack/test/template/subscriber_test.rb @@ -33,7 +33,7 @@ class AVSubscriberTest < ActiveSupport::TestCase end def test_render_text_template - @view.render(:text => "OMG") + @view.render(:text => "TEXT") wait assert_equal 1, @logger.logged(:info).size @@ -41,7 +41,7 @@ class AVSubscriberTest < ActiveSupport::TestCase end def test_render_inline_template - @view.render(:inline => "<%= 'OMG' %>") + @view.render(:inline => "<%= 'TEXT' %>") wait assert_equal 1, @logger.logged(:info).size diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index df98644436..11494e951e 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -264,12 +264,12 @@ module CallbacksTest define_callbacks :save attr_reader :stuff - set_callback :save, :before, :omg, :per_key => {:if => :yes} + set_callback :save, :before, :action, :per_key => {:if => :yes} def yes() true end - def omg - @stuff = "OMG" + def action + @stuff = "ACTION" end def save @@ -522,7 +522,7 @@ module CallbacksTest def test_save obj = HyphenatedCallbacks.new obj.save - assert_equal obj.stuff, "OMG" + assert_equal obj.stuff, "ACTION" end end end diff --git a/activesupport/test/fixtures/custom.rb b/activesupport/test/fixtures/custom.rb new file mode 100644 index 0000000000..0eefce0c25 --- /dev/null +++ b/activesupport/test/fixtures/custom.rb @@ -0,0 +1,2 @@ +class Custom +end \ No newline at end of file diff --git a/activesupport/test/fixtures/omgomg.rb b/activesupport/test/fixtures/omgomg.rb deleted file mode 100644 index a512a93ae4..0000000000 --- a/activesupport/test/fixtures/omgomg.rb +++ /dev/null @@ -1,2 +0,0 @@ -class OmgOmg -end \ No newline at end of file diff --git a/activesupport/test/isolation_test.rb b/activesupport/test/isolation_test.rb index a7af5e96f6..2c2986ea28 100644 --- a/activesupport/test/isolation_test.rb +++ b/activesupport/test/isolation_test.rb @@ -59,15 +59,15 @@ elsif ENV['CHILD'] end test "resets requires one" do - assert !defined?(OmgOmg) - assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/omgomg/).size - require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "omgomg")) + assert !defined?(Custom) + assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/custom/).size + require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "custom")) end test "resets requires two" do - assert !defined?(OmgOmg) - assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/omgomg/).size - require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "omgomg")) + assert !defined?(Custom) + assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/custom/).size + require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "custom")) end end else diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index d3af535c26..0b78b53c73 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -77,7 +77,7 @@ module Notifications def test_instrument_with_bang_returns_result_even_on_failure begin instrument!(:awesome, :payload => "notifications") do - raise "OMG" + raise "FAIL" end flunk rescue @@ -126,10 +126,10 @@ module Notifications def test_instrument_does_not_publish_when_exception_is_raised begin instrument(:awesome, :payload => "notifications") do - raise "OMG" + raise "FAIL" end rescue RuntimeError => e - assert_equal "OMG", e.message + assert_equal "FAIL", e.message end drain diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile index fc178fa44b..579b1a5538 100644 --- a/railties/guides/source/rails_application_templates.textile +++ b/railties/guides/source/rails_application_templates.textile @@ -88,7 +88,7 @@ Please note that you need to +git :init+ before you can install a plugin as a su Or use plain old SVN : -plugin 'wtfsvn', :svn => 'svn://crap.com/wtf/trunk' +plugin 'usingsvn', :svn => 'svn://example.com/usingsvn/trunk' h4. vendor/lib/file/initializer(filename, data = nil, &block) diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index 6a7e4dcc25..74301a5dc5 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -10,7 +10,7 @@ module InitializableTests attr_accessor :foo, :bar end - initializer :omg do + initializer :start do @foo ||= 0 @foo += 1 end -- cgit v1.2.3 From bb2c7b432c794af1e0e0ef16e29dcce604af416a Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 29 Jan 2010 16:50:10 +1100 Subject: Updating Action Mailer documentation --- actionmailer/lib/action_mailer/base.rb | 98 ++++++++++++---------- actionmailer/lib/action_mailer/delivery_methods.rb | 2 +- actionmailer/lib/action_mailer/quoting.rb | 3 + 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index dc451417d7..aa9822c6ab 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -33,8 +33,12 @@ module ActionMailer #:nodoc: # * attachments[]= - Allows you to add attachments to your email in an intuitive # manner; attachments['filename.png'] = File.read('path/to/filename.png') # - # * headers[]= - Allows you to specify non standard headers in your email such - # as headers['X-No-Spam'] = 'True' + # * headers[]= - Allows you to specify any header field in your email such + # as headers['X-No-Spam'] = 'True'. Note, while most fields (like To: + # From: can only appear once in an email header, other fields like X-Anything + # can appear multiple times. If you want to change a field that can appear multiple times, + # you need to set it to nil first so that Mail knows you are replacing it, not adding + # another field of the same name.) # # * headers(hash) - Allows you to specify multiple headers in your email such # as headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'}) @@ -42,15 +46,11 @@ module ActionMailer #:nodoc: # * mail - Allows you to specify your email to send. # # The hash passed to the mail method allows you to specify any header that a Mail::Message - # will accept (any valid Email header including optional fields). Obviously if you specify - # the same header in the headers method and then again in the mail method, the last one - # will over write the first, unless you are specifying a header field that can appear more - # than once per RFC, in which case, both will be inserted (X-value headers for example can - # appear multiple times.) + # will accept (any valid Email header including optional fields). # # The mail method, if not passed a block, will inspect your views and send all the views with - # the same name as the method, so the above action would send the +welcome.plain.erb+ view file - # as well as the +welcome.html.erb+ view file in a +multipart/alternative+ email. + # the same name as the method, so the above action would send the +welcome.text.plain.erb+ view + # file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email. # # If you want to explicitly render only certain templates, pass a block: # @@ -66,7 +66,7 @@ module ActionMailer #:nodoc: # format.html # end # - # Or even to renderize a special view: + # Or even to render a special view: # # mail(:to => user.emai) do |format| # format.text @@ -80,7 +80,7 @@ module ActionMailer #:nodoc: # # To define a template to be used with a mailing, create an .erb file with the same # name as the method in your mailer model. For example, in the mailer defined above, the template at - # app/views/notifier/signup_notification.text.erb would be used to generate the email. + # app/views/notifier/signup_notification.text.plain.erb would be used to generate the email. # # Variables defined in the model are accessible as instance variables in the view. # @@ -102,9 +102,9 @@ module ActionMailer #:nodoc: # # = Generating URLs # - # URLs can be generated in mailer views using url_for or named routes. - # Unlike controllers from Action Pack, the mailer instance doesn't have any context about the incoming request, - # so you'll need to provide all of the details needed to generate a URL. + # URLs can be generated in mailer views using url_for or named routes. Unlike controllers from + # Action Pack, the mailer instance doesn't have any context about the incoming request, so you'll need + # to provide all of the details needed to generate a URL. # # When using url_for you'll need to provide the :host, :controller, and :action: # @@ -114,11 +114,11 @@ module ActionMailer #:nodoc: # # <%= users_url(:host => "example.com") %> # - # You will want to avoid using the name_of_route_path form of named routes because it doesn't make sense to - # generate relative URLs in email messages. + # You will want to avoid using the name_of_route_path form of named routes because it doesn't + # make sense to generate relative URLs in email messages. # - # It is also possible to set a default host that will be used in all mailers by setting the :host option in - # the ActionMailer::Base.default_url_options hash as follows: + # It is also possible to set a default host that will be used in all mailers by setting the :host + # option in the ActionMailer::Base.default_url_options hash as follows: # # ActionMailer::Base.default_url_options[:host] = "example.com" # @@ -127,9 +127,9 @@ module ActionMailer #:nodoc: # config.action_mailer.default_url_options = { :host => "example.com" } # # If you do decide to set a default :host for your mailers you will want to use the - # :only_path => false option when using url_for. This will ensure that absolute URLs are generated because - # the url_for view helper will, by default, generate relative URLs when a :host option isn't - # explicitly provided. + # :only_path => false option when using url_for. This will ensure that absolute URLs are + # generated because the url_for view helper will, by default, generate relative URLs when a + # :host option isn't explicitly provided. # # = Sending mail # @@ -140,7 +140,7 @@ module ActionMailer #:nodoc: # mail = Notifier.welcome(david) # => a Mail::Message object # mail.deliver # sends the email # - # You never instantiate your mailer class. Rather, you just call the method on the class itself. + # You never instantiate your mailer class. Rather, you just call the method you defined on the class itself. # # = Multipart Emails # @@ -175,11 +175,11 @@ module ActionMailer #:nodoc: # end # end # - # Which will (if it had both a .text.erb and .html.erb tempalte in the view - # directory), send a complete multipart/mixed email with two parts, the first part being - # a multipart/alternative with the text and HTML email parts inside, and the second being - # a application/pdf with a Base64 encoded copy of the file.pdf book with the filename - # +free_book.pdf+. + # Which will (if it had both a welcome.text.plain.erb and welcome.text.html.erb + # tempalte in the view directory), send a complete multipart/mixed email with two parts, + # the first part being a multipart/alternative with the text and HTML email parts inside, + # and the second being a application/pdf with a Base64 encoded copy of the file.pdf book + # with the filename +free_book.pdf+. # # # = Configuration options @@ -189,7 +189,9 @@ module ActionMailer #:nodoc: # * default - This is a class wide hash of :key => value pairs containing # default values for the specified header fields of the Mail::Message. You can # specify a default for any valid header for Mail::Message and it will be used if - # you do not override it. The defaults set by Action Mailer are: + # you do not override it. You pass in the header value as a symbol, all lower case with under + # scores instead of hyphens, so Content-Transfer-Encoding: + # becomes :content_transfer_encoding. The defaults set by Action Mailer are: # * :mime_version => "1.0" # * :charset => "utf-8", # * :content_type => "text/plain", @@ -199,33 +201,40 @@ module ActionMailer #:nodoc: # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers. # # * smtp_settings - Allows detailed configuration for :smtp delivery method: - # * :address - Allows you to use a remote mail server. Just change it from its default "localhost" setting. + # * :address - Allows you to use a remote mail server. Just change it from its default + # "localhost" setting. # * :port - On the off chance that your mail server doesn't run on port 25, you can change it. # * :domain - If you need to specify a HELO domain, you can do it here. # * :user_name - If your mail server requires authentication, set the username in this setting. # * :password - If your mail server requires authentication, set the password in this setting. - # * :authentication - If your mail server requires authentication, you need to specify the authentication type here. + # * :authentication - If your mail server requires authentication, you need to specify the + # authentication type here. # This is a symbol and one of :plain, :login, :cram_md5. - # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it. - # It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true. + # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server + # and starts to use it. # # * sendmail_settings - Allows you to override options for the :sendmail delivery method. # * :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail. - # * :arguments - The command line arguments. Defaults to -i -t. + # * :arguments - The command line arguments. Defaults to -i -t with -f sender@addres + # added automatically before the message is sent. # # * file_settings - Allows you to override options for the :file delivery method. - # * :location - The directory into which emails will be written. Defaults to the application tmp/mails. + # * :location - The directory into which emails will be written. Defaults to the application + # tmp/mails. # # * raise_delivery_errors - Whether or not errors should be raised if the email fails to be delivered. # - # * delivery_method - Defines a delivery method. Possible values are :smtp (default), :sendmail, :test, - # and :file. Or you may provide a custom delivery method object eg. MyOwnDeliveryMethodClass.new + # * delivery_method - Defines a delivery method. Possible values are :smtp (default), + # :sendmail, :test, and :file. Or you may provide a custom delivery method + # object eg. MyOwnDeliveryMethodClass.new. See the Mail gem documentation on the interface you need to + # implement for a custom delivery agent. # - # * perform_deliveries - Determines whether deliver_* methods are actually carried out. By default they are, - # but this can be turned off to help functional testing. + # * perform_deliveries - Determines whether emails are actually sent from Action Mailer when you + # call .deliver on an mail message or on an Action Mailer method. This is on by default but can + # be turned off to aid in functional testing. # - # * deliveries - Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful - # for unit and functional testing. + # * deliveries - Keeps an array of all the emails sent out through the Action Mailer with + # delivery_method :test. Most useful for unit and functional testing. # # * default_charset - This is now deprecated, use the +default+ method above to # set the default +:charset+. @@ -284,7 +293,7 @@ module ActionMailer #:nodoc: # instantiates a new mailer, and passes the email object to the mailer # object's +receive+ method. If you want your mailer to be able to # process incoming messages, you'll need to implement a +receive+ - # method that accepts the email object as a parameter: + # method that accepts the raw email string as a parameter: # # class MyMailer < ActionMailer::Base # def receive(mail) @@ -299,9 +308,10 @@ module ActionMailer #:nodoc: end end - # Delivers a mail object. This is actually called by the Mail::Message object - # itself through a call back when you call :deliver on the Mail::Message, - # calling +deliver_mail+ directly and passing an Mail::Message will do nothing. + # Wraps an email delivery inside of Active Support Notifications instrumentation. This + # method is actually called by the Mail::Message object itself through a call back + # when you call :deliver on the Mail::Message, calling +deliver_mail+ directly + # and passing a Mail::Message will do nothing except tell the logger you sent the email. def deliver_mail(mail) #:nodoc: ActiveSupport::Notifications.instrument("action_mailer.deliver") do |payload| self.set_payload_for_mail(payload, mail) diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb index f6321a240c..7e92aea8fd 100644 --- a/actionmailer/lib/action_mailer/delivery_methods.rb +++ b/actionmailer/lib/action_mailer/delivery_methods.rb @@ -2,7 +2,7 @@ require 'tmpdir' module ActionMailer # This modules handles everything related to the delivery, from registering new - # delivery methods to configuring the mail object to be send. + # delivery methods to configuring the mail object to be sent. module DeliveryMethods extend ActiveSupport::Concern diff --git a/actionmailer/lib/action_mailer/quoting.rb b/actionmailer/lib/action_mailer/quoting.rb index b30441f9de..70f636bf69 100644 --- a/actionmailer/lib/action_mailer/quoting.rb +++ b/actionmailer/lib/action_mailer/quoting.rb @@ -1,5 +1,8 @@ module ActionMailer module Quoting #:nodoc: + # TODO extract this into Mail itself. + # + # # Convert the given text into quoted printable format, with an instruction # that the text be eventually interpreted in the given charset. def quoted_printable(text, charset) -- cgit v1.2.3 From 59e9478f57216999c12580c42cb9149894090123 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 31 Jan 2010 13:37:43 -0600 Subject: Require ac/test_case from AV::TestCase --- actionpack/lib/action_view/test_case.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 16d66b6eca..3095d84e13 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -1,3 +1,5 @@ +require 'action_controller/test_case' + module ActionView class Base alias_method :initialize_without_template_tracking, :initialize -- cgit v1.2.3 From a3349f845ffa2415e12ac9e26b4f7300d7edd3ef Mon Sep 17 00:00:00 2001 From: "Stephen St. Martin" Date: Sun, 31 Jan 2010 14:42:40 -0500 Subject: form_for should pass :remote to form_tag through html_options --- actionpack/lib/action_view/helpers/form_helper.rb | 2 ++ actionpack/test/template/form_helper_test.rb | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 20e9916d62..54610fdc71 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -280,6 +280,8 @@ module ActionView args.unshift object end + options[:html][:remote] = true if options.delete(:remote) + concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {})) fields_for(object_name, *(args << options), &proc) concat(''.html_safe!) diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index c97343fbe5..caeca9db10 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -451,6 +451,25 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal expected, output_buffer end + def test_form_for_with_remote + form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "
" + + "
" + + "" + + "" + + "" + + "" + + "
" + + assert_dom_equal expected, output_buffer + end + def test_form_for_without_object form_for(:post, :html => { :id => 'create-post' }) do |f| concat f.text_field(:title) -- cgit v1.2.3 From a9e89e82b67f721fe68ca58a2d371b666cdb7441 Mon Sep 17 00:00:00 2001 From: "Stephen St. Martin" Date: Sun, 31 Jan 2010 14:03:37 -0500 Subject: add :remote option to form_tag --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 1 + actionpack/test/template/form_tag_helper_test.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index fb32f78e5b..81c76e090a 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -441,6 +441,7 @@ module ActionView returning options.stringify_keys do |html_options| html_options["enctype"] = "multipart/form-data" if html_options.delete("multipart") html_options["action"] = url_for(url_for_options, *parameters_for_url) + html_options["data-remote"] = true if html_options.delete("remote") end end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 01bde8ea04..553ec44fad 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -53,6 +53,12 @@ class FormTagHelperTest < ActionView::TestCase assert_dom_equal expected, actual end + def test_form_tag_with_remote + actual = form_tag({}, :remote => true) + expected = %(
) + assert_dom_equal expected, actual + end + def test_form_tag_with_block_in_erb __in_erb_template = '' form_tag("http://example.com") { concat "Hello world!" } -- cgit v1.2.3 From e1618b9ac397d1963e788f441fc4965cd3f9d4cf Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Sun, 31 Jan 2010 15:40:40 -0500 Subject: data-remote needs to be on the form and not the submit when using button_to :remote=>true --- actionpack/lib/action_view/helpers/url_helper.rb | 4 +++- actionpack/test/template/url_helper_test.rb | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index bd179ef0b3..e56bfc7bfd 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -286,6 +286,8 @@ module ActionView form_method = method.to_s == 'get' ? 'get' : 'post' + remote = html_options.delete('remote') + request_token_tag = '' if form_method == 'post' && protect_against_forgery? request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) @@ -298,7 +300,7 @@ module ActionView html_options.merge!("type" => "submit", "value" => name) - ("
" + + ("
" + method_tag + tag("input", html_options) + request_token_tag + "
").html_safe! end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index b498ec8429..e904e88f49 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -81,6 +81,13 @@ class UrlHelperTest < ActionView::TestCase ) end + def test_button_to_with_remote_and_javascript_confirm + assert_dom_equal( + "
", + button_to("Hello", "http://www.example.com", :remote => true, :confirm => "Are you sure?") + ) + end + def test_button_to_enabled_disabled assert_dom_equal( "
", -- cgit v1.2.3 From c493370f332715dee0ef795a66e896d7f0471cbe Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Sun, 31 Jan 2010 16:30:21 -0600 Subject: UJS documentation. --- actionpack/lib/action_view/helpers/form_helper.rb | 27 +++++++++++ .../lib/action_view/helpers/form_tag_helper.rb | 29 ++++++++---- actionpack/lib/action_view/helpers/url_helper.rb | 55 ++++++++++++---------- 3 files changed, 78 insertions(+), 33 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 54610fdc71..a72357cf3d 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -225,6 +225,33 @@ module ActionView # ... # <% end %> # + # === Unobtrusive JavaScript + # + # Specifying: + # + # :remote => true + # + # in the options hash creates a form that will allow the unobtrusive JavaScript drivers to modify its + # behaviour. The expected default behaviour is an XMLHttpRequest in the background instead of the regular + # POST arrangement, but ultimately the behaviour is the choice of the JavaScript driver implementor. + # Even though it's using JavaScript to serialize the form elements, the form submission will work just like + # a regular submission as viewed by the receiving side (all elements available in params). + # + # Example: + # + # <% form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f| %> + # ... + # <% end %> + # + # The HTML generated for this would be: + # + #
+ #
+ # + #
+ # ... + #
+ # # === Customized form builders # # You can also build forms using a customized FormBuilder class. Subclass diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 81c76e090a..597cf311cb 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -19,6 +19,8 @@ module ActionView # If "put", "delete", or another verb is used, a hidden input with name _method # is added to simulate the verb over post. # * A list of parameters to feed to the URL the form will be posted to. + # * :remote - If set to true, will allow the Unobtrusive JavaScript drivers to control the + # submit behaviour. By default this behaviour is an ajax submit. # # ==== Examples # form_tag('/posts') @@ -30,10 +32,14 @@ module ActionView # form_tag('/upload', :multipart => true) # # =>
# - # <% form_tag '/posts' do -%> + # <% form_tag('/posts')do -%> #
<%= submit_tag 'Save' %>
# <% end -%> # # =>
+ # + # <% form_tag('/posts', :remote => true) %> + # # =>
+ # def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block) html_options = html_options_for_form(url_for_options, options, *parameters_for_url) if block_given? @@ -333,12 +339,13 @@ module ActionView # Creates a submit button with the text value as the caption. # # ==== Options - # * :confirm => 'question?' - This will add a JavaScript confirm - # prompt with the question specified. If the user accepts, the form is - # processed normally, otherwise no action is taken. + # * :confirm => 'question?' - If present the unobtrusive JavaScript + # drivers will provide a prompt with the question specified. If the user accepts, + # the form is processed normally, otherwise no action is taken. # * :disabled - If true, the user will not be able to use this input. - # * :disable_with - Value of this parameter will be used as the value for a disabled version - # of the submit button when the form is submitted. + # * :disable_with - Value of this parameter will be used as the value for a + # disabled version of the submit button when the form is submitted. This feature is + # provided by the unobtrusive JavaScript driver. # * Any other key creates standard HTML options for the tag. # # ==== Examples @@ -351,16 +358,22 @@ module ActionView # submit_tag "Save edits", :disabled => true # # => # + # # submit_tag "Complete sale", :disable_with => "Please wait..." - # # => # # submit_tag nil, :class => "form_submit" # # => # # submit_tag "Edit", :disable_with => "Editing...", :class => "edit-button" - # # => + # + # submit_tag "Save", :confirm => "Are you sure?" + # # => + # def submit_tag(value = "Save changes", options = {}) options.stringify_keys! diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index e56bfc7bfd..4301647a2c 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -117,8 +117,8 @@ module ActionView # end # # ==== Options - # * :confirm => 'question?' - This will add a JavaScript confirm - # prompt with the question specified. If the user accepts, the link is + # * :confirm => 'question?' - This will allow the unobtrusive JavaScript + # driver to prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. # * :method => symbol of HTTP verb - This modifier will dynamically # create an HTML form and immediately submit the form for processing using @@ -195,18 +195,15 @@ module ActionView # link_to "Nonsense search", searches_path(:foo => "bar", :baz => "quux") # # => Nonsense search # - # The three options specific to +link_to+ (:confirm and :method) are used as follows: + # The two options specific to +link_to+ (:confirm and :method) are used as follows: # # link_to "Visit Other Site", "http://www.rubyonrails.org/", :confirm => "Are you sure?" - # # => Visit Other Site - # - # link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete - # # => Delete Image + # # => Visit Other Site + # + # link_to("Destroy", "http://www.example.com", :method => :delete, :confirm => "Are you sure?") + # # => Destroy + + # def link_to(*args, &block) if block_given? options = args.first || {} @@ -256,9 +253,11 @@ module ActionView # There are a few special +html_options+: # * :method - Specifies the anchor name to be appended to the path. # * :disabled - Specifies the anchor name to be appended to the path. - # * :confirm - This will add a JavaScript confirm + # * :confirm - This will use the unobtrusive JavaScript driver to # prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. + # * :remote - If set to true, will allow the Unobtrusive JavaScript drivers to control the + # submit behaviour. By default this behaviour is an ajax submit. # # ==== Examples # <%= button_to "New", :action => "new" %> @@ -266,15 +265,27 @@ module ActionView # #
# #
" # - # button_to "Delete Image", { :action => "delete", :id => @image.id }, - # :confirm => "Are you sure?", :method => :delete + # + # <%= button_to "Delete Image", { :action => "delete", :id => @image.id }, + # :confirm => "Are you sure?", :method => :delete %> # # => "
# #
# # - # # + # # # #
# #
" + # + # + # <%= button_to('Destroy', 'http://www.example.com', :confirm => 'Are you sure?', + # :method => "delete", :remote => true, :disable_with => 'loading...') %> + # # => "
+ # #
+ # # + # # + # #
+ # #
" + # # + def button_to(name, options = {}, html_options = {}) html_options = html_options.stringify_keys convert_boolean_attributes!(html_options, %w( disabled )) @@ -567,14 +578,8 @@ module ActionView method, href = html_options.delete("method"), html_options['href'] - if confirm && method - add_confirm_to_attributes!(html_options, confirm) - add_method_to_attributes!(html_options, method) - elsif confirm - add_confirm_to_attributes!(html_options, confirm) - elsif method - add_method_to_attributes!(html_options, method) - end + add_confirm_to_attributes!(html_options, confirm) if confirm + add_method_to_attributes!(html_options, method) if method html_options["data-url"] = options[:url] if options.is_a?(Hash) && options[:url] -- cgit v1.2.3 From 9bd0422dd7b4fc9f3bebf6301b144c6a5f35c26b Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 31 Jan 2010 18:35:00 -0800 Subject: Bump arel dependency to 0.2.0 from 0.2.pre --- Gemfile | 2 +- Rakefile | 1 - activerecord/activerecord.gemspec | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 81b7ce4d49..68f68aa22d 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem "rails", "3.0.pre", :path => "railties" end # AR -gem "arel", "0.2.pre", :git => "git://github.com/rails/arel.git" +gem "arel", ">= 0.2.0" gem "sqlite3-ruby", ">= 1.2.5" only :test do diff --git a/Rakefile b/Rakefile index 5ae09160f0..a102b38cb7 100644 --- a/Rakefile +++ b/Rakefile @@ -38,7 +38,6 @@ Rake::GemPackageTask.new(spec) do |pkg| end task :install => :gem do - system %(cd arel && gem build arel.gemspec && gem install arel-0.2.pre.gem --no-ri --no-rdoc --ignore-dependencies) system %(cd rack && rake gem VERSION=1.0.2.pre && gem install rack-1.0.2.pre.gem --no-ri --no-rdoc --ignore-dependencies) (PROJECTS - ["railties"]).each do |project| puts "INSTALLING #{project}" diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec index c84a3ac5a9..4fd1a0213c 100644 --- a/activerecord/activerecord.gemspec +++ b/activerecord/activerecord.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', '= 3.0.pre') s.add_dependency('activemodel', '= 3.0.pre') - s.add_dependency('arel', '= 0.2.pre') + s.add_dependency('arel', '~> 0.2.0') s.require_path = 'lib' s.autorequire = 'active_record' -- cgit v1.2.3 From 9f01dff9c203821bf4ac6d7b885f1d6b018d5c79 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sun, 31 Jan 2010 16:33:06 -0800 Subject: Get rails tests running on bundler 0.9 --- Gemfile | 19 +++++++++---------- actionmailer/test/abstract_unit.rb | 9 +-------- actionpack/test/abstract_unit.rb | 11 +---------- activemodel/test/cases/helper.rb | 8 +------- activerecord/test/cases/helper.rb | 9 +-------- activeresource/test/abstract_unit.rb | 8 +------- activesupport/test/abstract_unit.rb | 10 +--------- load_paths.rb | 21 +++++++++++++++++++++ railties/Rakefile | 5 +---- railties/test/abstract_unit.rb | 12 ++---------- railties/test/isolation/abstract_unit.rb | 26 +++++++------------------- 11 files changed, 46 insertions(+), 92 deletions(-) create mode 100644 load_paths.rb diff --git a/Gemfile b/Gemfile index 68f68aa22d..68e6487e2c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,20 @@ -gem "rake", ">= 0.8.7" +path File.expand_path('..', __FILE__) +source :gemcutter + +gem "rails", "3.0.pre" + +gem "rake", ">= 0.8.7" gem "mocha", ">= 0.9.8" -gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9' -gem "rails", "3.0.pre", :path => "railties" -%w(activesupport activemodel actionpack actionmailer activerecord activeresource).each do |lib| - gem lib, '3.0.pre', :path => lib +if RUBY_VERSION < '1.9' + gem "ruby-debug", ">= 0.10.3" end # AR gem "arel", ">= 0.2.0" gem "sqlite3-ruby", ">= 1.2.5" -only :test do +group :test do gem "pg", ">= 0.8.0" gem "mysql", ">= 2.8.1" end @@ -21,8 +24,6 @@ gem "rack-test", "0.5.3" gem "RedCloth", ">= 4.2.2" if ENV['CI'] - disable_system_gems - gem "nokogiri", ">= 1.4.0" gem "memcache-client", ">= 1.7.6" @@ -34,5 +35,3 @@ if ENV['CI'] gem "test-unit", ">= 2.0.5" end end - -disable_system_gems diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index ce09bb5d61..8fb941f9c9 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -1,12 +1,5 @@ -begin - require File.expand_path('../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../load_paths', __FILE__) -require 'rubygems' require 'test/unit' require 'action_mailer' diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 7b04638ccc..867e50d5b9 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -1,10 +1,4 @@ -begin - require File.expand_path('../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../load_paths', __FILE__) $:.unshift(File.dirname(__FILE__) + '/lib') $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers') @@ -20,9 +14,6 @@ require 'action_view/base' require 'action_dispatch' require 'fixture_template' require 'active_support/dependencies' - -activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__) -$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path) require 'active_model' begin diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 917bb720d0..8bcbe54651 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -1,10 +1,4 @@ -begin - require File.expand_path('../../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../../load_paths', __FILE__) require 'config' require 'active_model' diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index fa76e2d57a..9e8bfbbee8 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -1,14 +1,7 @@ -begin - require File.expand_path('../../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../../load_paths', __FILE__) require 'config' -require 'rubygems' require 'test/unit' require 'stringio' diff --git a/activeresource/test/abstract_unit.rb b/activeresource/test/abstract_unit.rb index 1e71d5d0dd..2f43916521 100644 --- a/activeresource/test/abstract_unit.rb +++ b/activeresource/test/abstract_unit.rb @@ -1,10 +1,4 @@ -begin - require File.expand_path('../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../load_paths', __FILE__) require 'rubygems' require 'test/unit' diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index d91e0415c4..33be6f65bf 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -1,12 +1,4 @@ -ORIG_ARGV = ARGV.dup - -begin - require File.expand_path('../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../load_paths', __FILE__) require 'test/unit' require 'mocha' diff --git a/load_paths.rb b/load_paths.rb new file mode 100644 index 0000000000..55e2a530bd --- /dev/null +++ b/load_paths.rb @@ -0,0 +1,21 @@ +begin + require File.expand_path('../vendor/environment', __FILE__) +rescue LoadError + begin + require 'rubygems' + require 'bundler' + Bundler.setup + rescue LoadError + %w( + actionmailer + actionpack + activemodel + activerecord + activeresource + activesupport + railties + ).each do |framework| + $:.unshift File.expand_path("../#{framework}/lib", __FILE__) + end + end +end \ No newline at end of file diff --git a/railties/Rakefile b/railties/Rakefile index b8f5e81b85..ea0b8ef8fb 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,7 +1,4 @@ -begin - require File.expand_path('../../vendor/gems/environment', __FILE__) -rescue LoadError -end +require File.expand_path('../../load_paths', __FILE__) require 'rake' require 'rake/testtask' diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 77ef82856a..aa66dbb9be 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -1,15 +1,7 @@ ORIG_ARGV = ARGV.dup -root = File.expand_path('../../..', __FILE__) -begin - require "#{root}/vendor/gems/environment" -rescue LoadError - %w(activesupport activemodel activerecord actionpack actionmailer activeresource railties).each do |lib| - $:.unshift "#{root}/#{lib}/lib" - end -end - -$:.unshift "#{root}/railties/builtin/rails_info" +require File.expand_path("../../../load_paths", __FILE__) +$:.unshift File.expand_path("../../builtin/rails_info", __FILE__) require 'stringio' require 'test/unit' diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 940585836c..ff4ee6332b 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -183,23 +183,7 @@ module TestHelpers end def boot_rails - root = File.expand_path('../../../..', __FILE__) - begin - require "#{root}/vendor/gems/environment" - rescue LoadError - %w( - actionmailer/lib - actionpack/lib - activemodel/lib - activerecord/lib - activeresource/lib - activesupport/lib - railties/lib - railties - ).reverse_each do |path| - $:.unshift "#{root}/#{path}" - end - end + require File.expand_path('../../../../load_paths', __FILE__) end end end @@ -220,14 +204,18 @@ Module.new do end FileUtils.mkdir(tmp_path) - environment = File.expand_path('../../../../vendor/gems/environment', __FILE__) + environment = File.expand_path('../../../../load_paths', __FILE__) if File.exist?("#{environment}.rb") require_environment = "-r #{environment}" end `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}` File.open("#{tmp_path}/app_template/config/boot.rb", 'w') do |f| - f.puts "require '#{environment}'" if require_environment + if require_environment + f.puts "Dir.chdir('#{File.dirname(environment)}') do" + f.puts " require '#{environment}'" + f.puts "end" + end f.puts "require 'rails/all'" end end -- cgit v1.2.3 From dfeae62e57105e5a1986f0af80bc104355e3364f Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sun, 31 Jan 2010 19:25:51 -0800 Subject: Update the CI geminstaller to pull in the correct version of bundler --- ci/geminstaller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/geminstaller.yml b/ci/geminstaller.yml index 3dc2000bf9..1f1ecb49d4 100644 --- a/ci/geminstaller.yml +++ b/ci/geminstaller.yml @@ -5,4 +5,4 @@ gems: - name: rubygems-update version: >= 1.3.5 - name: bundler - version: >= 0.7.1 + version: >= 0.9.0.pre -- cgit v1.2.3 From 1c83fd2eff3fd174e1aba0512aa2dd8ecdadb2c7 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sun, 31 Jan 2010 19:35:11 -0800 Subject: Have rails depend on bundler --- rails.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/rails.gemspec b/rails.gemspec index 878a342903..b44dc27cb0 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.add_dependency('activeresource', '= 3.0.pre') s.add_dependency('actionmailer', '= 3.0.pre') s.add_dependency('railties', '= 3.0.pre') + s.add_dependency('bundler', '>= 0.9.0.pre') s.rdoc_options << '--exclude' << '.' s.has_rdoc = false -- cgit v1.2.3 From 4cbb9db0a5ff65b0a626a5b043331abefd89e717 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 31 Jan 2010 19:17:42 -0800 Subject: For performance reasons, you can no longer call html_safe! on Strings. Instead, all Strings are always not html_safe?. Instead, you can get a SafeBuffer from a String by calling #html_safe, which will SafeBuffer.new(self). * Additionally, instead of doing concat("".html_safe), you can do safe_concat(""), which will skip both the flag set, and the flag check. * For the first pass, I converted virtually all #html_safe!s to #html_safe, and the tests pass. A further optimization would be to try to use #safe_concat as much as possible, reducing the performance impact if we know up front that a String is safe. --- actionpack/lib/action_view.rb | 4 +- actionpack/lib/action_view/base.rb | 2 +- actionpack/lib/action_view/erb/util.rb | 49 ---------- .../lib/action_view/helpers/active_model_helper.rb | 11 +-- .../lib/action_view/helpers/asset_tag_helper.rb | 6 +- actionpack/lib/action_view/helpers/date_helper.rb | 14 +-- actionpack/lib/action_view/helpers/debug_helper.rb | 4 +- actionpack/lib/action_view/helpers/form_helper.rb | 4 +- .../lib/action_view/helpers/form_options_helper.rb | 2 +- .../lib/action_view/helpers/form_tag_helper.rb | 6 +- .../lib/action_view/helpers/number_helper.rb | 2 +- .../lib/action_view/helpers/prototype_helper.rb | 2 +- .../lib/action_view/helpers/raw_output_helper.rb | 2 +- .../lib/action_view/helpers/sanitize_helper.rb | 12 +-- actionpack/lib/action_view/helpers/tag_helper.rb | 8 +- actionpack/lib/action_view/helpers/text_helper.rb | 10 +- .../lib/action_view/helpers/translation_helper.rb | 2 +- actionpack/lib/action_view/helpers/url_helper.rb | 8 +- actionpack/lib/action_view/render/partials.rb | 2 +- actionpack/lib/action_view/safe_buffer.rb | 27 ------ actionpack/lib/action_view/test_case.rb | 2 +- actionpack/test/controller/caching_test.rb | 4 +- actionpack/test/controller/output_escaping_test.rb | 2 +- actionpack/test/template/erb_util_test.rb | 2 +- actionpack/test/template/form_helper_test.rb | 2 +- actionpack/test/template/form_tag_helper_test.rb | 6 +- actionpack/test/template/safe_buffer_test.rb | 2 +- actionpack/test/template/test_case_test.rb | 2 +- activesupport/lib/active_support.rb | 1 + .../core_ext/string/output_safety.rb | 106 +++++++++++++++++---- activesupport/test/core_ext/string_ext_test.rb | 67 ++++++------- 31 files changed, 178 insertions(+), 195 deletions(-) delete mode 100644 actionpack/lib/action_view/erb/util.rb delete mode 100644 actionpack/lib/action_view/safe_buffer.rb diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb index 93aa69c060..20a2a63621 100644 --- a/actionpack/lib/action_view.rb +++ b/actionpack/lib/action_view.rb @@ -56,7 +56,9 @@ module ActionView autoload :TestCase, 'action_view/test_case' end -require 'action_view/erb/util' +require 'active_support/core_ext/string/output_safety' require 'action_view/base' +ActionView::SafeBuffer = ActiveSupport::SafeBuffer + I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml" diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 07ef3f2140..148d507f1c 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -284,7 +284,7 @@ module ActionView #:nodoc: @helpers = self.class.helpers || Module.new @_controller = controller - @_content_for = Hash.new {|h,k| h[k] = ActionView::SafeBuffer.new } + @_content_for = Hash.new {|h,k| h[k] = ActiveSupport::SafeBuffer.new } @_virtual_path = nil self.view_paths = view_paths end diff --git a/actionpack/lib/action_view/erb/util.rb b/actionpack/lib/action_view/erb/util.rb deleted file mode 100644 index aef859b3ac..0000000000 --- a/actionpack/lib/action_view/erb/util.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'erb' - -class ERB - module Util - HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } - JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' } - - # A utility method for escaping HTML tag characters. - # This method is also aliased as h. - # - # In your ERb templates, use this method to escape any unsafe content. For example: - # <%=h @person.name %> - # - # ==== Example: - # puts html_escape("is a > 0 & a < 10?") - # # => is a > 0 & a < 10? - def html_escape(s) - s = s.to_s - if s.html_safe? - s - else - s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe! - end - end - - undef :h - alias h html_escape - - module_function :html_escape - module_function :h - - # A utility method for escaping HTML entities in JSON strings. - # This method is also aliased as j. - # - # In your ERb templates, use this method to escape any HTML entities: - # <%=j @person.to_json %> - # - # ==== Example: - # puts json_escape("is a > 0 & a < 10?") - # # => is a \u003E 0 \u0026 a \u003C 10? - def json_escape(s) - s.to_s.gsub(/[&"><]/) { |special| JSON_ESCAPE[special] } - end - - alias j json_escape - module_function :j - module_function :json_escape - end -end diff --git a/actionpack/lib/action_view/helpers/active_model_helper.rb b/actionpack/lib/action_view/helpers/active_model_helper.rb index 87b7adf6c4..e106bb0897 100644 --- a/actionpack/lib/action_view/helpers/active_model_helper.rb +++ b/actionpack/lib/action_view/helpers/active_model_helper.rb @@ -6,7 +6,7 @@ require 'active_support/core_ext/kernel/reporting' module ActionView class Base - @@field_error_proc = Proc.new{ |html_tag, instance| "
#{html_tag}
".html_safe! } + @@field_error_proc = Proc.new{ |html_tag, instance| "
#{html_tag}
".html_safe } cattr_accessor :field_error_proc end @@ -86,12 +86,11 @@ module ActionView submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :enctype => options[:multipart] ? 'multipart/form-data': nil) - contents << hidden_field(record_name, :id) unless record.new_record? - contents << all_input_tags(record, record_name, options) + contents.safe_concat hidden_field(record_name, :id) unless record.new_record? + contents.safe_concat all_input_tags(record, record_name, options) yield contents if block_given? - contents << submit_tag(submit_value) - contents << '' - contents.html_safe! + contents.safe_concat submit_tag(submit_value) + contents.safe_concat('') end # Returns a string containing the error message attached to the +method+ on the +object+ if one exists. diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 4df99f8293..96976ce45f 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -293,7 +293,7 @@ module ActionView else sources = expand_javascript_sources(sources, recursive) ensure_javascript_sources!(sources) if cache - sources.collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe! + sources.collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe end end @@ -444,7 +444,7 @@ module ActionView else sources = expand_stylesheet_sources(sources, recursive) ensure_stylesheet_sources!(sources) if cache - sources.collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe! + sources.collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe end end @@ -588,7 +588,7 @@ module ActionView if sources.is_a?(Array) content_tag("video", options) do - sources.map { |source| tag("source", :src => source) }.join.html_safe! + sources.map { |source| tag("source", :src => source) }.join.html_safe end else options[:src] = path_to_video(sources) diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 34f38b0a8a..8be2f76bd6 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -616,7 +616,7 @@ module ActionView build_selects_from_types(order) else - "#{select_date}#{@options[:datetime_separator]}#{select_time}".html_safe! + "#{select_date}#{@options[:datetime_separator]}#{select_time}".html_safe end end @@ -835,7 +835,7 @@ module ActionView select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt] select_html << select_options_as_html.to_s - (content_tag(:select, select_html, select_options) + "\n").html_safe! + (content_tag(:select, select_html, select_options) + "\n").html_safe end # Builds a prompt option tag with supplied options or from default options @@ -865,7 +865,7 @@ module ActionView :id => input_id_from_type(type), :name => input_name_from_type(type), :value => value - }) + "\n").html_safe! + }) + "\n").html_safe end # Returns the name attribute for the input tag @@ -896,7 +896,7 @@ module ActionView separator = separator(type) unless type == order.first # don't add on last field select.insert(0, separator.to_s + send("select_#{type}").to_s) end - select.html_safe! + select.html_safe end # Returns the separator for a given datetime component @@ -916,15 +916,15 @@ module ActionView class InstanceTag #:nodoc: def to_date_select_tag(options = {}, html_options = {}) - datetime_selector(options, html_options).select_date.html_safe! + datetime_selector(options, html_options).select_date.html_safe end def to_time_select_tag(options = {}, html_options = {}) - datetime_selector(options, html_options).select_time.html_safe! + datetime_selector(options, html_options).select_time.html_safe end def to_datetime_select_tag(options = {}, html_options = {}) - datetime_selector(options, html_options).select_datetime.html_safe! + datetime_selector(options, html_options).select_datetime.html_safe end private diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb index 885945fde3..e637dc1474 100644 --- a/actionpack/lib/action_view/helpers/debug_helper.rb +++ b/actionpack/lib/action_view/helpers/debug_helper.rb @@ -27,10 +27,10 @@ module ActionView def debug(object) begin Marshal::dump(object) - "
#{h(object.to_yaml).gsub("  ", "  ")}
".html_safe! + "
#{h(object.to_yaml).gsub("  ", "  ")}
".html_safe rescue Exception => e # errors from Marshal or YAML # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback - "#{h(object.inspect)}".html_safe! + "#{h(object.inspect)}".html_safe end end end diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index a72357cf3d..76998a6ea1 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -311,7 +311,7 @@ module ActionView concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {})) fields_for(object_name, *(args << options), &proc) - concat(''.html_safe!) + safe_concat('') end def apply_form_for_options!(object_or_array, options) #:nodoc: @@ -879,7 +879,7 @@ module ActionView end hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value) checkbox = tag("input", options) - (hidden + checkbox).html_safe! + (hidden + checkbox).html_safe end def to_boolean_select_tag(options = {}) diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 02ad637509..0ffe770f5f 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -296,7 +296,7 @@ module ActionView options << %() end - options_for_select.join("\n").html_safe! + options_for_select.join("\n").html_safe end # Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 597cf311cb..9b8471c6c6 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -446,7 +446,7 @@ module ActionView concat(tag(:fieldset, options, true)) concat(content_tag(:legend, legend)) unless legend.blank? concat(content) - concat("".html_safe!) + safe_concat("") end private @@ -474,14 +474,14 @@ module ActionView def form_tag_html(html_options) extra_tags = extra_tags_for_form(html_options) - (tag(:form, html_options, true) + extra_tags).html_safe! + (tag(:form, html_options, true) + extra_tags).html_safe end def form_tag_in_block(html_options, &block) content = capture(&block) concat(form_tag_html(html_options)) concat(content) - concat("".html_safe!) + safe_concat("") end def token_tag diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 64b71663c3..3d3502a08b 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -92,7 +92,7 @@ module ActionView :precision => precision, :delimiter => delimiter, :separator => separator) - ).gsub(/%u/, unit).html_safe! + ).gsub(/%u/, unit).html_safe rescue number end diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index d335d89274..7eb6bceca0 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -610,7 +610,7 @@ module ActionView # page.hide 'spinner' # end def update_page(&block) - JavaScriptGenerator.new(@template, &block).to_s.html_safe! + JavaScriptGenerator.new(@template, &block).to_s.html_safe end # Works like update_page but wraps the generated JavaScript in a