I mounted in my app the RailsAdmin engine ( according to the instructions from the wiki ) using
mount RailsAdmin::Engine => '/backend', :as => 'rails_admin'
I had to extend one controller from the engine to add a before_filter. When running my app in development, my extension and the other engine features are working perfectly.
However I have an issue in writing functional tests using Test::Unit for my before_filter. The filter kicks in at the right moment and works as expected, but once the action "tweaked" by the before filter redirects to index ( which is an expected result ), I get the following routing error:
ActionController::RoutingError: No route matches {:controller=>"rails_admin/main"}
The code leading to the exception lies in the engine's method to redirect to index or to the previous page ( kind of referer ); here is the code for the method
def back_or_index
if params[:return_to].presence
params[:return_to]
else
index_path
end
I discovered that when running the app in development, the url_for call triggered by index_path is supplied with the proper path_segments ( i.e.: :model_name => 'user' ) so that the route below is matched
index GET|POST /:model_name(.:format) rails_admin/main#index
On the other hand, when running the tests, the path_segments are not supplied, thus the :model_name constraint is not satisfied when looking for a matching route.
Since I'm new to engines, can someone tell me what I'm missing?
To me it looks as if the engine should take into consideration the fact that is mounted generating the index_path, but as I said I'm not an expert in this....