Skip to content

Instantly share code, notes, and snippets.

@evaldosantos
Created March 22, 2017 22:17
Show Gist options
  • Save evaldosantos/6e4854fedc854fce8e2a5844fecf0f00 to your computer and use it in GitHub Desktop.
Save evaldosantos/6e4854fedc854fce8e2a5844fecf0f00 to your computer and use it in GitHub Desktop.
# routing
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
resources :markets, only: [:index] do
resources :languages, param: :key, only: [:index, :show] do
resources :labels, params: :item, only: [:show, :update] do
resource :translations , only:[:update] do
post 'validate' => 'translations#validate'
end
end
end
end
end
end
# I have a translation_controller in app/controller/api/translations_controller.rb
# I'm trying to write a functional test to this route /api/markets/:market_id/languages/:language_key/labels/:label_id/translations
describe Api::TranslationsController, type: :controller do
context '#update' do
context "when the translation isn't found" do
it 'returns an error' do
# TRY to sends a put to /api/markets/:market_id/languages/:language_key/labels/:label_id/translations
put :update, {:market_id => 1}
end
end
context 'when the translation is found' do
context 'when the value is valid' do
end
context "when the value isn't valid" do
end
end
end
end
When I run I get this error:
Failures:
1) Api::TranslationsController#update when the translation isn't found returns an error
Failure/Error: put :update, {:market_id => 1, :language_key => 'en', :label_id => '648'}, {}, format: :json
ActionController::UrlGenerationError:
No route matches {:action=>"update", :controller=>"api/translations", :label_id=>"648", :language_key=>"en", :market_id=>"1"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment