提交 24226c51 编写于 作者: G Godfrey Chan

Raise a more helpful error for people who are using these extracted features

上级 69ed422a
...@@ -5,6 +5,21 @@ module ActionController #:nodoc: ...@@ -5,6 +5,21 @@ module ActionController #:nodoc:
module MimeResponds module MimeResponds
extend ActiveSupport::Concern extend ActiveSupport::Concern
module ClassMethods
def respond_to(*)
raise NoMethodError, "The controller-level `respond_to' feature has " \
"been extracted to the `responder` gem. Add it to your Gemfile to " \
"continue using this feature. Consult the Rails upgrade guide for " \
"details."
end
end
def respond_with(*)
raise NoMethodError, "The `respond_with' feature has been extracted " \
"to the `responder` gem. Add it to your Gemfile to continue using " \
"this feature. Consult the Rails upgrade guide for details."
end
# Without web-service support, an action which collects the data for displaying a list of people # Without web-service support, an action which collects the data for displaying a list of people
# might look something like this: # might look something like this:
# #
...@@ -165,7 +180,7 @@ module MimeResponds ...@@ -165,7 +180,7 @@ module MimeResponds
# format.html.phone { redirect_to progress_path } # format.html.phone { redirect_to progress_path }
# format.html.none { render "trash" } # format.html.none { render "trash" }
# end # end
# #
# Variants also support common `any`/`all` block that formats have. # Variants also support common `any`/`all` block that formats have.
# #
# It works for both inline: # It works for both inline:
......
require 'abstract_unit'
require 'controller/fake_models'
class ResponderTest < ActionController::TestCase
def test_class_level_respond_to
e = assert_raises(NoMethodError) do
Class.new(ActionController::Base) do
respond_to :json
end
end
assert_includes e.message, '`responder` gem'
end
def test_respond_with
klass = Class.new(ActionController::Base) do
def index
respond_with Customer.new("david", 13)
end
end
@controller = klass.new
e = assert_raises(NoMethodError) do
get :index
end
assert_includes e.message, '`responder` gem'
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册