Reputation: 72504
In my Rails application I have a simple controller which also has an action with a JS view. During development mode I can access that view, but not during testing. During testing I get a "missing template" error.
I just can't figure out why this is happening. I'm posting the relevant parts, perhaps someone can help me with this.
routes.rb
resource :store, :controller => 'store' do
member do
post :add_item
end
end
store_controller_test
post :add_item, { :product_id => product.id }
Exception message
ActionView::MissingTemplate: Missing template store/add_item
Additional information:
add_item.js.erb
Upvotes: 1
Views: 154
Reputation: 34340
The reason it can't find the template is because you are not creating a javascript post request in your tests, you are creating an HTML post request. To create a javascript post request, I would change the post call to specify the format.
post :add_item, { :product_id => product.id, :format => 'js' }
Upvotes: 1