diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-17 11:54:09 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-17 11:54:09 -0700 |
commit | 24226c51f075ed8d8e721cdefb6d2661c0a1f53a (patch) | |
tree | cc2dd2e420755a2991fcd44c0a2993d6092e99f3 | |
parent | 69ed422a9c534224eb818636d79d4263e2abd0a2 (diff) | |
download | rails-24226c51f075ed8d8e721cdefb6d2661c0a1f53a.tar.gz rails-24226c51f075ed8d8e721cdefb6d2661c0a1f53a.tar.bz2 rails-24226c51f075ed8d8e721cdefb6d2661c0a1f53a.zip |
Raise a more helpful error for people who are using these extracted features
-rw-r--r-- | actionpack/lib/action_controller/metal/mime_responds.rb | 17 | ||||
-rw-r--r-- | actionpack/test/controller/mime/responder_test.rb | 30 |
2 files changed, 46 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index a533f03b6d..f5565947aa 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -5,6 +5,21 @@ module ActionController #:nodoc: module MimeResponds 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 # might look something like this: # @@ -165,7 +180,7 @@ module ActionController #:nodoc: # format.html.phone { redirect_to progress_path } # format.html.none { render "trash" } # end - # + # # Variants also support common `any`/`all` block that formats have. # # It works for both inline: diff --git a/actionpack/test/controller/mime/responder_test.rb b/actionpack/test/controller/mime/responder_test.rb new file mode 100644 index 0000000000..6201af3299 --- /dev/null +++ b/actionpack/test/controller/mime/responder_test.rb @@ -0,0 +1,30 @@ +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 |