0
내가 중첩 된 자원에 대한 테스트 케이스를 작성하려고 나는 다음과 같은 오류보고 있어요에 대한 일치하지 TestCase에 :레일 ActionController :: 어떤 경로가 정의라는 이름의 중첩 된 자원
을 :Error:
test_should_get_single_budget_link(BudgetlinkControllerTest):
ActionController::RoutingError: No route matches {:budget_id=>980190962, :action=>"show", :controller=>"budgetlink"}
test/functional/budgetlink_controller_test.rb:5:in `test_should_get_single_budget_link'
내 routes.rb의 모습을 나는 내가 C를 가지고 있다는 사실이라고 생각
test "should get single budget link" do
get :show, 'budget_id' => budgets(:one).id
assert_response :success
assert_equal assigns(:budgetlink).primary, "Budget1"
assert_equal assigns(:budgetlink).secondary, "Budget2"
end
:
Simplebudget::Application.routes.draw do
root :to => "home#index"
resources :budgets do
resources :transactions
resources :budgets, :controller => :budgetlink
end
resources :classifications
resources :periodicities
end
내 테스트는 다음과 같습니다 예산 링크 대신 리소스 이름 "예산"을 사용하는 경로를 구성했으며 Rails는 현재 테스트에서 예산 경로를 인식 할 방법이 없습니다. 재 매핑 된 경로를 인식하도록 테스트를 구성하려면 어떻게해야합니까?
필요하다면 잘 모르지만 상처를 입을 수는 없다고 생각됩니다. 컨트롤러 코드는 다음과 같습니다.
class BudgetlinkController < ApplicationController
skip_before_filter :verify_authenticity_token
def show
@budgetlink = Budgetlink.find(params[:primary], params[:secondary])
respond_to do |format|
format.html #index.html.erb
format.json { render :json => @budgetlink}
end
end
end