aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/responder.rb20
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb4
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb13
-rw-r--r--actionpack/lib/action_view.rb19
-rw-r--r--actionpack/lib/action_view/base.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb12
-rw-r--r--actionpack/lib/action_view/lookup_context.rb2
-rw-r--r--actionpack/lib/action_view/partials.rb (renamed from actionpack/lib/action_view/render/partials.rb)0
-rw-r--r--actionpack/lib/action_view/path_set.rb (renamed from actionpack/lib/action_view/paths.rb)0
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb4
-rw-r--r--actionpack/lib/action_view/renderer/template_renderer.rb5
-rw-r--r--actionpack/lib/action_view/rendering.rb (renamed from actionpack/lib/action_view/render/rendering.rb)0
-rw-r--r--actionpack/lib/action_view/template.rb9
-rw-r--r--actionpack/lib/action_view/template/handler.rb4
-rw-r--r--actionpack/lib/action_view/template/inline.rb20
-rw-r--r--actionpack/test/controller/mime_responds_test.rb19
-rw-r--r--actionpack/test/controller/new_base/render_once_test.rb46
-rw-r--r--actionpack/test/dispatch/request_test.rb12
-rw-r--r--actionpack/test/dispatch/show_exceptions_test.rb20
-rw-r--r--actionpack/test/template/form_helper_test.rb15
-rw-r--r--actionpack/test/template/form_tag_helper_test.rb10
-rw-r--r--actionpack/test/template/log_subscriber_test.rb6
-rw-r--r--actionpack/test/template/lookup_context_test.rb4
-rw-r--r--actionpack/test/template/template_test.rb8
-rw-r--r--actionpack/test/template/url_helper_test.rb21
26 files changed, 181 insertions, 100 deletions
diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb
index 851925e1b7..38d32211cc 100644
--- a/actionpack/lib/action_controller/metal/responder.rb
+++ b/actionpack/lib/action_controller/metal/responder.rb
@@ -161,6 +161,8 @@ module ActionController #:nodoc:
display resource.errors, :status => :unprocessable_entity
elsif post?
display resource, :status => :created, :location => api_location
+ elsif has_empty_resource_definition?
+ display empty_resource, :status => :ok
else
head :ok
end
@@ -221,5 +223,23 @@ module ActionController #:nodoc:
def default_action
@action ||= ACTIONS_FOR_VERBS[request.request_method_symbol]
end
+
+ # Check whether resource needs a specific definition of empty resource to be valid
+ #
+ def has_empty_resource_definition?
+ respond_to?("empty_#{format}_resource")
+ end
+
+ # Delegate to proper empty resource method
+ #
+ def empty_resource
+ send("empty_#{format}_resource")
+ end
+
+ # Return a valid empty JSON resource
+ #
+ def empty_json_resource
+ "{}"
+ end
end
end
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index bbcdefb190..55a3166f6d 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -214,13 +214,13 @@ module ActionDispatch
# Override Rack's GET method to support indifferent access
def GET
- @env["action_dispatch.request.query_parameters"] ||= normalize_parameters(super)
+ @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {})
end
alias :query_parameters :GET
# Override Rack's POST method to support indifferent access
def POST
- @env["action_dispatch.request.request_parameters"] ||= normalize_parameters(super)
+ @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {})
end
alias :request_parameters :POST
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index ef0c9c51f5..71e736ce9f 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -62,6 +62,7 @@ module ActionDispatch
private
def render_exception(env, exception)
log_error(exception)
+ exception = original_exception(exception)
request = Request.new(env)
if @consider_all_requests_local || request.local?
@@ -154,5 +155,17 @@ module ActionDispatch
def logger
defined?(Rails.logger) ? Rails.logger : Logger.new($stderr)
end
+
+ def original_exception(exception)
+ if registered_original_exception?(exception)
+ exception.original_exception
+ else
+ exception
+ end
+ end
+
+ def registered_original_exception?(exception)
+ exception.respond_to?(:original_exception) && @@rescue_responses.has_key?(exception.original_exception.class.name)
+ end
end
end
diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb
index 0f9d35d062..dada64a86f 100644
--- a/actionpack/lib/action_view.rb
+++ b/actionpack/lib/action_view.rb
@@ -21,9 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
-$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
-
require 'active_support/ruby/shim'
require 'active_support/core_ext/class/attribute_accessors'
@@ -33,14 +30,15 @@ module ActionView
extend ActiveSupport::Autoload
eager_autoload do
+ autoload :Base
autoload :Context
- autoload :Template
autoload :Helpers
- autoload :Base
autoload :LookupContext
- autoload :Render
- autoload :PathSet, "action_view/paths"
- autoload :TestCase, "action_view/test_case"
+ autoload :Partials
+ autoload :PathSet
+ autoload :Rendering
+ autoload :Template
+ autoload :TestCase
autoload_under "renderer" do
autoload :AbstractRenderer
@@ -48,11 +46,6 @@ module ActionView
autoload :TemplateRenderer
end
- autoload_under "render" do
- autoload :Partials
- autoload :Rendering
- end
-
autoload_at "action_view/template/resolver" do
autoload :Resolver
autoload :PathResolver
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index a7a6bbd3a4..1beae37af3 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -224,6 +224,10 @@ module ActionView #:nodoc:
@controller_path ||= controller && controller.controller_path
end
+ def controller_prefix
+ @controller_prefix ||= controller && controller._prefix
+ end
+
ActiveSupport.run_load_hooks(:action_view, self)
end
end
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 298db46177..ae83b6bf39 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -390,7 +390,7 @@ module ActionView
end
if confirm = options.delete("confirm")
- add_confirm_to_attributes!(options, confirm)
+ options["data-confirm"] = confirm
end
tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
@@ -423,7 +423,7 @@ module ActionView
options.stringify_keys!
if confirm = options.delete("confirm")
- add_confirm_to_attributes!(options, confirm)
+ options["data-confirm"] = confirm
end
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index da42d94318..c007cac47f 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -587,10 +587,12 @@ module ActionView
html_options = html_options.stringify_keys
html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options)
+ disable_with = html_options.delete("disable_with")
confirm = html_options.delete('confirm')
method = html_options.delete('method')
- add_confirm_to_attributes!(html_options, confirm) if confirm
+ html_options["data-disable-with"] = disable_with if disable_with
+ html_options["data-confirm"] = confirm if confirm
add_method_to_attributes!(html_options, method) if method
html_options
@@ -601,13 +603,9 @@ module ActionView
options.is_a?(Hash) && options.key?('remote') && options.delete('remote')
end
- def add_confirm_to_attributes!(html_options, confirm)
- html_options["data-confirm"] = confirm if confirm
- end
-
def add_method_to_attributes!(html_options, method)
- html_options["rel"] = "nofollow" if method && method.to_s.downcase != "get"
- html_options["data-method"] = method if method
+ html_options["rel"] = "nofollow" if method.to_s.downcase != "get"
+ html_options["data-method"] = method
end
def options_for_javascript(options)
diff --git a/actionpack/lib/action_view/lookup_context.rb b/actionpack/lib/action_view/lookup_context.rb
index 80451798b1..27f94a73a6 100644
--- a/actionpack/lib/action_view/lookup_context.rb
+++ b/actionpack/lib/action_view/lookup_context.rb
@@ -61,7 +61,7 @@ module ActionView
def initialize(view_paths, details = {})
@details, @details_key = { :handlers => default_handlers }, nil
@frozen_formats, @skip_default_locale = false, false
- @cache = details.key?(:cache) ? details.delete(:cache) : true
+ @cache = true
self.view_paths = view_paths
self.registered_detail_setters.each do |key, setter|
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/partials.rb
index 844c3e9572..844c3e9572 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/partials.rb
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/path_set.rb
index dc26d75ff3..dc26d75ff3 100644
--- a/actionpack/lib/action_view/paths.rb
+++ b/actionpack/lib/action_view/path_set.rb
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index eff425687b..c580397cad 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -110,7 +110,7 @@ module ActionView
end
def find_template(path=@path, locals=@locals.keys)
- prefix = @view.controller_path unless path.include?(?/)
+ prefix = @view.controller_prefix unless path.include?(?/)
@lookup_context.find_template(path, prefix, true, locals)
end
@@ -151,7 +151,7 @@ module ActionView
object = object.to_model if object.respond_to?(:to_model)
object.class.model_name.partial_path.dup.tap do |partial|
- path = @view.controller_path
+ path = @view.controller_prefix
partial.insert(0, "#{File.dirname(path)}/") if partial.include?(?/) && path.include?(?/)
end
end
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb
index a9076760c5..36beb5c8d0 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/template_renderer.rb
@@ -21,7 +21,8 @@ module ActionView
def render_once(options)
paths, locals = options[:once], options[:locals] || {}
- layout, keys, prefix = options[:layout], locals.keys, options[:prefix]
+ layout, keys = options[:layout], locals.keys
+ prefix = options.fetch(:prefix, @view.controller_prefix)
raise "render :once expects a String or an Array to be given" unless paths
@@ -45,7 +46,7 @@ module ActionView
with_fallbacks { find_template(options[:file], options[:prefix], false, keys) }
elsif options.key?(:inline)
handler = Template.handler_class_for_extension(options[:type] || "erb")
- Template::Inline.new(options[:inline], handler, :locals => keys)
+ Template.new(options[:inline], "inline template", handler, :locals => keys)
elsif options.key?(:template)
options[:template].respond_to?(:render) ?
options[:template] : find_template(options[:template], options[:prefix], false, keys)
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/rendering.rb
index baa5d2c3fd..baa5d2c3fd 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/rendering.rb
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 3ba18cbfae..7dd8acf37b 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -93,7 +93,6 @@ module ActionView
autoload :Error
autoload :Handler
autoload :Handlers
- autoload :Inline
autoload :Text
end
@@ -185,14 +184,6 @@ module ActionView
end
end
- def hash
- identifier.hash
- end
-
- def eql?(other)
- other.is_a?(Template) && other.identifier == identifier
- end
-
def inspect
@inspect ||=
if defined?(Rails.root)
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb
index 0a9d299807..636f3ebbad 100644
--- a/actionpack/lib/action_view/template/handler.rb
+++ b/actionpack/lib/action_view/template/handler.rb
@@ -8,7 +8,7 @@ module ActionView
module Compilable
def self.included(base)
ActiveSupport::Deprecation.warn "Including Compilable in your template handler is deprecated. " <<
- "All the API your template handler needs to implement is to respond to #call."
+ "Since Rails 3, all the API your template handler needs to implement is to respond to #call."
base.extend(ClassMethods)
end
@@ -30,7 +30,7 @@ module ActionView
def self.inherited(base)
ActiveSupport::Deprecation.warn "Inheriting from ActionView::Template::Handler is deprecated. " <<
- "All the API your template handler needs to implement is to respond to #call."
+ "Since Rails 3, all the API your template handler needs to implement is to respond to #call."
super
end
diff --git a/actionpack/lib/action_view/template/inline.rb b/actionpack/lib/action_view/template/inline.rb
deleted file mode 100644
index be08065b6b..0000000000
--- a/actionpack/lib/action_view/template/inline.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'digest/md5'
-
-module ActionView
- class Template
- class Inline < ::ActionView::Template
- def initialize(source, handler, options={})
- super(source, "inline template", handler, options)
- end
-
- def md5_source
- @md5_source ||= Digest::MD5.hexdigest(source)
- end
-
- def eql?(other)
- other.is_a?(Inline) && other.md5_source == md5_source
- end
- end
- end
-end
- \ No newline at end of file
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index adccfa028f..a898ef76e5 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -709,6 +709,15 @@ class RespondWithControllerTest < ActionController::TestCase
assert_equal " ", @response.body
end
+ def test_using_resource_for_put_with_json_yields_ok_on_success
+ Customer.any_instance.stubs(:to_json).returns('{"name": "David"}')
+ @request.accept = "application/json"
+ put :using_resource
+ assert_equal "application/json", @response.content_type
+ assert_equal 200, @response.status
+ assert_equal "{}", @response.body
+ end
+
def test_using_resource_for_put_with_xml_yields_unprocessable_entity_on_failure
@request.accept = "application/xml"
errors = { :name => :invalid }
@@ -739,6 +748,16 @@ class RespondWithControllerTest < ActionController::TestCase
assert_equal " ", @response.body
end
+ def test_using_resource_for_delete_with_json_yields_ok_on_success
+ Customer.any_instance.stubs(:to_json).returns('{"name": "David"}')
+ Customer.any_instance.stubs(:destroyed?).returns(true)
+ @request.accept = "application/json"
+ delete :using_resource
+ assert_equal "application/json", @response.content_type
+ assert_equal 200, @response.status
+ assert_equal "{}", @response.body
+ end
+
def test_using_resource_for_delete_with_html_redirects_on_failure
with_test_route_set do
errors = { :name => :invalid }
diff --git a/actionpack/test/controller/new_base/render_once_test.rb b/actionpack/test/controller/new_base/render_once_test.rb
index 63de25be52..3035ed4ff2 100644
--- a/actionpack/test/controller/new_base/render_once_test.rb
+++ b/actionpack/test/controller/new_base/render_once_test.rb
@@ -8,29 +8,42 @@ module RenderTemplate
"test/a.html.erb" => "a",
"test/b.html.erb" => "<>",
"test/c.html.erb" => "c",
- "test/one.html.erb" => "<%= render :once => 'test/result' %>",
- "test/two.html.erb" => "<%= render :once => 'test/result' %>",
- "test/three.html.erb" => "<%= render :once => 'test/result' %>",
+ "test/one.html.erb" => "<%= render :once => 'result' %>",
+ "test/two.html.erb" => "<%= render :once => 'result' %>",
+ "test/three.html.erb" => "<%= render :once => 'result' %>",
"test/result.html.erb" => "YES!",
+ "other/result.html.erb" => "NO!",
"layouts/test.html.erb" => "l<%= yield %>l"
)
self.view_paths = [RESOLVER]
+ def _prefix
+ "test"
+ end
+
def multiple
- render :once => %w(test/a test/b test/c)
+ render :once => %w(a b c)
end
def once
- render :once => %w(test/one test/two test/three)
+ render :once => %w(one two three)
end
def duplicate
- render :once => %w(test/a test/a test/a)
+ render :once => %w(a a a)
end
def with_layout
- render :once => %w(test/a test/b test/c), :layout => "test"
+ render :once => %w(a b c), :layout => "test"
+ end
+
+ def with_prefix
+ render :once => "result", :prefix => "other"
+ end
+
+ def with_nil_prefix
+ render :once => "test/result", :prefix => nil
end
end
@@ -54,19 +67,20 @@ module RenderTemplate
get :with_layout
assert_response "la\n<>\ncl"
end
- end
- class TestWithResolverCache < Rack::TestCase
- testing RenderTemplate::RenderOnceController
- include Tests
+ def test_with_prefix_option
+ get :with_prefix
+ assert_response "NO!"
+ end
+
+ def test_with_nil_prefix_option
+ get :with_nil_prefix
+ assert_response "YES!"
+ end
end
- class TestWithoutResolverCache < Rack::TestCase
+ class TestRenderOnce < Rack::TestCase
testing RenderTemplate::RenderOnceController
include Tests
-
- def setup
- RenderTemplate::RenderOnceController::RESOLVER.stubs(:caching?).returns(false)
- end
end
end
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 3efed8bef6..04709e5346 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -385,6 +385,18 @@ class RequestTest < ActiveSupport::TestCase
assert_equal({"bar" => 2}, request.query_parameters)
end
+ test "parameters still accessible after rack parse error" do
+ mock_rack_env = { "QUERY_STRING" => "x[y]=1&x[y][][w]=2", "rack.input" => "foo" }
+ request = nil
+ begin
+ request = stub_request(mock_rack_env)
+ request.parameters
+ rescue TypeError => e
+ # rack will raise a TypeError when parsing this query string
+ end
+ assert_equal({}, request.parameters)
+ end
+
test "formats with accept header" do
request = stub_request 'HTTP_ACCEPT' => 'text/html'
request.expects(:parameters).at_least_once.returns({})
diff --git a/actionpack/test/dispatch/show_exceptions_test.rb b/actionpack/test/dispatch/show_exceptions_test.rb
index ce6c397e32..2a478c214f 100644
--- a/actionpack/test/dispatch/show_exceptions_test.rb
+++ b/actionpack/test/dispatch/show_exceptions_test.rb
@@ -1,6 +1,7 @@
require 'abstract_unit'
class ShowExceptionsTest < ActionDispatch::IntegrationTest
+
Boomer = lambda do |env|
req = ActionDispatch::Request.new(env)
case req.path
@@ -12,6 +13,8 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
raise ActionController::NotImplemented
when "/unprocessable_entity"
raise ActionController::InvalidAuthenticityToken
+ when "/not_found_original_exception"
+ raise ActionView::Template::Error.new('template', {}, AbstractController::ActionNotFound.new)
else
raise "puke!"
end
@@ -101,4 +104,21 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
assert_response 500
assert_match("&quot;foo&quot;=&gt;&quot;[FILTERED]&quot;", body)
end
+
+ test "show registered original exception for wrapped exceptions when consider_all_requests_local is false" do
+ @app = ProductionApp
+ self.remote_addr = '208.77.188.166'
+
+ get "/not_found_original_exception", {}, {'action_dispatch.show_exceptions' => true}
+ assert_response 404
+ assert_match(/404 error/, body)
+ end
+
+ test "show registered original exception for wrapped exceptions when consider_all_requests_local is true" do
+ @app = DevelopmentApp
+
+ get "/not_found_original_exception", {}, {'action_dispatch.show_exceptions' => true}
+ assert_response 404
+ assert_match(/AbstractController::ActionNotFound/, body)
+ end
end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 0bfdbeebd1..acb6e7aa64 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -735,11 +735,11 @@ class FormHelperTest < ActionView::TestCase
def test_form_for_with_search_field
# Test case for bug which would emit an "object" attribute
# when used with form_for using a search_field form helper
- form_for(Post.new, :url => "/search", :html => { :id => 'search-post' }) do |f|
+ form_for(Post.new, :url => "/search", :html => { :id => 'search-post', :method => :get}) do |f|
concat f.search_field(:title)
end
- expected = whole_form("/search", "search-post", "new_post") do
+ expected = whole_form("/search", "search-post", "new_post", "get") do
"<input name='post[title]' size='30' type='search' id='post_title' />"
end
@@ -1528,17 +1528,20 @@ class FormHelperTest < ActionView::TestCase
def snowman(method = nil)
txt = %{<div style="margin:0;padding:0;display:inline">}
txt << %{<input name="utf8" type="hidden" value="&#x2713;" />}
- txt << %{<input name="_method" type="hidden" value="#{method}" />} if method
+ if (method && !['get','post'].include?(method.to_s))
+ txt << %{<input name="_method" type="hidden" value="#{method}" />}
+ end
txt << %{</div>}
end
- def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil)
+ def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil)
txt = %{<form accept-charset="UTF-8" action="#{action}"}
txt << %{ enctype="multipart/form-data"} if multipart
txt << %{ data-remote="true"} if remote
txt << %{ class="#{html_class}"} if html_class
txt << %{ id="#{id}"} if id
- txt << %{ method="post">}
+ method = method.to_s == "get" ? "get" : "post"
+ txt << %{ method="#{method}">}
end
def whole_form(action = "/", id = nil, html_class = nil, options = nil)
@@ -1550,7 +1553,7 @@ class FormHelperTest < ActionView::TestCase
method = options
end
- form_text(action, id, html_class, remote, multipart) + snowman(method) + contents + "</form>"
+ form_text(action, id, html_class, remote, multipart, method) + snowman(method) + contents + "</form>"
end
def test_default_form_builder
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb
index 8c8e87ae9f..f3933a25b9 100644
--- a/actionpack/test/template/form_tag_helper_test.rb
+++ b/actionpack/test/template/form_tag_helper_test.rb
@@ -13,19 +13,23 @@ class FormTagHelperTest < ActionView::TestCase
txt = %{<div style="margin:0;padding:0;display:inline">}
txt << %{<input name="utf8" type="hidden" value="&#x2713;" />}
- txt << %{<input name="_method" type="hidden" value="#{method}" />} if method
+ if (method && !['get','post'].include?(method.to_s))
+ txt << %{<input name="_method" type="hidden" value="#{method}" />}
+ end
txt << %{</div>}
end
def form_text(action = "http://www.example.com", options = {})
- remote, enctype, html_class, id = options.values_at(:remote, :enctype, :html_class, :id)
+ remote, enctype, html_class, id, method = options.values_at(:remote, :enctype, :html_class, :id, :method)
+
+ method = method.to_s == "get" ? "get" : "post"
txt = %{<form accept-charset="UTF-8" action="#{action}"}
txt << %{ enctype="multipart/form-data"} if enctype
txt << %{ data-remote="true"} if remote
txt << %{ class="#{html_class}"} if html_class
txt << %{ id="#{id}"} if id
- txt << %{ method="post">}
+ txt << %{ method="#{method}">}
end
def whole_form(action = "http://www.example.com", options = {})
diff --git a/actionpack/test/template/log_subscriber_test.rb b/actionpack/test/template/log_subscriber_test.rb
index 6fb8d39818..435936b19f 100644
--- a/actionpack/test/template/log_subscriber_test.rb
+++ b/actionpack/test/template/log_subscriber_test.rb
@@ -57,7 +57,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
end
def test_render_partial_with_implicit_path
- @view.stubs(:controller_path).returns("test")
+ @view.stubs(:controller_prefix).returns("test")
@view.render(Customer.new("david"), :greeting => "hi")
wait
@@ -74,7 +74,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
end
def test_render_collection_with_implicit_path
- @view.stubs(:controller_path).returns("test")
+ @view.stubs(:controller_prefix).returns("test")
@view.render([ Customer.new("david"), Customer.new("mary") ], :greeting => "hi")
wait
@@ -83,7 +83,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
end
def test_render_collection_template_without_path
- @view.stubs(:controller_path).returns("test")
+ @view.stubs(:controller_prefix).returns("test")
@view.render([ GoodCustomer.new("david"), Customer.new("mary") ], :greeting => "hi")
wait
diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb
index 850589b13b..6d3b26e131 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionpack/test/template/lookup_context_test.rb
@@ -180,10 +180,6 @@ class LookupContextTest < ActiveSupport::TestCase
assert_not_equal template, old_template
end
-
- test "can have cache disabled on initialization" do
- assert !ActionView::LookupContext.new(FIXTURE_LOAD_PATH, :cache => false).cache
- end
end
class LookupContextWithFalseCaching < ActiveSupport::TestCase
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb
index f2156c31de..63f792d328 100644
--- a/actionpack/test/template/template_test.rb
+++ b/actionpack/test/template/template_test.rb
@@ -151,14 +151,6 @@ class TestERBTemplate < ActiveSupport::TestCase
end
end
- def test_inline_template_is_only_equal_if_source_match
- inline1 = ActionView::Template::Inline.new("sample", ERBHandler)
- inline2 = ActionView::Template::Inline.new("sample", ERBHandler)
- inline3 = ActionView::Template::Inline.new("other", ERBHandler)
- assert inline1.eql?(inline2)
- assert !inline1.eql?(inline3)
- end
-
if "ruby".encoding_aware?
def test_resulting_string_is_utf8
@template = new_template
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index b8a7d4259d..a6fdf806a4 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -69,6 +69,13 @@ class UrlHelperTest < ActiveSupport::TestCase
)
end
+ def test_button_to_with_javascript_disable_with
+ assert_dom_equal(
+ "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input data-disable-with=\"Greeting...\" type=\"submit\" value=\"Hello\" /></div></form>",
+ button_to("Hello", "http://www.example.com", :disable_with => "Greeting...")
+ )
+ end
+
def test_button_to_with_remote_and_javascript_confirm
assert_dom_equal(
"<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\" data-remote=\"true\"><div><input data-confirm=\"Are you sure?\" type=\"submit\" value=\"Hello\" /></div></form>",
@@ -76,6 +83,20 @@ class UrlHelperTest < ActiveSupport::TestCase
)
end
+ def test_button_to_with_remote_and_javascript_disable_with
+ assert_dom_equal(
+ "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\" data-remote=\"true\"><div><input data-disable-with=\"Greeting...\" type=\"submit\" value=\"Hello\" /></div></form>",
+ button_to("Hello", "http://www.example.com", :remote => true, :disable_with => "Greeting...")
+ )
+ end
+
+ def test_button_to_with_remote_and_javascript_confirm_and_javascript_disable_with
+ assert_dom_equal(
+ "<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\" data-remote=\"true\"><div><input data-disable-with=\"Greeting...\" data-confirm=\"Are you sure?\" type=\"submit\" value=\"Hello\" /></div></form>",
+ button_to("Hello", "http://www.example.com", :remote => true, :confirm => "Are you sure?", :disable_with => "Greeting...")
+ )
+ end
+
def test_button_to_with_remote_false
assert_dom_equal(
"<form method=\"post\" action=\"http://www.example.com\" class=\"button_to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",