lundi 23 mars 2015

Rails: how to test and access custom routing

so far in routes.rb



match 'campaigns_mobile_application', to: 'campaigns#update_mobile_store_application', via: [:post, :get]


in spec_helper.rb



config.include Rails.application.routes.url_helpers


in controller_spec.rb



get campaigns_mobile_application_path format: :json # and here I have error


ok, I have error:



ActionController::RoutingError No route matches {:controller=>"campaigns", :action=>"/api/campaigns_mobile_application.json"}


change routes.rb now:



resources :campaigns do
match 'mobile_application', to: 'campaigns#update_mobile_store_application', via: [:post, :get]
end


and also spec:



get campaign_mobile_application_path campaign_id: @campaign.id, format: :json


and again I catch error:



ActionController::RoutingError:
No route matches {:controller=>"campaigns", :action=>"/api/campaigns/6775/mobile_application.json"}


How to fix this?


Aucun commentaire:

Enregistrer un commentaire