This project is archived and is in readonly mode.
NoMethodError on formats= when using ActionController::TestCase to test a direct subclass of ActionController::Metal
Reported by David Chelimsky | August 17th, 2010 @ 01:15 PM | in 3.1
When using ActionController::TestCase to test a direct subclass
of ActionController::Metal, the test case raises a
NoMethodError
on formats=
. To see this in
action:
- Type the following in a shell:
rails new example
cd example
rake db:migrate
- Add test/functional/widgets_controller_test.rb with the following code:
require 'test_helper'
class WidgetsControllerTest < ActionController::TestCase
test "GET index" do
get :index
end
end
- Add app/controllers/widgets_controller.rb with the following code:
class WidgetsController < ActionController::Metal
def index
end
end
- Run the test:
rake test:functionals
...
1) Error:
test_GET_index(WidgetsControllerTest):
NoMethodError: undefined method `formats=' for #<WidgetsController:0x101e601e8>
/test/functional/widgets_controller_test.rb:5:in `test_GET_index'
Comments and changes to this ticket
-
David Chelimsky August 17th, 2010 @ 01:15 PM
- Assigned user set to José Valim
-
Santiago Pastorino August 19th, 2010 @ 08:07 PM
- Milestone cleared.
- State changed from new to open
- Assigned user changed from José Valim to Santiago Pastorino
- Importance changed from to Low
Hey David can you add a test case
-
Rohit Arondekar August 25th, 2010 @ 04:10 AM
I'm sorry if this is a silly question, but why would you want to call get :index in a functional test?
From what I gather, the docs say that AC::Metal is for obtaining Rack app for an action.
ActionController::Metal provides an #action method that returns a valid Rack application for a given action.
From the AC::Metal docs
Also the line that's causing the error is in actionpack/lib/action_controller/metal/rendering:10
def process_action(*) #:nodoc: self.formats = request.formats.map { |x| x.to_sym } super end
But in the whole of Actionpack there is only one formats= method defined in lib/action_view/lookup_context.rb so why was this line added in Metal?
Again I apologize if I have missed something obvious.
-
Repository November 6th, 2010 @ 11:17 PM
- State changed from open to committed
(from [2382667955df08599cb5df7bf3ef135817093d74]) Fix problems trying to functional test AC::Metal controllers
[#5393 state:committed] https://github.com/rails/rails/commit/2382667955df08599cb5df7bf3ef1...
-
Santiago Pastorino November 6th, 2010 @ 11:20 PM
- State changed from committed to open
- Milestone changed from 3.0.2 to 3.1
-
Santiago Pastorino February 9th, 2011 @ 12:31 AM
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 9th, 2011 @ 12:32 AM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 5393 NoMethodError on formats= when using ActionController::TestCase to test a direct subclass of ActionController::Metal [#5393 state:committed] https://github.com/rails/rails/c...