简体   繁体   中英

ActionView::MissingTemplate during testing

I'm testing a rails controller and attempting to perform a get with the code:

delete :remove_logs, :id => 3

And it consistently returns me an ActionView::MissingTemplate exception. I know that this is because there is no view associated with the get. There is a route for this method (from rake routes):

remove_logs        /devices/remove_logs/:id(.:format)            {:controller=>"devices", :action=>"remove_logs"}

The function itself works perfectly for the actually webpage as it's being called with:

<%= link_to "Remove History", remove_logs_path(device), 
:class => "medium red button",  :confirm => 'This will remove all history from 
this device. Are you sure?', :method => :delete %>

So my question is, is there a way to bypass or trick the test to not attempt to access the view and just access the controller method? This isn't my system I'm testing so I really don't want to make a new blank view or anything similar.

I think the problem may be related with the code in controller (remove_logs action) which usually has some code about redirecting to another url like bellow:

def destroy
  @tag = Tag.find(params[:id])
  @tag.destroy
  redirect_to :action => :index
end

I test with Test::Unit in my rails app, and it goes fine when having redirecting code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM